TypeScript轉JavaScript編譯器

💻 TypeScript Compiler

📐 工作原理與說明
呼叫 ts.transpileModule(原始碼, 選項) 做單檔案轉譯——僅移除型別註解,不做完整型別檢查;target 對映 ts.ScriptTarget(ES3 / ES5 / ES2015 / ES2017 / ES2020 / ESNext),module 對映 ts.ModuleKind(None / CommonJS / AMD / UMD / ESNext);編譯耗時 = performance.now() 前後差值(無 performance 時退回 Date.now());異常時診斷面板報編譯異常並清空輸出
把 TypeScript 編譯為 JavaScript。
  • 流程:先做型別檢查,再擦除型別註解,並按 target 降級語法(如轉為 ES5)。
  • 型別擦除:型別資訊只在編譯期存在,執行時不可見,因此無法用於執行時校驗。
  • 配置:tsconfig.json 控制 target、module、strict、lib 與輸出目錄。
  • 提醒:編譯不校驗外部資料,介面返回值等仍需做執行時校驗。

Compile TypeScript to JavaScript in your browser — try code without a toolchain.

TypeScript 輸入 支援 Tab 縮排
JavaScript 輸出 只讀
編譯耗時:- ms
輸出行數:- 行
輸出大小:- 字元
🩺 編譯診斷資訊 0 ▼
等待編譯...

Formula & Standard References

Item Formula / Note Source / Standard
Target the target option selects syntax lowering level TypeScript compiler options
Module system the module option chooses commonjs, esnext and others TypeScript compiler options
Type checking the strict family improves type safety and should be on TypeScript compiler options
⚠️ 使用說明與注意事項