Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

tsconfig rejects allowImportingTsExtensions

Errorerror TS5023 pointing at allowImportingTsExtensions in tsconfig.json

Short answer

allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly. The error comes from one of two things: a TypeScript version older than 5.0 that does not know the option, or a config that still emits JavaScript.

  • Applies to TypeScript 5, Vite, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the TypeScript version the project actually runs, since a global tsc can differ from the one in node_modules.

    npx tsc --version
  2. 2Match what you see, then jump to its fix

    1. 1The compiler rejects the option name itself, on a project that has an older TypeScript installedThe installed TypeScript is older than 5.0Fix
    2. 2The compiler recognises the option but reports that it needs noEmit or emitDeclarationOnlyThe config still emits JavaScriptFix

What does the error look like?

  • error TS5023 pointing at allowImportingTsExtensions in tsconfig.json
  • An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly

Cause 1 of 2

The installed TypeScript is older than 5.0

1Check

The option appears in the TypeScript 5.0 release notes under resolution customization flags, so an older compiler does not recognise it. Check the version from the first step and the one in package.json.

npx tsc --version
npm ls typescript

2Fix

Upgrade TypeScript in the project and restart the editor's TypeScript server so it uses the workspace version.

npm install --save-dev typescript@latest

3Verify

The version should print 5.0 or higher and the unknown-option error should be gone.

npx tsc --version

Confirmed by typescriptlang.org

Did this fix it?

Cause 2 of 2

The config still emits JavaScript

1Check

The option is only allowed with noEmit or emitDeclarationOnly because those .ts import paths would not resolve in emitted JavaScript. Your bundler or runtime is expected to resolve them instead.

grep -n "noEmit\|emitDeclarationOnly\|allowImportingTsExtensions" tsconfig*.json

2Fix

Set noEmit to true next to the option when a bundler builds the code, so tsc only type-checks. Use emitDeclarationOnly instead if you need type declaration files.

{
  "compilerOptions": {
    "allowImportingTsExtensions": true,
    "noEmit": true
  }
}

3Verify

Run the type check; it should finish without the option error.

npx tsc --noEmit

Confirmed by typescriptlang.org

Did this fix it?

How do I stop it coming back?

  • Pin the TypeScript version in package.json so every machine and CI runner uses the same compiler.
  • Let the bundler build and keep tsc for checking only when you import files with .ts extensions.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.