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
⚠️ 使用说明与注意事项