Description
nuxt typecheck uses vue-tsc -b --noEmit when the root tsconfig.json contains references (which is the default in Nuxt 4 since PR nuxt/nuxt#30665). However, vue-tsc in build mode (-b) does not properly resolve declare global type declarations from .nuxt/types/imports.d.ts across TypeScript project references.
This results in hundreds of false-positive "Cannot find name" errors for all Nuxt auto-imports (ref, computed, useRoute, navigateTo, definePageMeta, etc.).
Reproduction
- Create a fresh Nuxt 4 project (or any Nuxt project where
tsconfig.json has references)
- Run
nuxt typecheck
- Observe hundreds of
TS2304: Cannot find name '...' errors on all auto-imported items
Expected behavior
nuxt typecheck should report only real type errors.
Actual behavior
vue-tsc -b --noEmit reports ~900 errors, most of which are false-positive "Cannot find name" errors on auto-imports.
Running vue-tsc --noEmit -p .nuxt/tsconfig.json (without -b) correctly reports only ~40 real errors.
Root cause
In packages/nuxi/src/commands/typecheck.ts:
const supportsProjects = !!(tsconfig.references?.length)
const typeCheckArgs = supportsProjects ? ['-b', '--noEmit'] : ['--noEmit']
When -b is used, vue-tsc treats each project reference as an isolated compilation unit. The declare global block in .nuxt/types/imports.d.ts (which declares all auto-imports) is not visible across project boundaries, causing every auto-imported symbol to be unresolved.
Workaround
Replace nuxt typecheck with a direct vue-tsc invocation in package.json:
"typecheck": "nuxt prepare && vue-tsc --noEmit -p .nuxt/tsconfig.json"
This bypasses the -b flag while still pointing to the correct tsconfig that includes the auto-import declarations.
Environment
- Nuxt: 4.3.0
- @nuxt/cli: 3.32.0
- vue-tsc: 2.2.12
- TypeScript: 5.9.3
- Package manager: bun
Related issues
Description
nuxt typecheckusesvue-tsc -b --noEmitwhen the roottsconfig.jsoncontainsreferences(which is the default in Nuxt 4 since PR nuxt/nuxt#30665). However,vue-tscin build mode (-b) does not properly resolvedeclare globaltype declarations from.nuxt/types/imports.d.tsacross TypeScript project references.This results in hundreds of false-positive "Cannot find name" errors for all Nuxt auto-imports (
ref,computed,useRoute,navigateTo,definePageMeta, etc.).Reproduction
tsconfig.jsonhasreferences)nuxt typecheckTS2304: Cannot find name '...'errors on all auto-imported itemsExpected behavior
nuxt typecheckshould report only real type errors.Actual behavior
vue-tsc -b --noEmitreports ~900 errors, most of which are false-positive "Cannot find name" errors on auto-imports.Running
vue-tsc --noEmit -p .nuxt/tsconfig.json(without-b) correctly reports only ~40 real errors.Root cause
In
packages/nuxi/src/commands/typecheck.ts:When
-bis used,vue-tsctreats each project reference as an isolated compilation unit. Thedeclare globalblock in.nuxt/types/imports.d.ts(which declares all auto-imports) is not visible across project boundaries, causing every auto-imported symbol to be unresolved.Workaround
Replace
nuxt typecheckwith a directvue-tscinvocation inpackage.json:This bypasses the
-bflag while still pointing to the correct tsconfig that includes the auto-import declarations.Environment
Related issues
vue-tscoverwrite server imports with app imports nuxt#29263 —vue-tscoverwrite server imports with app imports (open)nuxi typecheckdoes not works with alias imports (server) #455 —nuxi typecheckdoes not work with alias imports (closed, duplicate)nuxi typecheck#323 — Run typecheck for client and server withnuxi typecheck(closed, implemented)