Skip to content

chore: enable Nuxt typedPages and typescriptPlugin experimental flags - #2

Draft
jasonappah wants to merge 1 commit into
devfrom
chore/enable-nuxt-experimental-type-safety
Draft

jasonappah wants to merge 1 commit into
devfrom
chore/enable-nuxt-experimental-type-safety

Conversation

@jasonappah

@jasonappah jasonappah commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

experimental.typedPages

Generates a typed route map so route names and paths are checked.

typedPages

experimental.typescriptPlugin

Registers the @dxup/nuxt language-service plugin for editor DX.

typescriptPlugin

Not enabled: routeTypedFetch, strictRouteTypes

routeTypedFetch ·
strictRouteTypes

Both are merged into nuxt 4.x (PR #36238, 2026-09-02) but are in no published release — 4.5.2 shipped 2026-08-05, before the merge. Verified against freshly downloaded npm tarballs: the flags are absent from both @nuxt/schema@4.5.2 and the nuxt@4.5.2 runtime, and @nuxt/schema rejects them with TS2353. strictRouteTypes also requires routeTypedFetch.

nuxt.com serves /docs/4.x/ from the 4.x branch rather than the release tag, so it documents flags that are not yet installable. Worth enabling when the next 4.x ships.

Type checking: unchanged

typescript.typeCheck stays NODE_ENV !== 'production' — dev only, as on dev. Verified nuxt dev still reports type errors (ERROR(vue-tsc)), and docker build passes untouched.

Turning it on for nuxt build does fail the Docker deploy, and the fix is one line in the Dockerfile rather than anything in nuxt.config.ts: postinstall runs nuxt prepare during pnpm i, before COPY . . lands the app source, so .nuxt holds incomplete type artifacts and the in-build typecheck reports ~10 bogus errors (unresolved auto-imports, module types). Re-preparing after the source copy fixes it — confirmed by a real docker build where a deliberately introduced type error then failed the build.

Left out here to keep the deploy path untouched. Note CI already gates every PR with pnpm typecheck, so build-time typechecking is a redundant second gate rather than new coverage. Happy to split it into a follow-up.

Notes

  • typedPages enforces useRoute('name') but leaves navigateTo / router.push / <NuxtLink to> open to any string — vue-router types those as _LiteralUnion<KnownPaths, string>, so they get completion, not enforcement. Intentional upstream, not a misconfiguration.
  • .nuxtrc appears as untracked after running tests; it is generated by @nuxt/test-utils and is unrelated to this branch.

- typedPages: generated typed router (.nuxt/types/typed-router.d.ts) with
  the vue-router sfc-typed-router Volar plugin. useRoute("name") is now
  name-checked; path-based calls (navigateTo, router.push, <NuxtLink to>)
  get completion via _LiteralUnion, which keeps arbitrary strings allowed.
- typescriptPlugin: registers the @dxup/unimport and @dxup/nuxt language
  service plugins for editor DX (auto-import go-to-definition).

Not enabled: routeTypedFetch and strictRouteTypes. Both exist on the nuxt
`4.x` branch but are absent from every published version (4.5.2 is latest),
so the schema rejects them; strictRouteTypes also requires routeTypedFetch.
@jasonappah
jasonappah force-pushed the chore/enable-nuxt-experimental-type-safety branch from c2510c0 to 0520cee Compare September 26, 2026 15:44
@jasonappah jasonappah changed the title chore: enable Nuxt type-safety experimental flags + build-time typecheck chore: enable Nuxt typedPages and typescriptPlugin experimental flags Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant