{"id":4844,"date":"2023-01-05T10:47:20","date_gmt":"2023-01-05T02:47:20","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=4844"},"modified":"2023-01-05T10:47:20","modified_gmt":"2023-01-05T02:47:20","slug":"%e6%b7%b1%e5%85%a5%e4%ba%86%e8%a7%a3typescript%e7%b1%bb%e5%9e%8b%e5%85%bc%e5%ae%b9%e6%80%a7%ef%bc%9a%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8%e5%ae%83%e4%be%86%e6%8f%90%e9%ab%98%e7%a8%8b%e5%ba%8f%e5%93%81","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/typescript\/%e6%b7%b1%e5%85%a5%e4%ba%86%e8%a7%a3typescript%e7%b1%bb%e5%9e%8b%e5%85%bc%e5%ae%b9%e6%80%a7%ef%bc%9a%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8%e5%ae%83%e4%be%86%e6%8f%90%e9%ab%98%e7%a8%8b%e5%ba%8f%e5%93%81\/","title":{"rendered":"\u6df1\u5165\u4e86\u89e3TypeScript\u7c7b\u578b\u517c\u5bb9\u6027\uff1a\u5982\u4f55\u4f7f\u7528\u5b83\u4f86\u63d0\u9ad8\u7a0b\u5e8f\u54c1\u8cea"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"TypeScript, Type Compatibility\"><\/p>\n<h1>TypeScript \u7c7b\u578b\u517c\u5bb9\u6027(type compatibility)<\/h1>\n<p>TypeScript \u662f\u4e00\u7a2e\u5f37\u578b\u5225\u7684 JavaScript \u8a9e\u8a00\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u7a2e\u7a31\u70ba\u300c\u7c7b\u578b\u517c\u5bb9\u6027\u300d\u7684\u6a5f\u5236\uff0c\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5728\u7a0b\u5f0f\u78bc\u4e2d\u66f4\u5bb9\u6613\u5730\u6aa2\u67e5\u548c\u64cd\u4f5c\u8cc7\u6599\u985e\u578b\u3002\u7c7b\u578b\u517c\u5bb9\u6027\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u6aa2\u67e5\u548c\u64cd\u4f5c\u8cc7\u6599\u985e\u578b\uff0c\u4e26\u4e14\u53ef\u4ee5\u6e1b\u5c11\u7a0b\u5f0f\u78bc\u4e2d\u7684\u932f\u8aa4\u3002<\/p>\n<p><!--more--><\/p>\n<p>TypeScript \u7684\u7c7b\u578b\u517c\u5bb9\u6027\u662f\u57fa\u65bc JavaScript \u7684\u539f\u751f\u7c7b\u578b\u7cfb\u7edf\uff0c\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u5728\u7a0b\u5f0f\u78bc\u4e2d\u66f4\u5bb9\u6613\u5730\u6aa2\u67e5\u548c\u64cd\u4f5c\u8cc7\u6599\u985e\u578b\u3002\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u6aa2\u67e5\u548c\u64cd\u4f5c\u8cc7\u6599\u985e\u578b\uff0c\u4e26\u4e14\u53ef\u4ee5\u6e1b\u5c11\u7a0b\u5f0f\u78bc\u4e2d\u7684\u932f\u8aa4\u3002<\/p>\n<p>TypeScript \u7684\u7c7b\u578b\u517c\u5bb9\u6027\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u6aa2\u67e5\u548c\u64cd\u4f5c\u8cc7\u6599\u985e\u578b\uff0c\u4e26\u4e14\u53ef\u4ee5\u6e1b\u5c11\u7a0b\u5f0f\u78bc\u4e2d\u7684\u932f\u8aa4\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u60f3\u8981\u5c07\u4e00\u500b\u5b57\u4e32\u8f49\u63db\u70ba\u6578\u5b57\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 <code>parseInt()<\/code> \u51fd\u6578\uff1a<\/p>\n<pre class=\"brush: javascript\">\nlet str = \"123\";\nlet num = parseInt(str);\nconsole.log(num); \/\/ 123\n<\/pre>\n<p>TypeScript \u7684\u7c7b\u578b\u517c\u5bb9\u6027\u9084\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u6aa2\u67e5\u548c\u64cd\u4f5c\u8cc7\u6599\u985e\u578b\uff0c\u4e26\u4e14\u53ef\u4ee5\u6e1b\u5c11\u7a0b\u5f0f\u78bc\u4e2d\u7684\u932f\u8aa4\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u60f3\u8981\u6aa2\u67e5\u4e00\u500b\u8b8a\u6578\u662f\u5426\u70ba\u5b57\u4e32\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 <code>typeof<\/code> \u904b\u7b97\u5b50\uff1a<\/p>\n<pre class=\"brush: javascript\">\nlet str = \"123\";\nlet isString = typeof str === \"string\";\nconsole.log(isString); \/\/ true\n<\/pre>\n<p>TypeScript \u7684\u7c7b\u578b\u517c\u5bb9\u6027\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u6aa2\u67e5\u548c\u64cd\u4f5c\u8cc7\u6599\u985e\u578b\uff0c\u4e26\u4e14\u53ef\u4ee5\u6e1b\u5c11\u7a0b\u5f0f\u78bc\u4e2d\u7684\u932f\u8aa4\u3002\u5b83\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u6aa2\u67e5\u548c\u64cd\u4f5c\u8cc7\u6599\u985e\u578b\uff0c\u4e26\u4e14\u53ef\u4ee5\u6e1b\u5c11\u7a0b\u5f0f\u78bc\u4e2d\u7684\u932f\u8aa4\u3002\u4f7f\u7528 TypeScript \u7684\u7c7b\u578b\u517c\u5bb9\u6027\u53ef\u4ee5\u8b93\u958b\u767c\u8005\u66f4\u5bb9\u6613\u5730\u6aa2\u67e5\u548c\u64cd\u4f5c\u8cc7\u6599\u985e\u578b\uff0c\u4e26\u4e14\u53ef\u4ee5\u6e1b\u5c11\u7a0b\u5f0f\u78bc\u4e2d\u7684\u932f\u8aa4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981\uff1aTypeScript\u7c7b\u578b\u517c\u5bb9\u6027\u662f\u4e00\u7a2e\u7a0b\u5e8f\u8a2d\u8a08\u6280\u8853\uff0c\u53ef\u4ee5\u5e6b\u52a9\u958b\u767c\u4eba\u54e1\u66f4\u597d\u5730\u7ba1\u7406\u548c\u63a7\u5236\u7a0b\u5e8f\u7684\u54c1\u8cea\u3002\u672c\u6587\u5c07\u4ecb\u7d39TypeScript\u7c7b\u578b\u517c\u5bb9\u6027\u7684\u57fa\u672c\u6982\u5ff5\uff0c\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528\u5b83\u4f86\u63d0\u9ad8\u7a0b\u5e8f\u54c1\u8cea\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-4844","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-1g8","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4844","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=4844"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4844\/revisions"}],"predecessor-version":[{"id":4845,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/4844\/revisions\/4845"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=4844"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=4844"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=4844"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}