jsconfig.json option

verbatimModuleSyntax

  • Default false
  • Since TypeScript 5.0

In a TypeScript project, verbatimModuleSyntax makes tsc write every import and export as written, dropping only those marked type. That is about output, and a JavaScript project with noEmit has none. It also cannot change how you import types: JavaScript has no import type syntax, and type imports in JSDoc (@import, import("./x.js").T) never reach the output anyway.

What it does do in a .js file: under module: "nodenext", it reports ESM export syntax in a file TypeScript treats as CommonJS (TS1287): a .cjs file, or a .js file whose package.json says "type": "commonjs" or has no type field. Without the option, TypeScript checks such a file quietly. Node.js refuses export in a file it loads as CommonJS; recent Node.js versions run a .js file without a type field as an ES module when it uses ES module syntax, so the error matters most where "type": "commonjs" is set. It arrived with TypeScript 5.0, and tsc --init writes it in 5.9.

At a glance

Write Optional in a .js project. Turn it on if some files are CommonJS: it reports export syntax in files TypeScript treats as CommonJS
On the command line --verbatimModuleSyntax
Type boolean
Default in TypeScript 5.9 false
TypeScript's description Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting.

The description is quoted from TypeScript's own option list (Apache-2.0); see the notices.

Examples

main.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: main.js(2,1): error TS1287: A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. main.js(2,1): error TS1287: A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. main.js(2,1): error TS1287: A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled. checked 21 October 2026
export const port = 8080;error TS1287: A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled.
verbatimModuleSyntax on: ESM syntax in a CommonJS file.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": [],
    "verbatimModuleSyntax": true
  },
  "include": [
    "*.js"
  ]
}
main.js TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. No errors. checked 21 October 2026
export const port = 8080;
verbatimModuleSyntax off: the same file passes, and Node.js would refuse to run it.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": [
    "*.js"
  ]
}

Importing a type in JavaScript

With or without this option, import { Config } from "./types.js" for a name that is only a @typedef is an error in a .js file (TS18042): JavaScript imports are values. Use @import (TypeScript 5.5 and later) or an import() type in JSDoc.

Gotchas

  • In TypeScript 5.9 an import statement in a CommonJS .js file is not reported under this option, only export; Node.js rejects both.

Sources

Last reviewed 20 October 2026.