verbatimModuleSyntax
The compiler option that keeps every import and export exactly as written, except those marked type, which are removed.
In more detail
It makes the output predictable for tools that compile one file at a time, such as esbuild, SWC and Node.js type stripping. Importing an interface without the type keyword becomes an error. It replaced the older importsNotUsedAsValues and preserveValueImports options in TypeScript 5.0.
Related terms
- type-only import — An import written import type { X } or import { type X }, which brings in only types and is always removed from the output.
- type stripping — Running TypeScript by deleting the type annotations and executing what is left, without checking the types.
- bundler — A build tool, such as webpack, Rollup or Vite, that follows imports and combines modules into files a browser can load efficiently.
- single-file transpilation — Compiling each file on its own without looking at the rest of the project, which is fast but cannot use type information.
Taught in
- ECMAScript Modules, CJS Interop And verbatimModuleSyntax — Production TypeScript