{"id":4928,"date":"2023-01-05T11:20:32","date_gmt":"2023-01-05T03:20:32","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=4928"},"modified":"2023-01-05T11:20:32","modified_gmt":"2023-01-05T03:20:32","slug":"%e6%b7%b1%e5%85%a5%e6%8e%a2%e8%a8%8etypescript%e4%b8%ad%e7%9a%84%e7%b1%bb%e5%9e%8b%e5%88%ab%e5%90%8d%e8%88%87%e6%8e%a5%e5%8f%a3","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/typescript\/%e6%b7%b1%e5%85%a5%e6%8e%a2%e8%a8%8etypescript%e4%b8%ad%e7%9a%84%e7%b1%bb%e5%9e%8b%e5%88%ab%e5%90%8d%e8%88%87%e6%8e%a5%e5%8f%a3\/","title":{"rendered":"\u6df1\u5165\u63a2\u8a0eTypeScript\u4e2d\u7684\u7c7b\u578b\u522b\u540d\u8207\u63a5\u53e3"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"TypeScript, \u7c7b\u578b\u522b\u540d, \u63a5\u53e3, interfaces\"><\/p>\n<h1>TypeScript \u7c7b\u578b\u522b\u540d(type alias)\u4e0e\u63a5\u53e3(interfaces)\u7684\u533a\u522b<\/h1>\n<p>TypeScript \u662f\u4e00\u7a2e\u5f37\u578b\u5225\u7684 JavaScript \u8a9e\u8a00\uff0c\u5b83\u63d0\u4f9b\u4e86\u5169\u7a2e\u5b9a\u7fa9\u8cc7\u6599\u578b\u5225\u7684\u65b9\u5f0f\uff1a\u7c7b\u578b\u522b\u540d(type alias)\u548c\u63a5\u53e3(interfaces)\u3002\u96d6\u7136\u5b83\u5011\u90fd\u53ef\u4ee5\u7528\u4f86\u5b9a\u7fa9\u8cc7\u6599\u578b\u5225\uff0c\u4f46\u5b83\u5011\u4e4b\u9593\u4ecd\u6709\u8457\u4e00\u4e9b\u91cd\u8981\u7684\u5340\u5225\u3002<\/p>\n<h2>\u7c7b\u578b\u522b\u540d(type alias)<\/h2>\n<p>\u7c7b\u578b\u522b\u540d(type alias)\u662f\u4e00\u7a2e\u5b9a\u7fa9\u8cc7\u6599\u578b\u5225\u7684\u65b9\u5f0f\uff0c\u5b83\u53ef\u4ee5\u7528\u4f86\u5b9a\u7fa9\u4e00\u500b\u65b0\u7684\u8cc7\u6599\u578b\u5225\uff0c\u4e26\u5c07\u5176\u8207\u4e00\u500b\u5df2\u7d93\u5b58\u5728\u7684\u8cc7\u6599\u578b\u5225\u76f8\u95dc\u806f\u3002\u5b83\u53ef\u4ee5\u7528\u4f86\u5b9a\u7fa9\u8907\u96dc\u7684\u8cc7\u6599\u578b\u5225\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre class=\"brush: typescript\">\ntype Person = {\n  name: string;\n  age: number;\n  address: string;\n};\n<\/pre>\n<p>\u4e0a\u9762\u7684\u7a0b\u5f0f\u78bc\u5b9a\u7fa9\u4e86\u4e00\u500b\u65b0\u7684\u8cc7\u6599\u578b\u5225 Person\uff0c\u5b83\u662f\u4e00\u500b\u5305\u542b name\u3001age \u548c address \u7684\u7269\u4ef6\u3002<\/p>\n<h2>\u63a5\u53e3(interfaces)<\/h2>\n<p>\u63a5\u53e3(interfaces)\u4e5f\u662f\u4e00\u7a2e\u5b9a\u7fa9\u8cc7\u6599\u578b\u5225\u7684\u65b9\u5f0f\uff0c\u5b83\u53ef\u4ee5\u7528\u4f86\u5b9a\u7fa9\u4e00\u500b\u65b0\u7684\u8cc7\u6599\u578b\u5225\uff0c\u4e26\u5c07\u5176\u8207\u4e00\u500b\u5df2\u7d93\u5b58\u5728\u7684\u8cc7\u6599\u578b\u5225\u76f8\u95dc\u806f\u3002\u5b83\u53ef\u4ee5\u7528\u4f86\u5b9a\u7fa9\u8907\u96dc\u7684\u8cc7\u6599\u578b\u5225\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre class=\"brush: typescript\">\ninterface Person {\n  name: string;\n  age: number;\n  address: string;\n}\n<\/pre>\n<p>\u4e0a\u9762\u7684\u7a0b\u5f0f\u78bc\u5b9a\u7fa9\u4e86\u4e00\u500b\u65b0\u7684\u8cc7\u6599\u578b\u5225 Person\uff0c\u5b83\u662f\u4e00\u500b\u5305\u542b name\u3001age \u548c address \u7684\u7269\u4ef6\u3002<\/p>\n<h2>\u7c7b\u578b\u522b\u540d(type alias)\u8207\u63a5\u53e3(interfaces)\u7684\u5340\u5225<\/h2>\n<p>\u96d6\u7136\u7c7b\u578b\u522b\u540d(type alias)\u548c\u63a5\u53e3(interfaces)\u90fd\u53ef\u4ee5\u7528\u4f86\u5b9a\u7fa9\u8cc7\u6599\u578b\u5225\uff0c\u4f46\u5b83\u5011\u4e4b\u9593\u4ecd\u6709\u8457\u4e00\u4e9b\u91cd\u8981\u7684\u5340\u5225\uff1a<\/p>\n<ul>\n<li><strong>\u7c7b\u578b\u522b\u540d(type alias)\u53ef\u4ee5\u7528\u4f86\u5b9a\u7fa9\u8907\u96dc\u7684\u8cc7\u6599\u578b\u5225\uff0c\u800c\u63a5\u53e3(interfaces)\u53ea\u80fd\u7528\u4f86\u5b9a\u7fa9\u7269\u4ef6\u578b\u5225\u3002<\/strong><\/li>\n<li><strong>\u7c7b\u578b\u522b\u540d(type alias)\u53ef\u4ee5\u7528\u4f86\u5b9a\u7fa9\u51fd\u6578\u578b\u5225\uff0c\u800c\u63a5\u53e3(interfaces)\u4e0d\u80fd\u7528\u4f86\u5b9a\u7fa9\u51fd\u6578\u578b\u5225\u3002<\/strong><\/li>\n<li><strong>\u7c7b\u578b\u522b\u540d(type alias)\u53ef\u4ee5\u7528\u4f86\u5b9a\u7fa9\u57fa\u672c\u578b\u5225\uff0c\u800c\u63a5\u53e3(interfaces)\u4e0d\u80fd\u7528\u4f86\u5b9a\u7fa9\u57fa\u672c\u578b\u5225\u3002<\/strong><\/li>\n<\/ul>\n<p><!--more--><\/p>\n<p>\u7e3d\u7d50\u4f86\u8aaa\uff0c\u7c7b\u578b\u522b\u540d(type alias)\u548c\u63a5\u53e3(interfaces)\u90fd\u53ef\u4ee5\u7528\u4f86\u5b9a\u7fa9\u8cc7\u6599\u578b\u5225\uff0c\u4f46\u5b83\u5011\u4e4b\u9593\u4ecd\u6709\u8457\u4e00\u4e9b\u91cd\u8981\u7684\u5340\u5225\u3002\u56e0\u6b64\uff0c\u5728\u4f7f\u7528 TypeScript \u6642\uff0c\u6211\u5011\u61c9\u8a72\u6839\u64da\u6211\u5011\u7684\u9700\u6c42\u4f86\u9078\u64c7\u5408\u9069\u7684\u5b9a\u7fa9\u8cc7\u6599\u578b\u5225\u7684\u65b9\u5f0f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981\uff1aTypeScript\u4e2d\u7684\u7c7b\u578b\u522b\u540d\u8207\u63a5\u53e3\u6709\u8457\u4e0d\u540c\u7684\u529f\u80fd\uff0c\u7c7b\u578b\u522b\u540d\u53ef\u4ee5\u7528\u4f86\u5b9a\u7fa9\u4e00\u500b\u65b0\u7684\u540d\u7a31\uff0c\u800c\u63a5\u53e3\u5247\u53ef\u4ee5\u7528\u4f86\u5b9a\u7fa9\u4e00\u500b\u7269\u4ef6\u7684\u7d50\u69cb\uff0c\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0eTypeScript\u4e2d\u7684\u7c7b\u578b\u522b\u540d\u8207\u63a5\u53e3\u7684\u529f\u80fd\u8207\u5340\u5225\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[187],"tags":[186],"class_list":["post-4928","post","type-post","status-publish","format-standard","hentry","category-typescript","tag-typescript"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pcFK27-1hu","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/comments?post=4928"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4928\/revisions"}],"predecessor-version":[{"id":4929,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4928\/revisions\/4929"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=4928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=4928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=4928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}