tsconfig rejects allowImportingTsExtensions
error TS5023 pointing at allowImportingTsExtensions in tsconfig.jsonShort 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.
Fix it fast
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 --version2Match what you see, then jump to its fix
What does the error look like?
error TS5023 pointing at allowImportingTsExtensions in tsconfig.jsonAn 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 typescript2Fix
Upgrade TypeScript in the project and restart the editor's TypeScript server so it uses the workspace version.
npm install --save-dev typescript@latest3Verify
The version should print 5.0 or higher and the unknown-option error should be gone.
npx tsc --versionConfirmed by typescriptlang.org
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*.json2Fix
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 --noEmitConfirmed by typescriptlang.org
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Web apps
Cypress refuses to start with 'Your configFile is invalid'
Your configFile threw an error from: /path/to/cypress.config.ts
Cypress could not load cypress.config.js or .ts, or found something wrong in it.
5 causes, each with a fixWeb apps
ESLint cannot decide which copy of the @typescript-eslint plugin to use
The message lists two file paths for the same plugin, each with the name of the config that loaded it
ESLint found the same plugin at two different file paths and will not pick one.
3 causes, each with a fixWeb apps
ESLint says it cannot resolve a path to a module that does exist
Unable to resolve path to module 'react'. import/no-unresolved
import/no-unresolved fails when eslint-plugin-import cannot find the file or package on disk with its resolver.
4 causes, each with a fixWeb apps
ESLint was configured to run using parserOptions.project, but the file is not in the TSConfig
However, that TSConfig does not include this file
Type-aware linting needs every linted file to belong to a TypeScript project.
4 causes, each with a fixWeb apps
Upgrading to Next.js 16: middleware becomes proxy, and the other things that break
Missing Required default.js for Parallel Route
Next.js 16 renames middleware.ts to proxy.ts and its exported function to proxy.
6 causes, each with a fixWeb apps
TypeScript cannot resolve import './globals.css' in Next.js
ts(2882)
TypeScript now checks imports like import './globals.css' when noUncheckedSideEffectImports is on, and it finds no type for a CSS file.
2 causes, each with a fix