# verbatimModuleSyntax

> The `verbatimModuleSyntax` TypeScript compiler option keeps imports and exports exactly as written, requiring explicit type-only imports.

## What does verbatimModuleSyntax do in TypeScript?

The compiler option that keeps import and export statements as written, removing only those marked with the `type` modifier. Makes the output predictable for bundlers and type stripping tools.

- Topic: Modules
- Type: concept

## Example

Wrong:

```ts
import { User, getUser } from './api';

const u: User = await getUser();
```

Right:

```ts
import { type User, getUser } from './api';

const u: User = await getUser();
```

Marking `User` with `type` lets the compiler drop it, so the output never imports a name that does not exist.

## Common mistakes

- A runtime crash because an import of a type-only export was kept in the output.

## Key points

- Every type-only import is marked with `import type` or an inline `type` specifier.
- Imports kept only for side effects are written as `import './file'`.
- Older options `importsNotUsedAsValues` and `preserveValueImports` are not used together with it.

## Interview questions

### What is the difference between import type and an inline type modifier?

`import type { A }` removes the whole statement. `import { type A, b }` removes only `A` and keeps the import of `b`.

### Does verbatimModuleSyntax work with CommonJS?

In files emitted as CommonJS, ES `import` syntax is an error under it; use `import x = require('x')` or switch the output to ES modules.

## Related cards

- [import type](https://wonderium.dev/ts/type-only-imports.md)
- [erasableSyntaxOnly](https://wonderium.dev/ts/erasable-syntax-only.md)
- [Type Stripping](https://wonderium.dev/ts/type-stripping.md)
- [moduleResolution](https://wonderium.dev/ts/module-resolution.md)
- [Compiler Options](https://wonderium.dev/ts/compiler-options.md)

---

- Level: [TypeScript](https://wonderium.dev/ts.md)
- HTML version: https://wonderium.dev/ts/verbatim-module-syntax
- Last updated: 2026-11-25
