{"id":98,"date":"2025-10-29T15:35:33","date_gmt":"2025-10-29T07:35:33","guid":{"rendered":"http:\/\/180.76.113.73:8080\/?p=98"},"modified":"2026-06-29T21:20:58","modified_gmt":"2026-06-29T13:20:58","slug":"%e8%ae%b0typescript%e4%b8%8elua%e7%9a%84%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/www.windafterglow.cn\/index.php\/2025\/10\/29\/%e8%ae%b0typescript%e4%b8%8elua%e7%9a%84%e9%85%8d%e7%bd%ae\/","title":{"rendered":"\u8bb0TypeScript\u4e0eLua\u7684\u914d\u7f6e"},"content":{"rendered":"<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" data-src=\"http:\/\/180.76.113.73:8080\/wp-content\/uploads\/2025\/10\/1761707827-20250426071941174562318137809-1024x576.jpg\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@3.0\/basic\/puff-load.svg\" onerror=\"imgError(this)\" alt=\"\" class=\"wp-image-99 lazyload\" srcset=\"https:\/\/www.windafterglow.cn\/wp-content\/uploads\/2025\/10\/1761707827-20250426071941174562318137809-1024x576.jpg 1024w, https:\/\/www.windafterglow.cn\/wp-content\/uploads\/2025\/10\/1761707827-20250426071941174562318137809-300x169.jpg 300w, https:\/\/www.windafterglow.cn\/wp-content\/uploads\/2025\/10\/1761707827-20250426071941174562318137809-768x432.jpg 768w, https:\/\/www.windafterglow.cn\/wp-content\/uploads\/2025\/10\/1761707827-20250426071941174562318137809-1536x864.jpg 1536w, https:\/\/www.windafterglow.cn\/wp-content\/uploads\/2025\/10\/1761707827-20250426071941174562318137809-2048x1152.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><noscript><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"http:\/\/180.76.113.73:8080\/wp-content\/uploads\/2025\/10\/1761707827-20250426071941174562318137809-1024x576.jpg\" alt=\"\" class=\"wp-image-99\" srcset=\"https:\/\/www.windafterglow.cn\/wp-content\/uploads\/2025\/10\/1761707827-20250426071941174562318137809-1024x576.jpg 1024w, https:\/\/www.windafterglow.cn\/wp-content\/uploads\/2025\/10\/1761707827-20250426071941174562318137809-300x169.jpg 300w, https:\/\/www.windafterglow.cn\/wp-content\/uploads\/2025\/10\/1761707827-20250426071941174562318137809-768x432.jpg 768w, https:\/\/www.windafterglow.cn\/wp-content\/uploads\/2025\/10\/1761707827-20250426071941174562318137809-1536x864.jpg 1536w, https:\/\/www.windafterglow.cn\/wp-content\/uploads\/2025\/10\/1761707827-20250426071941174562318137809-2048x1152.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/noscript><\/figure>\n<p>\u8fd9\u662f\u4e00\u4e2a\u5173\u4e8e\u914d\u7f6e\u57fa\u4e8eVSCode\u5e73\u53f0\u5f00\u53d1Ts\u548cLua\u73af\u5883\u7684\u6587\u7ae0\u548c\u8e29\u5751\u8bb0\u5f55\u3002<\/p>\n<h4>TypeScript<\/h4>\n<h5>\u4e00\u3001\u5b89\u88c5Node.js<\/h5>\n<p>\u5728\u5b89\u88c5TypeScript\u4e4b\u524d\uff0c\u9700\u8981\u5148\u5b89\u88c5Node\uff0c\u56e0\u4e3aTs\u662f\u5728Node\u4e0a\u8fd0\u884c\u7684\u3002<\/p>\n<p>Node.js\u5b98\u7f51 :<a href=\"https:\/\/nodejs.org\/en\/\" target=\"_blank\"  rel=\"nofollow\" >https:\/\/nodejs.org\/en\/<\/a><\/p>\n<h5>\u4e8c\u3001\u4f7f\u7528npm\u5b89\u88c5Ts<\/h5>\n<p>\u6253\u5f00cmd\uff0c\u51c6\u5907\u8f93\u5165\u4e0b\u8f7d\u547d\u4ee4<\/p>\n<blockquote>\n<p>\u5207\u6362\u56fd\u5185\u4e0b\u8f7d\u6e90\uff08\u4e5f\u53ef\u4ee5\u4e0d\u5207\u6362\uff09\uff1a<\/p>\n<\/blockquote>\n<pre><code class=\"lang-shell language-shell shell\">npm config set registry https:\/\/registry.npmmirror.com<\/code><\/pre>\n<blockquote>\n<p>\u5b89\u88c5typescript <strong><code>-g<\/code><\/strong>\u4e3a\u5168\u5c40\u5b89\u88c5\uff0c\u4e0d\u6dfb\u52a0\u5219\u4ec5\u5728\u9879\u76ee\u6587\u4ef6\u5939\u5b89\u88c5:<\/p>\n<\/blockquote>\n<pre><code class=\"lang-shell language-shell shell\">npm install -g typescript<\/code><\/pre>\n<blockquote>\n<p>\u8f93\u51fa\u5e94\u4e3a:<\/p>\n<\/blockquote>\n<pre><code class=\"lang-shell language-shell shell\">Version &quot;\u7248\u672c\u53f7&quot;\n\u5982 Version 5.9.3<\/code><\/pre>\n<h5>\u4e09\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/h5>\n<p>\u9700\u8981\u628a<code>Node.js<\/code>\u548c<code>typescript<\/code>\u90fd\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/p>\n<p>\u6ce8\u610f\uff1a\u5982\u679c<code>typescr<\/code>\u662fnpm\u5168\u5c40\u5b89\u88c5\uff0c\u5219\u53ef\u4ee5\u5728\u8f93\u5165:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">npm config ls<\/code><\/pre>\n<blockquote>\n<p>\u8f93\u51fa\uff1a<\/p>\n<\/blockquote>\n<pre><code class=\"lang-shell language-shell shell\">; &quot;builtin&quot; config from &quot;npm \u5b89\u88c5\u8def\u5f84&quot;\n\nprefix = &quot;typescript \u5168\u5c40\u5b89\u88c5\u8def\u5f84&quot;<\/code><\/pre>\n<h5>\u56db\u3001Vscode\u4e2d\u914d\u7f6etypescript\u548c\u4e00\u4e9b\u5c0f\u5751<\/h5>\n<p>\u5728Vscode\u4e2d\u5b89\u88c5\u63d2\u4ef6<code>JavaScript and TypeScript Nightly<\/code>,\u5373\u53ef\u5f00\u59cb\u7740\u624b\u7f16\u5199typescript\u4ee3\u7801\u3002<\/p>\n<p>\u5728\u9879\u76ee\u6587\u4ef6\u5939\u4e2d\u6253\u5f00\u7ec8\u7aef\uff0c\u8f93\u5165:<\/p>\n<pre><code class=\"lang-shell language-shell shell\">tsc --init<\/code><\/pre>\n<p>\u548c<\/p>\n<pre><code class=\"lang-shell language-shell shell\">tsc --watch<\/code><\/pre>\n<p><code>tsc --init<\/code>:\u8be5\u547d\u4ee4\u662f\u521b\u5efa<strong><code>tsconfig.json<\/code><\/strong>\u6587\u4ef6\u7684\uff0c\u53ef\u4ee5\u914d\u7f6etypescript\u7f16\u8bd1\u5668\u3002<\/p>\n<p><code>tsc --watch<\/code>:\u8be5\u547d\u4ee4\u5219\u662f\u81ea\u52a8\u76d1\u542c\u6587\u4ef6\u53d8\u5316\u5e76\u91cd\u65b0\u7f16\u8bd1\u3002<\/p>\n<p><span style=\"color:#ffa500\"><strong>\u6ce8\u610f<\/strong><\/span><\/p>\n<ul>\n<li>\n<blockquote>\n<p>\u5982\u679c\u51fa\u73b0\u62a5\u9519\uff1a\"\u4e0d\u5b58\u5728<code>tsc<\/code>\u547d\u4ee4\"\u6216\u8005 \"<code>\u65e0\u6cd5\u5c06&ldquo;ts-node&rdquo;\u9879\u8bc6\u522b\u4e3a cmdlet\u3001\u51fd\u6570\u3001\u811a\u672c\u6587\u4ef6\u6216\u53ef\u8fd0\u884c\u7a0b\u5e8f\u7684\u540d\u79f0<\/code>\"\u3002<\/p>\n<\/blockquote>\n<p>\u770b\u4e00\u4e0b\u53d8\u91cf\u914d\u7f6e\u662f\u5426\u6b63\u786e\uff0c\u7136\u540e\u91cd\u542f\u4e00\u4e0bvscode\u3002<\/p>\n<\/li>\n<li>\n<blockquote>\n<p>\u5982\u679c\u51fa\u73b0\u62a5\u9519\uff1a<code>TypeScript tsc.ps1 \u65e0\u6cd5\u52a0\u8f7d\uff0c\u56e0\u4e3a\u5728\u6b64\u7cfb\u7edf\u4e0a\u7981\u7528\u4e86\u8fd0\u884c\u811a\u672c<\/code><\/p>\n<\/blockquote>\n<p>\u5219\u4ee5\u7ba1\u7406\u5458\u6743\u9650\u8fd0\u884cPowerShell<\/p>\n<p>\u8f93\u5165\u4e0b\u5217\u547d\u4ee4\u67e5\u8be2\u5f53\u524d\u7684\u811a\u672c\u6267\u884c\u7b56\u7565\uff1a<\/p>\n<pre><code class=\"lang-shell language-shell shell\">Get-ExecutionPolicy<\/code><\/pre>\n<p>\u5982\u679c\u7b56\u7565\u662fRestricted\uff0c\u5219\u8868\u793a\u811a\u672c\u6267\u884c\u88ab\u7981\u7528\u3002<\/p>\n<p>\u9700\u8981\u5c06\u7b56\u7565\u66f4\u6539\u4e3aUnrestricted\uff0c\u4ee5\u5141\u8bb8\u8fd0\u884c\u6240\u6709\u811a\u672c\u3002<\/p>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u66f4\u6539\u7b56\u7565\uff1a<\/p>\n<pre><code>Set-ExecutionPolicy Unrestricted<\/code><\/pre>\n<\/li>\n<li>\n<blockquote>\n<p>\u5982\u679c\u8fd0\u884c\u4e4b\u540e\u8f93\u51fa\u4e3a\uff1a\"<code>typescript 'ts-node' \ufffd\ufffd\ufffd\ufffd\ufffd\u06b2\ufffd\ufffd\ufffd\ufffd\u2cbf\ufffd\ufffd\ufffd\ue8ec\u04b2\ufffd\ufffd\ufffd\u01ff\ufffd\ufffd\ufffd\ufffd\u0435\u0133\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u013c\ufffd\ufffd\ufffd<\/code>\"<\/p>\n<\/blockquote>\n<\/li>\n<\/ul>\n<p>\u200b      \u8fd9\u662f<code>code runner<\/code>\u7684\u95ee\u9898\uff0c\u89e3\u51b3\u65b9\u6cd5\uff1a\n\u200b      \u5728\u8bbe\u7f6e\u91cc\u627e\u5230<code>Code-runner: Language Mapping<\/code>,\u7136\u540e\u7f16\u8f91setting.json\u6587\u4ef6\uff0c\u6dfb\u52a0\u5982\u4e0b\u5185\u5bb9:<\/p>\n<pre><code class=\"lang-json language-json json\">&quot;code-runner.executorMap&quot;: {\n    &quot;typescript&quot;: &quot;npx ts-node --files&quot;\n}<\/code><\/pre>\n<ul>\n<li>\n<blockquote>\n<p>\u5982\u679c\u8fd0\u884c\u65f6\uff0c\u51fa\u73b0\u4e86<code>SyntaxError: Unexpected token ':'<\/code><\/p>\n<\/blockquote>\n<\/li>\n<\/ul>\n<p>\u200b        \u8fd9\u8bf4\u660e\u4f60\u662f\u76f4\u63a5\u8fd0\u884c\u4e86ts\u6587\u4ef6\uff0c\u800c\u4e0d\u662f\u7ecf\u8fc7\u7f16\u8bd1\u540e\u8fd0\u884c\u7684ts\u6587\u4ef6\uff0c\u53ef\u80fd\u662f\u4f60\u5fd8\u4e86\u6267\u884c<code>tsc --watch<\/code>\u6216\u8005ts\u6587\u4ef6\u540e\u7f00\u6709\u95ee\u9898\u3002<\/p>\n<h4>Lua<\/h4>\n<h5>\u4e00\u3001\u4e0b\u8f7d\u4ee3\u7801<\/h5>\n<p>Lua\u5b98\u7f51\uff1a<a href=\"https:\/\/www.lua.org\/\" target=\"_blank\"  rel=\"nofollow\" >The Programming Language Lua<\/a><\/p>\n<figure id=\"attachment_mmd_139\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"300\" height=\"155\" data-src=\"https:\/\/www.windafterglow.cn\/wp-content\/uploads\/2025\/10\/1761723173-image-20251029152241815-300x155.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@3.0\/basic\/puff-load.svg\" onerror=\"imgError(this)\" class=\"attachment-300x155 size-300x155 lazyload\" alt=\"1761723173-image-20251029152241815\" loading=\"lazy\" align=\"none\" \/><noscript><img decoding=\"async\" width=\"300\" height=\"155\" src=\"https:\/\/www.windafterglow.cn\/wp-content\/uploads\/2025\/10\/1761723173-image-20251029152241815-300x155.png\" class=\"attachment-300x155 size-300x155\" alt=\"1761723173-image-20251029152241815\" loading=\"lazy\" align=\"none\" \/><\/noscript><\/figure>\n<figure id=\"attachment_mmd_138\" class=\"wp-block-image alignnone\"><img decoding=\"async\" width=\"300\" height=\"205\" data-src=\"https:\/\/www.windafterglow.cn\/wp-content\/uploads\/2025\/10\/1761723172-image-20251029152358205-300x205.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@3.0\/basic\/puff-load.svg\" onerror=\"imgError(this)\" class=\"attachment-300x205 size-300x205 lazyload\" alt=\"1761723172-image-20251029152358205\" loading=\"lazy\" align=\"none\" \/><noscript><img decoding=\"async\" width=\"300\" height=\"205\" src=\"https:\/\/www.windafterglow.cn\/wp-content\/uploads\/2025\/10\/1761723172-image-20251029152358205-300x205.png\" class=\"attachment-300x205 size-300x205\" alt=\"1761723172-image-20251029152358205\" loading=\"lazy\" align=\"none\" \/><\/noscript><\/figure>\n<p><strong>\u7136\u540e\u4e0b\u8f7d\uff0c\u89e3\u538b\u5230\u6307\u5b9a\u6587\u4ef6\u5939\uff0c\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/strong><\/p>\n<h5>\u4e8c\u3001Vscode\u914d\u7f6eLua\u548c\u5751<\/h5>\n<p>\u5728Vscode\u4e2d\u4e0b\u8f7d\u63d2\u4ef6<code>Lua<\/code>\uff08\u6de1\u84dd\u8272\u7684\u90a3\u4e2a\uff09\u548c<code>Lua Debug<\/code>\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u5c31\u53ef\u4ee5\u5199Lua\u4ee3\u7801\u4e86\u3002<\/p>\n<p><strong><span style=\"color:#ffa500\">\u6ce8\u610f<\/span><\/strong><\/p>\n<ul>\n<li>\n<blockquote>\n<p>\u5982\u679c\u51fa\u73b0\uff1a<code>'lua' \ufffd\ufffd\ufffd\ufffd\ufffd\u06b2\ufffd\ufffd\ufffd\ufffd\u2cbf\ufffd\ufffd\ufffd\ue8ec\u04b2\ufffd\ufffd\ufffd\u01ff\ufffd\ufffd\ufffd\ufffd\u0435\u0133\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u013c\ufffd\ufffd\ufffd<\/code><\/p>\n<\/blockquote>\n<\/li>\n<\/ul>\n<p>\u200b       \u8fd9\u8fd8\u662fCodeRunner\u7684\u95ee\u9898\uff0c\u627e\u5230CodeRunner\u7684<code>Code-runner: Executor Map<\/code>\uff0c\u5728<code>code-runner.executorMap<\/code>\u4e2d\u6dfb\u52a0\u5b89\u88c5\u7684Lua\u7a0b\u5e8f\u4f4d\u7f6e\uff0c\u5982\uff1a<\/p>\n<pre><code class=\"lang-json language-json json\">&quot;code-runner.executorMap&quot;: {\n\n    &quot;lua&quot;:&quot;F:\\\\ProgrammerEnv\\\\Lua\\\\lua53.exe&quot;,\n}<\/code><\/pre>\n<ul>\n<li>\n<blockquote>\n<p>\u8fd8\u6709\u4e2a\u4e2d\u6587\u4e71\u7801\u95ee\u9898<\/p>\n<\/blockquote>\n<\/li>\n<\/ul>\n<p>\u200b       \u6211\u662f\u4e0b\u8f7d\u4e86Vscode\u5185\u7f6e\u7684<code>GBK to UTF8 for vscode<\/code>\u63d2\u4ef6\u8fdb\u884c\u89e3\u51b3\u7684\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u662f\u4e00\u4e2a\u5173\u4e8e\u914d\u7f6e\u57fa\u4e8eVSCode\u5e73\u53f0\u5f00\u53d1Ts\u548cLua\u73af\u5883\u7684\u6587\u7ae0\u548c\u8e29\u5751\u8bb0\u5f55\u3002 TypeScript \u4e00\u3001\u5b89\u88c5Node.js \u5728\u5b89\u88c5T &#8230;<\/p>","protected":false},"author":1,"featured_media":99,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-98","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-1"],"_links":{"self":[{"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/posts\/98","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/comments?post=98"}],"version-history":[{"count":26,"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/posts\/98\/revisions"}],"predecessor-version":[{"id":191,"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/posts\/98\/revisions\/191"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/media\/99"}],"wp:attachment":[{"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/media?parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/categories?post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.windafterglow.cn\/index.php\/wp-json\/wp\/v2\/tags?post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}