Skip to content
Tutorials Center
My learning

Topics

TypeScript Reference ยท tsconfig: Language, Modules and Emit Options

TypeScript verbatimModuleSyntax option

Reference for verbatimModuleSyntax: imports without type are kept, imports with type are erased, error TS1484, and how it replaces importsNotUsedAsValues.

verbatimModuleSyntax makes import and export emit predictable. Any import or export without the type keyword is kept in the output exactly as written; anything marked type is removed. The compiler no longer guesses whether an import is "used only as a type" and drops it silently.

To make this safe, the compiler reports an error when you import something that is only a type without marking it with type (TS1484). It also reports ES-style syntax in a file that would be emitted as CommonJS. It replaces the older importsNotUsedAsValues and preserveValueImports options.

TypeScript
import type { User } from "./user.js";        // erased
import { type Role, createUser } from "./user.js"; // Role erased, createUser kept

Try it

TypeScript What is kept and what is erased

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.

TypeScript Type-only imports in real code

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or readFileSync(0)), it gets the next line from this box.

Syntax

JSON
{ "compilerOptions": { "verbatimModuleSyntax": true } }
Source form Result
import type { A } from "m" Removed completely.
import { type A, b } from "m" Becomes import { b } from "m".
import { A } from "m" where A is a type Error TS1484. Add type.
import "m" Always kept.
export type { A } Removed.
export = / import x = require() in an ESM-emitting file Error: use export default / import.

Usage notes

  • A fully type-only import with the inline form (import { type A } from "m") leaves import {} from "m" behind in older versions, which still loads the module. Use import type { A } from "m" when you want no runtime import at all.
  • The option removes the guesswork that made import { Foo } from "./foo" sometimes import a module and sometimes not, depending on how Foo was used.
  • In a CommonJS-emitting project, import statements are errors (TS1286); use import x = require("m") or switch to ESM output.
  • It is the recommended companion to isolatedModules for bundlers, Vite, and Node type stripping.
  • Enable it from the start; converting a large codebase later means adding type keywords in many files. Editors and linters (consistent-type-imports) can fix them automatically.
  • Re-export statements follow the same rule: export { T } of a type needs export type.