{"id":4924,"date":"2023-01-05T11:19:32","date_gmt":"2023-01-05T03:19:32","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=4924"},"modified":"2023-01-05T11:19:32","modified_gmt":"2023-01-05T03:19:32","slug":"%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8typescript%e7%b1%bb%e5%9e%8b%e5%88%ab%e5%90%8d%e8%87%aa%e5%ae%9a%e4%b9%89","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/typescript\/%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8typescript%e7%b1%bb%e5%9e%8b%e5%88%ab%e5%90%8d%e8%87%aa%e5%ae%9a%e4%b9%89\/","title":{"rendered":"\u5b78\u7fd2\u5982\u4f55\u4f7f\u7528TypeScript\u7c7b\u578b\u522b\u540d\u81ea\u5b9a\u4e49"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"TypeScript, \u7c7b\u578b\u522b\u540d, \u81ea\u5b9a\u4e49\"><\/p>\n<h1>TypeScript \u7c7b\u578b\u522b\u540d(type alias)\u7684\u81ea\u5b9a\u4e49<\/h1>\n<p>TypeScript \u662f\u4e00\u7a2e\u5f37\u578b\u5225\u7684 JavaScript \u8a9e\u8a00\uff0c\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5728\u958b\u767c\u6642\u5c31\u53ef\u4ee5\u6aa2\u67e5\u51fa\u7a0b\u5f0f\u78bc\u4e2d\u7684\u932f\u8aa4\uff0c\u6e1b\u5c11\u958b\u767c\u6642\u9593\u3002TypeScript \u4e2d\u7684\u7c7b\u578b\u522b\u540d(type alias)\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u81ea\u5b9a\u4e49\u81ea\u5df1\u7684\u8cc7\u6599\u578b\u5225\uff0c\u8b93\u7a0b\u5f0f\u78bc\u66f4\u52a0\u6e05\u6670\u6613\u8b80\u3002<\/p>\n<h2>\u4ec0\u9ebc\u662f TypeScript \u7c7b\u578b\u522b\u540d(type alias)<\/h2>\n<p>TypeScript \u7c7b\u578b\u522b\u540d(type alias)\u662f\u4e00\u7a2e\u81ea\u5b9a\u7fa9\u7684\u8cc7\u6599\u578b\u5225\uff0c\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5c07\u4e00\u7a2e\u8907\u96dc\u7684\u8cc7\u6599\u578b\u5225\u7c21\u5316\uff0c\u8b93\u7a0b\u5f0f\u78bc\u66f4\u52a0\u6e05\u6670\u6613\u8b80\u3002<\/p>\n<h2>TypeScript \u7c7b\u578b\u522b\u540d(type alias)\u7684\u8a9e\u6cd5<\/h2>\n<p>TypeScript \u7c7b\u578b\u522b\u540d(type alias)\u7684\u8a9e\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre class=\"brush: javascript\">\ntype \u81ea\u5b9a\u7fa9\u578b\u5225\u540d\u7a31 = \u8cc7\u6599\u578b\u5225;\n<\/pre>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre class=\"brush: javascript\">\ntype Name = string;\n<\/pre>\n<p>\u4e0a\u9762\u7684\u7a0b\u5f0f\u78bc\u5b9a\u7fa9\u4e86\u4e00\u500b\u540d\u70ba Name \u7684\u81ea\u5b9a\u7fa9\u578b\u5225\uff0c\u5b83\u7684\u8cc7\u6599\u578b\u5225\u662f string\u3002<\/p>\n<h2>TypeScript \u7c7b\u578b\u522b\u540d(type alias)\u7684\u4f7f\u7528<\/h2>\n<p>TypeScript \u7c7b\u578b\u522b\u540d(type alias)\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5c07\u4e00\u7a2e\u8907\u96dc\u7684\u8cc7\u6599\u578b\u5225\u7c21\u5316\uff0c\u8b93\u7a0b\u5f0f\u78bc\u66f4\u52a0\u6e05\u6670\u6613\u8b80\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5047\u8a2d\u6211\u5011\u6709\u4e00\u500b\u8907\u96dc\u7684\u8cc7\u6599\u578b\u5225\uff1a<\/p>\n<pre class=\"brush: javascript\">\ntype Person = {\n  name: string;\n  age: number;\n  address: {\n    street: string;\n    city: string;\n    state: string;\n  };\n};\n<\/pre>\n<p>\u6211\u5011\u53ef\u4ee5\u4f7f\u7528 TypeScript \u7c7b\u578b\u522b\u540d(type alias)\u5c07\u5b83\u7c21\u5316\uff1a<\/p>\n<pre class=\"brush: javascript\">\ntype PersonInfo = {\n  name: string;\n  age: number;\n};\n\ntype Address = {\n  street: string;\n  city: string;\n  state: string;\n};\n\ntype Person = PersonInfo & Address;\n<\/pre>\n<p>\u4e0a\u9762\u7684\u7a0b\u5f0f\u78bc\u5c07 Person \u8cc7\u6599\u578b\u5225\u7c21\u5316\u70ba PersonInfo \u8207 Address \u5169\u500b\u8cc7\u6599\u578b\u5225\uff0c\u4f7f\u5f97\u7a0b\u5f0f\u78bc\u66f4\u52a0\u6e05\u6670\u6613\u8b80\u3002<\/p>\n<p><!--more--><\/p>\n<h2>\u7e3d\u7d50<\/h2>\n<p>TypeScript \u7c7b\u578b\u522b\u540d(type alias)\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u81ea\u5b9a\u7fa9\u81ea\u5df1\u7684\u8cc7\u6599\u578b\u5225\uff0c\u8b93\u7a0b\u5f0f\u78bc\u66f4\u52a0\u6e05\u6670\u6613\u8b80\u3002\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5c07\u4e00\u7a2e\u8907\u96dc\u7684\u8cc7\u6599\u578b\u5225\u7c21\u5316\uff0c\u4f7f\u5f97\u7a0b\u5f0f\u78bc\u66f4\u52a0\u6e05\u6670\u6613\u8b80\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981\uff1aTypeScript\u7c7b\u578b\u522b\u540d\u662f\u4e00\u7a2e\u5f37\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u81ea\u5b9a\u7fa9\u8907\u96dc\u7684\u985e\u578b\uff0c\u4e26\u66f4\u597d\u5730\u7ba1\u7406\u548c\u7d44\u7e54\u4ee3\u78bc\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528TypeScript\u7c7b\u578b\u5225\u540d\u81ea\u5b9a\u7fa9\uff0c\u4ee5\u53ca\u5b83\u7684\u512a\u9ede\u548c\u7f3a\u9ede\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-4924","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-1hq","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4924","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=4924"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4924\/revisions"}],"predecessor-version":[{"id":4925,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4924\/revisions\/4925"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=4924"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=4924"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=4924"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}