{"id":61824,"date":"2026-01-18T17:49:39","date_gmt":"2026-01-18T09:49:39","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/61824.html"},"modified":"2026-01-18T17:49:39","modified_gmt":"2026-01-18T09:49:39","slug":"typescript-%e7%b1%bb%e5%9e%8b%e5%85%bc%e5%ae%b9%e6%80%a7%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88%e9%b8%ad%e5%ad%90%e7%b1%bb%e5%9e%8b%ef%bc%88duck-typing%ef%bc%89%e5%a6%82%e6%ad%a4%e9%87%8d%e8%a6%81","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/61824.html","title":{"rendered":"TypeScript \u7c7b\u578b\u517c\u5bb9\u6027\uff1a\u4e3a\u4ec0\u4e48\u9e2d\u5b50\u7c7b\u578b\uff08Duck Typing\uff09\u5982\u6b64\u91cd\u8981"},"content":{"rendered":"<p>\u4f60\u60f3\u641e\u61c2 TypeScript \u4e2d\u9e2d\u5b50\u7c7b\u578b\u7684\u6838\u5fc3\u4ef7\u503c\u3001\u5b83\u548c TypeScript \u7c7b\u578b\u517c\u5bb9\u6027\u7684\u5f3a\u5173\u8054&#xff0c;\u4ee5\u53ca\u80cc\u540e\u7684\u5e95\u5c42\u903b\u8f91&#xff0c;\u8fd9\u7bc7\u5185\u5bb9\u4f1a\u628a\u300c\u662f\u4ec0\u4e48\u3001\u4e3a\u4ec0\u4e48\u91cd\u8981\u3001\u600e\u4e48\u7528\u3001\u6ce8\u610f\u4e8b\u9879\u300d\u8bb2\u900f&#xff0c;\u5185\u5bb9\u5b8c\u6574\u4e14\u8d34\u5408\u5b9e\u6218\u3002<\/p>\n<h3>\u4e00\u3001\u5148\u660e\u786e\u6838\u5fc3\u5b9a\u4e49<\/h3>\n<h4>\u2705 TypeScript \u7684\u7c7b\u578b\u517c\u5bb9\u6027\u6838\u5fc3\u89c4\u5219<\/h4>\n<p>TypeScript \u662f\u57fa\u4e8e\u300c\u7ed3\u6784\u5b50\u7c7b\u578b\u300d(Structural Subtyping) \u7684\u7c7b\u578b\u7cfb\u7edf&#xff0c;\u4e0d\u662f\u57fa\u4e8e\u300c\u540d\u4e49\u7c7b\u578b\u300d(Nominal Typing)\u3002<\/p>\n<ul>\n<li>\u540d\u4e49\u7c7b\u578b&#xff1a;\u7c7b\u578b\u7684\u517c\u5bb9\u6027\u7531\u300c\u7c7b\u578b\u7684\u540d\u79f0 \/ \u8eab\u4efd\u300d\u51b3\u5b9a&#xff08;\u6bd4\u5982 Java\/C#&#xff09;&#xff0c;\u4e24\u4e2a\u7c7b\u578b\u540d\u5b57\u4e0d\u4e00\u6837&#xff0c;\u54ea\u6015\u957f\u5f97\u5b8c\u5168\u4e00\u6837&#xff0c;\u4e5f\u4e0d\u517c\u5bb9&#xff1b;<\/li>\n<li>\u7ed3\u6784\u5b50\u7c7b\u578b&#xff1a;\u7c7b\u578b\u7684\u517c\u5bb9\u6027\u53ea\u7531\u300c\u7c7b\u578b\u7684\u7ed3\u6784 \/ \u5f62\u72b6\u300d\u51b3\u5b9a \u2014\u2014 \u53ea\u8981\u4e24\u4e2a\u7c7b\u578b\u7684\u5c5e\u6027\u3001\u65b9\u6cd5\u7684\u540d\u79f0\u548c\u7c7b\u578b\u5339\u914d&#xff0c;\u5c31\u8ba4\u4e3a\u5b83\u4eec\u662f\u517c\u5bb9\u7684&#xff0c;\u548c\u300c\u7c7b\u578b\u53eb\u4ec0\u4e48\u540d\u5b57\u300d\u5b8c\u5168\u65e0\u5173\u3002<\/li>\n<\/ul>\n<h4>\u2705 \u9e2d\u5b50\u7c7b\u578b&#xff08;Duck Typing&#xff09;\u7684\u5b98\u65b9\u5b9a\u4e49<\/h4>\n<p>\u5f53\u770b\u5230\u4e00\u53ea\u9e1f\u8d70\u8d77\u6765\u50cf\u9e2d\u5b50\u3001\u6e38\u6cf3\u8d77\u6765\u50cf\u9e2d\u5b50\u3001\u53eb\u8d77\u6765\u4e5f\u50cf\u9e2d\u5b50&#xff0c;\u90a3\u4e48\u8fd9\u53ea\u9e1f\u5c31\u53ef\u4ee5\u88ab\u79f0\u4e3a\u9e2d\u5b50\u3002\u6620\u5c04\u5230 TypeScript \u4e2d&#xff1a;\u4e00\u4e2a\u5bf9\u8c61&#xff0c;\u53ea\u8981\u5b83\u62e5\u6709\u67d0\u4e2a\u7c7b\u578b\u6240\u8981\u6c42\u7684\u300c\u6240\u6709\u5c5e\u6027\u548c\u65b9\u6cd5\u300d&#xff0c;\u90a3\u4e48\u8fd9\u4e2a\u5bf9\u8c61\u5c31\u53ef\u4ee5\u88ab\u89c6\u4f5c\u8fd9\u4e2a\u7c7b\u578b&#xff0c;\u65e0\u8bba\u8fd9\u4e2a\u5bf9\u8c61\u672c\u8eab\u88ab\u58f0\u660e\u6210\u4ec0\u4e48\u7c7b\u578b\u3002<\/p>\n<p>\u2728 \u91cd\u8981\u5173\u8054&#xff1a;\u9e2d\u5b50\u7c7b\u578b\u662f\u300c\u7ed3\u6784\u5b50\u7c7b\u578b\u300d\u7684\u901a\u4fd7\u8868\u8fbe\u548c\u6838\u5fc3\u601d\u60f3&#xff0c;TypeScript \u7684\u7c7b\u578b\u517c\u5bb9\u6027\u89c4\u5219&#xff0c;\u672c\u8d28\u5c31\u662f\u9e2d\u5b50\u7c7b\u578b\u7684\u843d\u5730\u5b9e\u73b0\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001\u4e3a\u4ec0\u4e48\u9e2d\u5b50\u7c7b\u578b\u5bf9 TypeScript \u81f3\u5173\u91cd\u8981&#xff1f;&#xff08;\u6838\u5fc3\u4ef7\u503c&#xff0c;\u5fc5\u770b&#xff09;<\/h3>\n<p>\u9e2d\u5b50\u7c7b\u578b\u662f TypeScript \u7c7b\u578b\u7cfb\u7edf\u7684\u300c\u57fa\u77f3\u300d\u4e4b\u4e00&#xff0c;\u5b83\u7684\u91cd\u8981\u6027\u4f53\u73b0\u5728 5 \u4e2a\u6838\u5fc3\u7ef4\u5ea6&#xff0c;\u7f3a\u4e00\u4e0d\u53ef&#xff0c;\u4e5f\u662f TypeScript \u80fd\u517c\u987e\u300c\u7c7b\u578b\u5b89\u5168\u300d\u548c\u300c\u5f00\u53d1\u7075\u6d3b\u300d\u7684\u5173\u952e&#xff1a;<\/p>\n<h4>&#x1f31f; 1. \u5f7b\u5e95\u62b9\u5e73\u300c\u7c7b\u578b\u547d\u540d\u300d\u7684\u9650\u5236&#xff0c;\u5927\u5e45\u63d0\u5347\u7075\u6d3b\u6027<\/h4>\n<p>TypeScript \u4e0d\u4f1a\u56e0\u4e3a\u300c\u7c7b\u578b\u540d\u79f0\u4e0d\u540c\u300d\u5c31\u5224\u5b9a\u4e0d\u517c\u5bb9&#xff0c;\u53ea\u8981\u7ed3\u6784\u4e00\u81f4&#xff0c;\u5c31\u80fd\u65e0\u7f1d\u590d\u7528\u3002\u8fd9\u5b8c\u7f8e\u9002\u914d JavaScript \u5929\u751f\u7684\u300c\u65e0\u7c7b\u578b\u3001\u5f31\u7c7b\u578b\u300d\u7279\u6027&#xff0c;\u8ba9 TypeScript \u6210\u4e3a JS \u7684\u8d85\u96c6\u800c\u975e\u300c\u67b7\u9501\u300d\u3002<\/p>\n<p>typescript<\/p>\n<p>\u8fd0\u884c<\/p>\n<p>\/\/ \u6848\u4f8b&#xff1a;\u4e24\u4e2a\u4e0d\u540c\u540d\u5b57\u7684\u7c7b\u578b&#xff0c;\u7ed3\u6784\u4e00\u81f4&#xff0c;\u5b8c\u5168\u517c\u5bb9<br \/>\ntype Duck &#061; { name: string; quack(): void };<br \/>\ntype Goose &#061; { name: string; quack(): void };<\/p>\n<p>const duck: Duck &#061; { name: &#034;\u5510\u8001\u9e2d&#034;, quack: () &#061;&gt; console.log(&#034;\u560e\u560e\u560e&#034;) };<br \/>\nconst goose: Goose &#061; duck; \/\/ \u2705 \u5b8c\u5168\u517c\u5bb9&#xff0c;\u65e0\u62a5\u9519&#xff0c;\u56e0\u4e3a\u7ed3\u6784\u4e00\u81f4<\/p>\n<h4>&#x1f31f; 2. \u652f\u6301\u300c\u8d85\u96c6\u517c\u5bb9\u300d&#xff0c;\u5b9e\u73b0\u300c\u7c7b\u578b\u5bbd\u677e\u5339\u914d\u300d&#xff08;\u6700\u6838\u5fc3\u7684\u7c7b\u578b\u517c\u5bb9\u89c4\u5219&#xff09;<\/h4>\n<p>\u8fd9\u662f\u9e2d\u5b50\u7c7b\u578b\u6700\u6838\u5fc3\u7684\u4ef7\u503c&#xff0c;\u4e5f\u662f TypeScript \u7c7b\u578b\u517c\u5bb9\u7684\u6838\u5fc3\u903b\u8f91&#xff1a;<\/p>\n<p>\u5982\u679c\u4e00\u4e2a\u7c7b\u578b A \u62e5\u6709 \u76ee\u6807\u7c7b\u578b B \u6240\u8981\u6c42\u7684\u300c\u5168\u90e8\u5c5e\u6027\u548c\u65b9\u6cd5\u300d&#xff0c;\u90a3\u4e48 A \u53ef\u4ee5\u8d4b\u503c\u7ed9 B&#xff08;A \u662f B \u7684\u8d85\u96c6&#xff09;\u3002<\/p>\n<p>\u7b80\u5355\u8bf4&#xff1a;\u591a\u7684\u5c5e\u6027 \/ \u65b9\u6cd5\u4e0d\u5f71\u54cd\u517c\u5bb9\u6027&#xff0c;\u300c\u6ee1\u8db3\u5fc5\u8981\u6761\u4ef6\u300d\u5373\u53ef\u3002\u8fd9\u89e3\u51b3\u4e86\u5f00\u53d1\u4e2d\u300c\u5bf9\u8c61\u5c5e\u6027\u5197\u4f59\u300d\u7684\u75db\u70b9&#xff0c;\u4e0d\u7528\u4e3a\u4e86\u5339\u914d\u7c7b\u578b\u523b\u610f\u5220\u51cf\u5c5e\u6027\u3002<\/p>\n<p>typescript<\/p>\n<p>\u8fd0\u884c<\/p>\n<p>\/\/ \u6848\u4f8b&#xff1a;\u8d85\u96c6\u517c\u5bb9 &#8211; \u7ecf\u5178\u573a\u666f<br \/>\ntype User &#061; { name: string; age: number };<br \/>\n\/\/ Admin \u662f User \u7684\u8d85\u96c6&#xff1a;\u62e5\u6709 User \u7684\u6240\u6709\u5c5e\u6027 &#043; \u989d\u5916\u7684 role \u5c5e\u6027<br \/>\ntype Admin &#061; { name: string; age: number; role: string };<\/p>\n<p>const admin: Admin &#061; { name: &#034;\u5f20\u4e09&#034;, age: 28, role: &#034;\u7ba1\u7406\u5458&#034; };<br \/>\nconst user: User &#061; admin; \/\/ \u2705 \u5b8c\u5168\u517c\u5bb9&#xff0c;\u65e0\u62a5\u9519<\/p>\n<h4>&#x1f31f; 3. \u5b8c\u7f8e\u9002\u914d JavaScript \u7684\u300c\u52a8\u6001\u7279\u6027\u300d&#xff0c;\u65e0\u4fb5\u5165\u517c\u5bb9\u539f\u751f JS<\/h4>\n<p>JavaScript \u662f\u52a8\u6001\u8bed\u8a00&#xff0c;\u6211\u4eec\u7ecf\u5e38\u4f1a\u521b\u5efa\u300c\u4e34\u65f6\u5bf9\u8c61\u300d\u300c\u533f\u540d\u5bf9\u8c61\u300d\u76f4\u63a5\u4f20\u53c2 \/ \u8d4b\u503c&#xff0c;\u800c\u9e2d\u5b50\u7c7b\u578b\u5929\u7136\u652f\u6301\u8fd9\u79cd\u5199\u6cd5&#xff1a;\u533f\u540d\u5bf9\u8c61\u53ea\u8981\u7ed3\u6784\u5339\u914d&#xff0c;\u5c31\u80fd\u76f4\u63a5\u5f53\u4f5c\u76ee\u6807\u7c7b\u578b\u4f7f\u7528&#xff0c;\u65e0\u9700\u663e\u5f0f\u58f0\u660e\u7c7b\u578b&#xff0c;\u4e5f\u65e0\u9700\u624b\u52a8\u8f6c\u6362\u3002\u8fd9\u662f TypeScript \u5bf9 JS \u751f\u6001\u300c\u96f6\u4fb5\u5165\u300d\u7684\u5173\u952e&#xff0c;\u4e5f\u662f\u5927\u5bb6\u89c9\u5f97 TS \u4e0a\u624b\u53cb\u597d\u7684\u6838\u5fc3\u539f\u56e0\u4e4b\u4e00\u3002<\/p>\n<p>typescript<\/p>\n<p>\u8fd0\u884c<\/p>\n<p>\/\/ \u6848\u4f8b&#xff1a;\u533f\u540d\u5bf9\u8c61\u76f4\u63a5\u8d4b\u503c\u7ed9\u7c7b\u578b\u53d8\u91cf&#xff0c;\u65e0\u9700\u663e\u5f0f\u58f0\u660e<br \/>\ntype Person &#061; { id: number; name: string };<\/p>\n<p>\/\/ \u533f\u540d\u5bf9\u8c61\u7ed3\u6784\u5339\u914d Person&#xff0c;\u76f4\u63a5\u8d4b\u503c \u2705<br \/>\nconst p1: Person &#061; { id: 1, name: &#034;\u674e\u56db&#034; };<\/p>\n<p>\/\/ \u51fd\u6570\u53c2\u6570\u4e5f\u662f\u540c\u7406&#xff0c;\u533f\u540d\u5bf9\u8c61\u76f4\u63a5\u4f20\u53c2 \u2705<br \/>\nfunction printPerson(p: Person) { console.log(p.name) }<br \/>\nprintPerson({ id: 2, name: &#034;\u738b\u4e94&#034; });<\/p>\n<h4>&#x1f31f; 4. \u6781\u5927\u964d\u4f4e\u300c\u5197\u4f59\u4ee3\u7801\u300d&#xff0c;\u5b9e\u73b0\u66f4\u4f18\u96c5\u7684\u62bd\u8c61\u548c\u89e3\u8026<\/h4>\n<p>\u5982\u679c\u6ca1\u6709\u9e2d\u5b50\u7c7b\u578b&#xff08;\u7528\u540d\u4e49\u7c7b\u578b&#xff09;&#xff0c;\u6211\u4eec\u9700\u8981\u9891\u7e41\u505a\u300c\u7c7b\u578b\u8f6c\u6362\u300d\u300c\u7ee7\u627f\u58f0\u660e\u300d\u624d\u80fd\u590d\u7528\u903b\u8f91&#xff0c;\u4ee3\u7801\u4f1a\u53d8\u5f97\u81c3\u80bf\u4e14\u8026\u5408\u5ea6\u9ad8\u3002\u800c\u9e2d\u5b50\u7c7b\u578b\u8ba9\u6211\u4eec\u53ea\u5173\u6ce8\u300c\u5bf9\u8c61\u80fd\u505a\u4ec0\u4e48&#xff08;\u6709\u4ec0\u4e48\u5c5e\u6027 \/ \u65b9\u6cd5&#xff09;\u300d&#xff0c;\u800c\u4e0d\u662f\u300c\u5bf9\u8c61\u662f\u4ec0\u4e48\u7c7b\u578b\u300d&#xff0c;\u8fd9\u79cd\u57fa\u4e8e\u884c\u4e3a\u7684\u62bd\u8c61&#xff0c;\u80fd\u8ba9\u4ee3\u7801\u89e3\u8026\u3001\u66f4\u7b80\u6d01&#xff0c;\u590d\u7528\u6027\u66f4\u5f3a\u3002<\/p>\n<p>typescript<\/p>\n<p>\u8fd0\u884c<\/p>\n<p>\/\/ \u6848\u4f8b&#xff1a;\u57fa\u4e8e\u884c\u4e3a\u7684\u62bd\u8c61&#xff0c;\u65e0\u9700\u7ee7\u627f&#xff0c;\u53ea\u8981\u6709 fly \u65b9\u6cd5\u5c31\u53ef\u4ee5\u98de<br \/>\ntype Flyable &#061; { fly(): void };<\/p>\n<p>class Bird { fly() { console.log(&#034;\u9e1f\u98de&#034;) } }<br \/>\nclass Plane { fly() { console.log(&#034;\u98de\u673a\u98de&#034;) } }<br \/>\nclass Superman { fly() { console.log(&#034;\u8d85\u4eba\u98de&#034;) } }<\/p>\n<p>\/\/ \u4e00\u4e2a\u51fd\u6570&#xff0c;\u53ea\u8981\u53c2\u6570\u6ee1\u8db3 Flyable \u7ed3\u6784&#xff0c;\u5c31\u80fd\u6267\u884c<br \/>\nfunction letItFly(item: Flyable) { item.fly() }<\/p>\n<p>letItFly(new Bird()); \/\/ \u2705<br \/>\nletItFly(new Plane()); \/\/ \u2705<br \/>\nletItFly(new Superman()); \/\/ \u2705<\/p>\n<p>\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d&#xff0c;Bird\/Plane\/Superman \u6ca1\u6709\u4efb\u4f55\u7ee7\u627f\u5173\u7cfb&#xff0c;\u53ea\u662f\u62e5\u6709\u76f8\u540c\u7684 fly \u65b9\u6cd5&#xff0c;\u5c31\u80fd\u88ab\u540c\u4e00\u4e2a\u51fd\u6570\u5904\u7406 \u2014\u2014 \u8fd9\u5c31\u662f\u9e2d\u5b50\u7c7b\u578b\u5e26\u6765\u7684\u300c\u4f18\u96c5\u89e3\u8026\u300d\u3002<\/p>\n<h4>&#x1f31f; 5. \u517c\u987e\u300c\u7c7b\u578b\u5b89\u5168\u300d\u4e0e\u300c\u5f00\u53d1\u6548\u7387\u300d&#xff0c;\u9c7c\u548c\u718a\u638c\u517c\u5f97<\/h4>\n<p>\u5f88\u591a\u4eba\u62c5\u5fc3&#xff1a;\u9e2d\u5b50\u7c7b\u578b\u8fd9\u4e48\u7075\u6d3b&#xff0c;\u4f1a\u4e0d\u4f1a\u4e22\u5931\u7c7b\u578b\u5b89\u5168&#xff1f;\u7b54\u6848\u662f\u4e0d\u4f1a\u3002TypeScript \u7684\u9e2d\u5b50\u7c7b\u578b\u662f\u300c\u5e26\u7c7b\u578b\u6821\u9a8c\u7684\u7075\u6d3b\u300d&#xff1a;\u5b83\u5141\u8bb8\u4f60\u7075\u6d3b\u7684\u8d4b\u503c\u3001\u4f20\u53c2\u3001\u62bd\u8c61&#xff0c;\u4f46\u53ea\u8981\u4f60\u7f3a\u5c11\u76ee\u6807\u7c7b\u578b\u7684\u300c\u5fc5\u8981\u5c5e\u6027 \/ \u65b9\u6cd5\u300d&#xff0c;\u5c31\u4f1a\u7acb\u523b\u629b\u51fa\u7f16\u8bd1\u9519\u8bef&#xff0c;\u4e25\u683c\u4fdd\u969c\u7c7b\u578b\u5b89\u5168\u3002<\/p>\n<p>typescript<\/p>\n<p>\u8fd0\u884c<\/p>\n<p>\/\/ \u6848\u4f8b&#xff1a;\u7f3a\u5c11\u5fc5\u8981\u5c5e\u6027&#xff0c;\u7acb\u523b\u62a5\u9519 \u274c \u4fdd\u969c\u7c7b\u578b\u5b89\u5168<br \/>\ntype Student &#061; { id: number; name: string; grade: string };<\/p>\n<p>\/\/ \u274c \u62a5\u9519&#xff1a;Property &#039;grade&#039; is missing in type &#8230;<br \/>\nconst s1: Student &#061; { id: 100, name: &#034;\u8d75\u516d&#034; };<\/p>\n<p>\/\/ \u274c \u62a5\u9519&#xff1a;Argument of type &#8230; is missing the following property: grade<br \/>\nfunction printStudent(s: Student) {}<br \/>\nprintStudent({ id: 101, name: &#034;\u94b1\u4e03&#034; });<\/p>\n<p>\u2705 \u7ed3\u8bba&#xff1a;\u9e2d\u5b50\u7c7b\u578b\u7684\u300c\u7075\u6d3b\u300d&#xff0c;\u662f\u5728\u7c7b\u578b\u5b89\u5168\u524d\u63d0\u4e0b\u7684\u7075\u6d3b \u2014\u2014 \u65e2\u4e0d\u4f1a\u50cf\u7eaf JS \u90a3\u6837\u65e0\u7ea6\u675f&#xff0c;\u4e5f\u4e0d\u4f1a\u50cf\u540d\u4e49\u7c7b\u578b\u90a3\u6837\u6b7b\u677f&#xff0c;\u5b8c\u7f8e\u5e73\u8861\u4e86\u300c\u5b89\u5168\u300d\u548c\u300c\u6548\u7387\u300d\u3002<\/p>\n<hr \/>\n<h3>\u4e09\u3001\u9e2d\u5b50\u7c7b\u578b\u7684\u300c\u7279\u6b8a\u6ce8\u610f\u4e8b\u9879\u300d&#xff1a;\u4e24\u4e2a\u5bb9\u6613\u8e29\u5751\u7684\u8fb9\u754c\u89c4\u5219<\/h3>\n<p>\u9e2d\u5b50\u7c7b\u578b\u7684\u6838\u5fc3\u89c4\u5219\u5f88\u7b80\u5355&#xff0c;\u4f46\u6709\u4e24\u4e2a\u7279\u6b8a\u573a\u666f\u7684\u884c\u4e3a\u9700\u8981\u7262\u8bb0&#xff0c;\u907f\u514d\u5f00\u53d1\u4e2d\u8e29\u5751&#xff0c;\u8fd9\u4e5f\u662f TypeScript \u7c7b\u578b\u517c\u5bb9\u6027\u7684\u300c\u8fb9\u754c\u7ec6\u8282\u300d&#xff1a;<\/p>\n<h4>\u26a0\ufe0f \u6ce8\u610f 1&#xff1a;\u5bf9\u8c61\u5b57\u9762\u91cf\u7684\u300c\u65b0\u9c9c\u5ea6\u68c0\u67e5\u300d(Freshness Check)<\/h4>\n<p>\u8fd9\u662f\u6700\u5bb9\u6613\u8e29\u5751\u7684\u70b9&#xff1a;\u76f4\u63a5\u4f20\u5165\u7684\u300c\u5bf9\u8c61\u5b57\u9762\u91cf\u300d\u4f1a\u88ab\u505a\u4e25\u683c\u6821\u9a8c&#xff0c;\u4e0d\u5141\u8bb8\u6709\u300c\u591a\u4f59\u5c5e\u6027\u300d&#xff0c;\u4f46\u300c\u53d8\u91cf\u8d4b\u503c\u540e\u7684\u5bf9\u8c61\u300d\u5219\u4e0d\u4f1a\u3002\u8fd9\u548c\u6211\u4eec\u524d\u9762\u8bb2\u7684\u300c\u8d85\u96c6\u517c\u5bb9\u300d\u770b\u4f3c\u77db\u76fe&#xff0c;\u5b9e\u5219\u662f TypeScript \u7684\u4fdd\u62a4\u673a\u5236&#xff1a;\u9632\u6b62\u4f60\u4e0d\u5c0f\u5fc3\u5199\u9519\u5c5e\u6027\u540d&#xff08;\u6bd4\u5982\u628a name \u5199\u6210 naem&#xff09;\u3002<\/p>\n<p>typescript<\/p>\n<p>\u8fd0\u884c<\/p>\n<p>type Car &#061; { brand: string; price: number };<\/p>\n<p>\/\/ \u2705 \u53d8\u91cf\u8d4b\u503c\u7684\u5bf9\u8c61&#xff0c;\u5141\u8bb8\u6709\u591a\u4f59\u5c5e\u6027&#xff08;\u8d85\u96c6\u517c\u5bb9&#xff09;<br \/>\nconst myCar &#061; { brand: &#034;\u7279\u65af\u62c9&#034;, price: 30, color: &#034;\u767d\u8272&#034; };<br \/>\nconst car1: Car &#061; myCar;<\/p>\n<p>\/\/ \u274c \u76f4\u63a5\u4f20\u5165\u7684\u5bf9\u8c61\u5b57\u9762\u91cf&#xff0c;\u4e25\u683c\u6821\u9a8c&#xff0c;\u591a\u4f59\u5c5e\u6027\u62a5\u9519<br \/>\nconst car2: Car &#061; { brand: &#034;\u6bd4\u4e9a\u8fea&#034;, price: 20, color: &#034;\u7070\u8272&#034; };<br \/>\n\/\/ \u9519\u8bef\u63d0\u793a&#xff1a;Object literal may only specify known properties&#8230;<\/p>\n<p>\/\/ \u274c \u51fd\u6570\u53c2\u6570\u7684\u5bf9\u8c61\u5b57\u9762\u91cf&#xff0c;\u540c\u6837\u4e25\u683c\u6821\u9a8c<br \/>\nfunction showCar(c: Car) {}<br \/>\nshowCar({ brand: &#034;\u5b9d\u9a6c&#034;, price: 50, color: &#034;\u9ed1\u8272&#034; }); \/\/ \u62a5\u9519<\/p>\n<p>\u2705 \u89e3\u51b3\u65b9\u6848&#xff1a;\u5982\u679c\u786e\u5b9e\u9700\u8981\u4f20\u591a\u4f59\u5c5e\u6027&#xff0c;\u5148\u8d4b\u503c\u7ed9\u53d8\u91cf\u518d\u4f20\u53c2\u5373\u53ef&#xff0c;\u5982\u4e0a\u9762\u7684 myCar \u6848\u4f8b\u3002<\/p>\n<h4>\u26a0\ufe0f \u6ce8\u610f 2&#xff1a;\u51fd\u6570\u7684\u7c7b\u578b\u517c\u5bb9\u6027\u662f\u300c\u9006\u53d8 &#043; \u534f\u53d8\u300d\u7684\u7279\u6b8a\u89c4\u5219<\/h4>\n<p>\u9e2d\u5b50\u7c7b\u578b\u5bf9\u300c\u5bf9\u8c61 \/ \u63a5\u53e3\u300d\u7684\u517c\u5bb9\u89c4\u5219\u5f88\u7b80\u5355&#xff08;\u8d85\u96c6\u517c\u5bb9&#xff09;&#xff0c;\u4f46\u5bf9\u300c\u51fd\u6570\u300d\u7684\u517c\u5bb9\u89c4\u5219\u6709\u5dee\u5f02&#xff0c;\u6838\u5fc3\u603b\u7ed3&#xff1a;<\/p>\n<li>\u51fd\u6570\u7684\u53c2\u6570\u7c7b\u578b&#xff1a;\u9075\u5faa\u300c\u9006\u53d8\u300d\u2192 \u76ee\u6807\u51fd\u6570\u7684\u53c2\u6570\u7c7b\u578b&#xff0c;\u53ef\u4ee5\u662f\u300c\u6e90\u51fd\u6570\u53c2\u6570\u7c7b\u578b\u7684\u7236\u7c7b\u578b\u300d&#xff08;\u66f4\u5bbd\u6cdb&#xff09;&#xff1b;<\/li>\n<li>\u51fd\u6570\u7684\u8fd4\u56de\u503c\u7c7b\u578b&#xff1a;\u9075\u5faa\u300c\u534f\u53d8\u300d\u2192 \u6e90\u51fd\u6570\u7684\u8fd4\u56de\u503c\u7c7b\u578b&#xff0c;\u53ef\u4ee5\u662f\u300c\u76ee\u6807\u51fd\u6570\u8fd4\u56de\u503c\u7c7b\u578b\u7684\u5b50\u7c7b\u578b\u300d&#xff08;\u66f4\u5177\u4f53&#xff09;&#xff1b;<\/li>\n<li>\u7b80\u5316\u8bb0\u5fc6&#xff1a;\u53c2\u6570\u53ef\u4ee5\u66f4\u677e&#xff0c;\u8fd4\u56de\u503c\u53ef\u4ee5\u66f4\u4e25\u3002<\/li>\n<p>typescript<\/p>\n<p>\u8fd0\u884c<\/p>\n<p>\/\/ \u6848\u4f8b&#xff1a;\u51fd\u6570\u517c\u5bb9\u6027<br \/>\ntype Animal &#061; { name: string };<br \/>\ntype Dog &#061; { name: string; bark(): void }; \/\/ Dog \u662f Animal \u7684\u5b50\u7c7b\u578b<\/p>\n<p>\/\/ \u6e90\u51fd\u6570&#xff1a;\u53c2\u6570\u66f4\u4e25&#xff08;Dog&#xff09;&#xff0c;\u8fd4\u56de\u503c\u66f4\u5177\u4f53&#xff08;Dog&#xff09;<br \/>\nconst fn1 &#061; (d: Dog): Dog &#061;&gt; ({ name: &#034;\u65fa\u8d22&#034;, bark: () &#061;&gt; {} });<br \/>\n\/\/ \u76ee\u6807\u51fd\u6570&#xff1a;\u53c2\u6570\u66f4\u677e&#xff08;Animal&#xff09;&#xff0c;\u8fd4\u56de\u503c\u66f4\u5bbd\u6cdb&#xff08;Animal&#xff09;<br \/>\nconst fn2: (a: Animal) &#061;&gt; Animal &#061; fn1; \/\/ \u2705 \u5b8c\u5168\u517c\u5bb9<\/p>\n<hr \/>\n<h3>\u603b\u7ed3&#xff08;\u6838\u5fc3\u77e5\u8bc6\u70b9\u901f\u8bb0&#xff0c;\u5fc5\u80cc&#xff09;<\/h3>\n<li>TypeScript \u7684\u7c7b\u578b\u517c\u5bb9\u6027\u57fa\u4e8e \u7ed3\u6784\u5b50\u7c7b\u578b&#xff0c;\u9e2d\u5b50\u7c7b\u578b\u662f\u5b83\u7684\u901a\u4fd7\u8868\u8fbe&#xff0c;\u6838\u5fc3\u601d\u60f3&#xff1a;\u50cf\u9e2d\u5b50\u5c31\u662f\u9e2d\u5b50&#xff1b;<\/li>\n<li>\u9e2d\u5b50\u7c7b\u578b\u7684\u6838\u5fc3\u89c4\u5219&#xff1a;\u53ea\u8981\u62e5\u6709\u76ee\u6807\u7c7b\u578b\u7684\u5168\u90e8\u5fc5\u8981\u5c5e\u6027 \/ \u65b9\u6cd5&#xff0c;\u5c31\u517c\u5bb9&#xff0c;\u5141\u8bb8\u6709\u591a\u4f59\u5c5e\u6027&#xff1b;<\/li>\n<li>\u9e2d\u5b50\u7c7b\u578b\u7684 5 \u4e2a\u6838\u5fc3\u4ef7\u503c&#xff08;\u91cd\u8981\u6027&#xff09;&#xff1a;\u2705 \u62b9\u5e73\u7c7b\u578b\u547d\u540d\u9650\u5236&#xff0c;\u63d0\u5347\u7075\u6d3b\u6027&#xff1b;\u2705 \u652f\u6301\u8d85\u96c6\u517c\u5bb9&#xff0c;\u5bbd\u677e\u5339\u914d&#xff1b;\u2705 \u539f\u751f\u517c\u5bb9 JS \u52a8\u6001\u7279\u6027&#xff0c;\u96f6\u4fb5\u5165&#xff1b;\u2705 \u964d\u4f4e\u5197\u4f59\u4ee3\u7801&#xff0c;\u4f18\u96c5\u89e3\u8026&#xff1b;\u2705 \u517c\u987e\u7c7b\u578b\u5b89\u5168\u4e0e\u5f00\u53d1\u6548\u7387&#xff1b;<\/li>\n<li>\u4e24\u4e2a\u5fc5\u8bb0\u6ce8\u610f\u4e8b\u9879&#xff1a;\u2705 \u5bf9\u8c61\u5b57\u9762\u91cf\u6709\u300c\u65b0\u9c9c\u5ea6\u68c0\u67e5\u300d&#xff0c;\u7981\u6b62\u591a\u4f59\u5c5e\u6027&#xff1b;\u2705 \u51fd\u6570\u517c\u5bb9\u6027\u662f\u300c\u53c2\u6570\u9006\u53d8\u3001\u8fd4\u56de\u503c\u534f\u53d8\u300d\u3002<\/li>\n<p>\u9e2d\u5b50\u7c7b\u578b\u662f TypeScript \u6700\u6838\u5fc3\u7684\u8bbe\u8ba1\u7406\u5ff5\u4e4b\u4e00&#xff0c;\u7406\u89e3\u5b83&#xff0c;\u4f60\u5c31\u80fd\u5f7b\u5e95\u641e\u61c2 TypeScript \u7684\u7c7b\u578b\u517c\u5bb9\u89c4\u5219&#xff0c;\u544a\u522b\u5927\u90e8\u5206\u300c\u7c7b\u578b\u62a5\u9519\u641e\u4e0d\u61c2\u300d\u7684\u95ee\u9898 \u2714\ufe0f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f60\u60f3\u641e\u61c2 TypeScript \u4e2d\u9e2d\u5b50\u7c7b\u578b\u7684\u6838\u5fc3\u4ef7\u503c\u3001\u5b83\u548c TypeScript \u7c7b\u578b\u517c\u5bb9\u6027\u7684\u5f3a\u5173\u8054&#xff0c;\u4ee5\u53ca\u80cc\u540e\u7684\u5e95\u5c42\u903b\u8f91&#xff0c;\u8fd9\u7bc7\u5185\u5bb9\u4f1a\u628a\u300c\u662f\u4ec0\u4e48\u3001\u4e3a\u4ec0\u4e48\u91cd\u8981\u3001\u600e\u4e48\u7528\u3001\u6ce8\u610f\u4e8b\u9879\u300d\u8bb2\u900f&#xff0c;\u5185\u5bb9\u5b8c\u6574\u4e14\u8d34\u5408\u5b9e\u6218\u3002\u4e00\u3001\u5148\u660e\u786e\u6838\u5fc3\u5b9a\u4e49\u2705 TypeScript \u7684\u7c7b\u578b\u517c\u5bb9\u6027\u6838\u5fc3\u89c4\u5219TypeScript \u662f\u57fa\u4e8e\u300c\u7ed3\u6784\u5b50\u7c7b\u578b\u300d(Structural Subtyping) \u7684\u7c7b\u578b\u7cfb\u7edf&#xff0c;\u4e0d\u662f\u57fa\u4e8e\u300c\u540d\u4e49\u7c7b\u578b\u300d(Nominal Typing)\u3002\u540d\u4e49\u7c7b<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[568],"topic":[],"class_list":["post-61824","post","type-post","status-publish","format-standard","hentry","category-server","tag-typescript"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>TypeScript \u7c7b\u578b\u517c\u5bb9\u6027\uff1a\u4e3a\u4ec0\u4e48\u9e2d\u5b50\u7c7b\u578b\uff08Duck Typing\uff09\u5982\u6b64\u91cd\u8981 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/61824.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"TypeScript \u7c7b\u578b\u517c\u5bb9\u6027\uff1a\u4e3a\u4ec0\u4e48\u9e2d\u5b50\u7c7b\u578b\uff08Duck Typing\uff09\u5982\u6b64\u91cd\u8981 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4f60\u60f3\u641e\u61c2 TypeScript \u4e2d\u9e2d\u5b50\u7c7b\u578b\u7684\u6838\u5fc3\u4ef7\u503c\u3001\u5b83\u548c TypeScript \u7c7b\u578b\u517c\u5bb9\u6027\u7684\u5f3a\u5173\u8054&#xff0c;\u4ee5\u53ca\u80cc\u540e\u7684\u5e95\u5c42\u903b\u8f91&#xff0c;\u8fd9\u7bc7\u5185\u5bb9\u4f1a\u628a\u300c\u662f\u4ec0\u4e48\u3001\u4e3a\u4ec0\u4e48\u91cd\u8981\u3001\u600e\u4e48\u7528\u3001\u6ce8\u610f\u4e8b\u9879\u300d\u8bb2\u900f&#xff0c;\u5185\u5bb9\u5b8c\u6574\u4e14\u8d34\u5408\u5b9e\u6218\u3002\u4e00\u3001\u5148\u660e\u786e\u6838\u5fc3\u5b9a\u4e49\u2705 TypeScript \u7684\u7c7b\u578b\u517c\u5bb9\u6027\u6838\u5fc3\u89c4\u5219TypeScript \u662f\u57fa\u4e8e\u300c\u7ed3\u6784\u5b50\u7c7b\u578b\u300d(Structural Subtyping) \u7684\u7c7b\u578b\u7cfb\u7edf&#xff0c;\u4e0d\u662f\u57fa\u4e8e\u300c\u540d\u4e49\u7c7b\u578b\u300d(Nominal Typing)\u3002\u540d\u4e49\u7c7b\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/61824.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-18T09:49:39+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/61824.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/61824.html\",\"name\":\"TypeScript \u7c7b\u578b\u517c\u5bb9\u6027\uff1a\u4e3a\u4ec0\u4e48\u9e2d\u5b50\u7c7b\u578b\uff08Duck Typing\uff09\u5982\u6b64\u91cd\u8981 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-18T09:49:39+00:00\",\"dateModified\":\"2026-01-18T09:49:39+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/61824.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/61824.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/61824.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"TypeScript \u7c7b\u578b\u517c\u5bb9\u6027\uff1a\u4e3a\u4ec0\u4e48\u9e2d\u5b50\u7c7b\u578b\uff08Duck Typing\uff09\u5982\u6b64\u91cd\u8981\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"TypeScript \u7c7b\u578b\u517c\u5bb9\u6027\uff1a\u4e3a\u4ec0\u4e48\u9e2d\u5b50\u7c7b\u578b\uff08Duck Typing\uff09\u5982\u6b64\u91cd\u8981 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/61824.html","og_locale":"zh_CN","og_type":"article","og_title":"TypeScript \u7c7b\u578b\u517c\u5bb9\u6027\uff1a\u4e3a\u4ec0\u4e48\u9e2d\u5b50\u7c7b\u578b\uff08Duck Typing\uff09\u5982\u6b64\u91cd\u8981 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4f60\u60f3\u641e\u61c2 TypeScript \u4e2d\u9e2d\u5b50\u7c7b\u578b\u7684\u6838\u5fc3\u4ef7\u503c\u3001\u5b83\u548c TypeScript \u7c7b\u578b\u517c\u5bb9\u6027\u7684\u5f3a\u5173\u8054&#xff0c;\u4ee5\u53ca\u80cc\u540e\u7684\u5e95\u5c42\u903b\u8f91&#xff0c;\u8fd9\u7bc7\u5185\u5bb9\u4f1a\u628a\u300c\u662f\u4ec0\u4e48\u3001\u4e3a\u4ec0\u4e48\u91cd\u8981\u3001\u600e\u4e48\u7528\u3001\u6ce8\u610f\u4e8b\u9879\u300d\u8bb2\u900f&#xff0c;\u5185\u5bb9\u5b8c\u6574\u4e14\u8d34\u5408\u5b9e\u6218\u3002\u4e00\u3001\u5148\u660e\u786e\u6838\u5fc3\u5b9a\u4e49\u2705 TypeScript \u7684\u7c7b\u578b\u517c\u5bb9\u6027\u6838\u5fc3\u89c4\u5219TypeScript \u662f\u57fa\u4e8e\u300c\u7ed3\u6784\u5b50\u7c7b\u578b\u300d(Structural Subtyping) \u7684\u7c7b\u578b\u7cfb\u7edf&#xff0c;\u4e0d\u662f\u57fa\u4e8e\u300c\u540d\u4e49\u7c7b\u578b\u300d(Nominal Typing)\u3002\u540d\u4e49\u7c7b","og_url":"https:\/\/www.wsisp.com\/helps\/61824.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-18T09:49:39+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/61824.html","url":"https:\/\/www.wsisp.com\/helps\/61824.html","name":"TypeScript \u7c7b\u578b\u517c\u5bb9\u6027\uff1a\u4e3a\u4ec0\u4e48\u9e2d\u5b50\u7c7b\u578b\uff08Duck Typing\uff09\u5982\u6b64\u91cd\u8981 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-18T09:49:39+00:00","dateModified":"2026-01-18T09:49:39+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/61824.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/61824.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/61824.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"TypeScript \u7c7b\u578b\u517c\u5bb9\u6027\uff1a\u4e3a\u4ec0\u4e48\u9e2d\u5b50\u7c7b\u578b\uff08Duck Typing\uff09\u5982\u6b64\u91cd\u8981"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/61824","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=61824"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/61824\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=61824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=61824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=61824"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=61824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}