{"id":3105,"date":"2024-11-10T10:41:29","date_gmt":"2024-11-10T02:41:29","guid":{"rendered":"https:\/\/fwq.ai\/blog\/3105\/"},"modified":"2024-11-10T10:41:29","modified_gmt":"2024-11-10T02:41:29","slug":"%e6%89%8b%e6%9c%ba%e8%bf%90%e8%a1%8ctypescript%e7%9a%84%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/3105\/","title":{"rendered":"\u624b\u673a\u8fd0\u884ctypescript\u7684\u65b9\u6cd5"},"content":{"rendered":"<blockquote><p>\n  \u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u5728\u624b\u673a\u4e0a\u8fd0\u884c typescript\uff1a\u4f7f\u7528\u7f16\u8bd1\u5668\uff08\u5982 typescript playground\u3001tslint\uff09\u3001\u4f7f\u7528\u6846\u67b6\uff08\u5982 capacitor\u3001ionic\uff09\u6216\u4f7f\u7528\u8f6c\u6362\u5668\uff08\u5982 babel\uff09\u3002\u7f16\u8bd1\u5668\u9002\u7528\u4e8e\u5feb\u901f\u6d4b\u8bd5\uff0c\u6846\u67b6\u9002\u7528\u4e8e\u539f\u751f\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\uff0c\u8f6c\u6362\u5668\u9002\u7528\u4e8e\u5728\u79fb\u52a8\u6d4f\u89c8\u5668\u4e2d\u8fd0\u884c typescript \u4ee3\u7801\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/07\/2024110723454685353.jpg\" class=\"aligncenter\" title=\"\u624b\u673a\u8fd0\u884ctypescript\u7684\u65b9\u6cd5\u63d2\u56fe\" alt=\"\u624b\u673a\u8fd0\u884ctypescript\u7684\u65b9\u6cd5\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5728\u624b\u673a\u4e0a\u8fd0\u884c TypeScript<\/strong><\/p>\n<p>\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u5728\u624b\u673a\u4e0a\u8fd0\u884c TypeScript\uff1a<\/p>\n<p><strong>\u4f7f\u7528\u7f16\u8bd1\u5668:<\/strong><\/p>\n<ul>\n<li> <strong>TypeScript Playground:<\/strong> \u5728\u7ebf\u5de5\u5177\uff0c\u53ef\u7f16\u8bd1\u5e76\u8fd0\u884c TypeScript \u4ee3\u7801\uff0c\u4f46\u53ef\u80fd\u6709\u529f\u80fd\u9650\u5236\u3002<\/li>\n<li> <strong>TSLint:<\/strong> \u547d\u4ee4\u884c\u5de5\u5177\uff0c\u53ef\u7f16\u8bd1 TypeScript \u4ee3\u7801\u5e76\u68c0\u67e5\u98ce\u683c\u548c\u9519\u8bef\u3002<\/li>\n<\/ul>\n<p><strong>\u4f7f\u7528\u6846\u67b6:<\/strong><\/p>\n<ul>\n<li> <strong>Capacitor:<\/strong> \u5f00\u6e90\u6846\u67b6\uff0c\u5141\u8bb8\u4f7f\u7528 TypeScript \u7f16\u5199\u539f\u751f\uff0c\u53ef\u5728 iOS \u548c Android \u4e0a\u8fd0\u884c\u3002<\/li>\n<li> <strong>Ionic:<\/strong> \u57fa\u4e8e Capacitor \u7684\u6846\u67b6\uff0c\u63d0\u4f9b UI \u7ec4\u4ef6\u548c\u5de5\u5177\uff0c\u7b80\u5316\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u3002<\/li>\n<\/ul>\n<p><strong>\u4f7f\u7528\u8f6c\u6362\u5668:<\/strong><\/p>\n<ul>\n<li> <strong>Babel:<\/strong> \u8f6c\u6362\u5668\uff0c\u53ef\u5c06 TypeScript \u4ee3\u7801\u8f6c\u6362\u4e3a JavaScript\uff0c\u7136\u540e\u53ef\u4ee5\u5728\u79fb\u52a8\u6d4f\u89c8\u5668\u4e2d\u8fd0\u884c\u3002<\/li>\n<\/ul>\n<p><strong>\u8be6\u7ec6\u8bf4\u660e:<\/strong><\/p>\n<p><strong>\u4f7f\u7528\u7f16\u8bd1\u5668:<\/strong><\/p>\n<p>TypeScript Playground \u662f\u4e00\u4e2a\u7b80\u5355\u6613\u7528\u7684\u5de5\u5177\uff0c\u9002\u5408\u5feb\u901f\u6d4b\u8bd5\u6216\u7f16\u5199\u5c11\u91cf\u4ee3\u7801\u3002\u53ea\u9700\u7c98\u8d34 TypeScript \u4ee3\u7801\u5e76\u70b9\u51fb\u201cRun\u201d\u6309\u94ae\u5373\u53ef\u3002<\/p>\n<p>TSLint \u5bf9\u4e8e\u5927\u578b\u9879\u76ee\u66f4\u5b9e\u7528\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u786e\u4fdd\u4ee3\u7801\u8d28\u91cf\u5e76\u9632\u6b62\u9519\u8bef\u3002\u53ef\u4ee5\u4f7f\u7528 npm \u5b89\u88c5 TSLint\uff0c\u7136\u540e\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u7f16\u8bd1\u4ee3\u7801\uff1a<\/p>\n<pre>tslint --project tsconfig.json<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u4f7f\u7528\u6846\u67b6:<\/strong><\/p>\n<p>Capacitor \u548c Ionic \u662f\u6d41\u884c\u7684\u6846\u67b6\uff0c\u5141\u8bb8\u4f7f\u7528 TypeScript \u5f00\u53d1\u539f\u751f\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u4eec\u63d0\u4f9b\u4e86\u5bf9\u8bbe\u5907\u529f\u80fd\u7684\u8bbf\u95ee\uff0c\u5982\u76f8\u673a\u3001GPS \u548c\u5b58\u50a8\u3002<\/p>\n<p><strong>\u4f7f\u7528\u8f6c\u6362\u5668:<\/strong><\/p>\n<p>Babel \u53ef\u4ee5\u5c06 TypeScript \u4ee3\u7801\u8f6c\u6362\u4e3a JavaScript \u4ee3\u7801\uff0c\u53ef\u4ee5\u4f7f\u7528 npm \u5b89\u88c5 Babel\uff0c\u7136\u540e\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8f6c\u6362\u4ee3\u7801\uff1a<\/p>\n<pre>babel input.ts --out output.js<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8f6c\u6362\u540e\u7684 JavaScript \u4ee3\u7801\u53ef\u4ee5\u5728\u79fb\u52a8\u6d4f\u89c8\u5668\u4e2d\u8fd0\u884c\uff0c\u4f8b\u5982 Safari \u6216 Chrome\u3002<\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879:<\/strong><\/p>\n<p>\u5728\u624b\u673a\u4e0a\u8fd0\u884c TypeScript \u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u9650\u5236\uff1a<\/p>\n<ul>\n<li> <strong>\u67d0\u4e9b\u529f\u80fd\u4e0d\u53ef\u7528:<\/strong> \u4f7f\u7528\u539f\u751f\u8bbe\u5907\u529f\u80fd\uff08\u5982\u76f8\u673a\uff09\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u7279\u5b9a\u4e8e\u5e73\u53f0\u7684\u4ee3\u7801\u3002<\/li>\n<li> <strong>\u6027\u80fd\u9650\u5236:<\/strong> \u5728\u4f4e\u7aef\u8bbe\u5907\u4e0a\u8fd0\u884c TypeScript \u4ee3\u7801\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6027\u80fd\u95ee\u9898\u3002<\/li>\n<li> <strong>\u8c03\u8bd5\u56f0\u96be:<\/strong> \u5728\u79fb\u52a8\u8bbe\u5907\u4e0a\u8c03\u8bd5 TypeScript \u4ee3\u7801\u53ef\u80fd\u6bd4\u5728\u684c\u9762\u73af\u5883\u4e2d\u66f4\u56f0\u96be\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u624b\u673a\u8fd0\u884c\u7684\u65b9\u6cd5\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u5728\u624b\u673a\u4e0a\u8fd0\u884c typescript\uff1a\u4f7f\u7528\u7f16\u8bd1\u5668\uff08\u5982 typescript playground\u3001tslint\uff09\u3001\u4f7f\u7528\u6846\u67b6\uff08\u5982 capacitor\u3001ionic\uff09\u6216\u4f7f\u7528\u8f6c\u6362\u5668\uff08\u5982 babel\uff09\u3002\u7f16\u8bd1\u5668\u9002\u7528\u4e8e\u5feb\u901f\u6d4b\u8bd5\uff0c\u6846\u67b6\u9002\u7528\u4e8e\u539f\u751f\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\uff0c\u8f6c\u6362\u5668\u9002\u7528\u4e8e\u5728\u79fb\u52a8\u6d4f\u89c8\u5668\u4e2d\u8fd0\u884c typescript \u4ee3\u7801\u3002 \u5728\u624b\u673a\u4e0a\u8fd0\u884c TypeScript \u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u5728\u624b\u673a\u4e0a\u8fd0\u884c TypeScript\uff1a \u4f7f\u7528\u7f16\u8bd1\u5668: TypeScript Playground: \u5728\u7ebf\u5de5\u5177\uff0c\u53ef\u7f16\u8bd1\u5e76\u8fd0\u884c TypeScript \u4ee3\u7801\uff0c\u4f46\u53ef\u80fd\u6709\u529f\u80fd\u9650\u5236\u3002 TSLint: \u547d\u4ee4\u884c\u5de5\u5177\uff0c\u53ef\u7f16\u8bd1 TypeScript \u4ee3\u7801\u5e76\u68c0\u67e5\u98ce\u683c\u548c\u9519\u8bef\u3002 \u4f7f\u7528\u6846\u67b6: Capacitor: \u5f00\u6e90\u6846\u67b6\uff0c\u5141\u8bb8\u4f7f\u7528 TypeScript \u7f16\u5199\u539f\u751f\uff0c\u53ef\u5728 iOS \u548c Android \u4e0a\u8fd0\u884c\u3002 Ionic: \u57fa\u4e8e Capacitor \u7684\u6846\u67b6\uff0c\u63d0\u4f9b UI \u7ec4\u4ef6\u548c\u5de5\u5177\uff0c\u7b80\u5316\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u3002 \u4f7f\u7528\u8f6c\u6362\u5668: Babel: \u8f6c\u6362\u5668\uff0c\u53ef\u5c06 TypeScript \u4ee3\u7801\u8f6c\u6362\u4e3a JavaScript\uff0c\u7136\u540e\u53ef\u4ee5\u5728\u79fb\u52a8\u6d4f\u89c8\u5668\u4e2d\u8fd0\u884c\u3002 \u8be6\u7ec6\u8bf4\u660e: \u4f7f\u7528\u7f16\u8bd1\u5668: TypeScript Playground \u662f\u4e00\u4e2a\u7b80\u5355\u6613\u7528\u7684\u5de5\u5177\uff0c\u9002\u5408\u5feb\u901f\u6d4b\u8bd5\u6216\u7f16\u5199\u5c11\u91cf\u4ee3\u7801\u3002\u53ea\u9700\u7c98\u8d34 TypeScript \u4ee3\u7801\u5e76\u70b9\u51fb\u201cRun\u201d\u6309\u94ae\u5373\u53ef\u3002 TSLint \u5bf9\u4e8e\u5927\u578b\u9879\u76ee\u66f4\u5b9e\u7528\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u786e\u4fdd\u4ee3\u7801\u8d28\u91cf\u5e76\u9632\u6b62\u9519\u8bef\u3002\u53ef\u4ee5\u4f7f\u7528 npm \u5b89\u88c5 TSLint\uff0c\u7136\u540e\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u7f16\u8bd1\u4ee3\u7801\uff1a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-3105","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=3105"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/3105\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=3105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=3105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=3105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}