-
Notifications
You must be signed in to change notification settings - Fork 107
Description
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.jsonhasreferences) - 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
vue-tscoverwrite server imports with app imports nuxt#29263 —vue-tscoverwrite server imports with app imports (open)- Typecheck (vue-tsc) errors on all that is auto imported nuxt#28869 — Typecheck errors on all that is auto imported (closed, not planned)
- feat(kit,nuxt,schema): separate ts projects for node/app/nitro nuxt#30665 — PR that introduced separate TS projects for node/app/nitro
nuxi typecheckdoes not works with alias imports (server) #455 —nuxi typecheckdoes not work with alias imports (closed, duplicate)- Run typecheck for client *and* server with
nuxi typecheck#323 — Run typecheck for client and server withnuxi typecheck(closed, implemented)