fix(types): wire RouteNamedMap via generated routes.d.ts#2700
Conversation
Move the `TypesConfig.RouteNamedMap` augmentation out of `vue-router-auto-routes.d.mts` and into the generated `routes.d.ts` emitted by the unplugin. The previous wiring only activated when the project actually imported `vue-router/auto-routes`, so resolver-only setups (`vue-router/auto-resolver`) collapsed `RouteMap` to `RouteMapGeneric` and `useRoute()` returned untyped params. The generated d.ts is always part of the user's tsconfig `include`, so the augmentation now applies regardless of which virtual module the user imports. Closes #2696
✅ Deploy Preview for vue-router canceled.
|
commit: |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe PR introduces a ChangesRouteNamedMap Type Wiring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
[skip ci]
Summary
TypesConfig.RouteNamedMapaugmentation out ofvue-router-auto-routes.d.mtsand into the generatedroutes.d.ts. The previous wiring only fired when the project actually importedvue-router/auto-routes, so resolver-only setups (vue-router/auto-resolver) silently fell back toRouteMapGenericanduseRoute()lost typed params..d.tsis always part of the user's tsconfiginclude, so the augmentation now applies regardless of which virtual module the user imports (or even if they only rely on the Volar plugins).The generated block now looks like:
The
RouteNamedMapinterface body still lives insidedeclare module 'vue-router/auto-routes'in the generated file, so existing user augmentations of that interface keep working.Test plan
generateDTS.spec.tsassertingRouteNamedMapis wired through thevue-routeraugmentation block (fails onmain, passes here)pnpm exec vitest runinpackages/router— full suite (1563 tests) green, snapshot updatedpnpm types(vue-tsc) inpackages/playground-file-basedwithsrc/router/classic.ts(the onlyauto-routesconsumer) removed — typed routes still resolve and the@ts-expect-errorassertions inresolver.tsstill triggerRouteNamedMapfromvue-router/auto-routesstill resolve (interface is still exported there)Summary by CodeRabbit
New Features
Tests