fix(module): annotate the runtime plugins so declaration emit succeeds - #510
Merged
Conversation
`pnpm build` has been failing on `main` since #500, with twelve TS2883 errors: src/runtime/plugins/colors.ts(32,1): error TS2883: The inferred type of 'default' cannot be named without a reference to 'ObjectPlugin' from '.pnpm/nuxt@4.5.2_c8b663…/node_modules/nuxt/app'. This is likely not portable. A type annotation is necessary. **Cause.** Not the plugins — they have not changed since #405. #500 added `@vitest/coverage-v8`, which reshuffled 711 lines of the lockfile and with them the `nuxt@4.5.2_<peers>` hash. Declaration emit then had no portable name for the inferred plugin type. Bisected with exit codes across seven commits: `a2d632cb` builds, `f288620b` (#500) does not. **Fix.** Annotate the three exports explicitly — `const plugin: ObjectPlugin` plus `export default plugin` — which makes the emitted `.d.ts` independent of how the peer graph happens to resolve. **And the reason it went unnoticed for three days: CI never built the module.** It runs `dev:prepare`, `lint`, `typecheck`, `test:coverage` and `test:module`; `typecheck` is `vue-tsc --noEmit`, which is a different thing from the real declaration emit and passes while the build fails. A `Build the module` step now runs between typecheck and the suite. Verified by removing the annotations again with the CI step in place: the build exits 1, the twelve errors return. With them, exit 0. `lint` · `typecheck` · `build` · `test` (7472 passed, 6 skipped, 318 files) — green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue
Found while porting #509. Independent of it — this is a defect on
main.Type of change
Description
pnpm buildhas been failing onmainsince #500, with twelveTS2883errors:Cause
Not the plugins —
runtime/plugins/{colors,platform,ui-version}.tshave not changed since #405.#500 added
@vitest/coverage-v8, which reshuffled 711 lines of the lockfile and with them thenuxt@4.5.2_<peers>resolution hash. Declaration emit then had no portable name for the inferred plugin type — which is exactly what the error names.Bisected with exit codes across seven commits:
a2d632cbbuilds clean,f288620b(#500) does not. Worth noting how nearly I got this wrong: my first pass countedTS2883lines instead of checking exit status, which reported "0 errors" for commits where the build had failed for an unrelated reason. Those results were discarded.Fix
Annotate the three exports explicitly —
const plugin: ObjectPluginplusexport default plugin— so the emitted.d.tsno longer depends on how the peer graph happens to resolve. Each carries a short note saying why the annotation is not decoration.Why it went unnoticed for three days
CI never built the module. It runs
dev:prepare,lint,typecheck,test:coverageandtest:module.typecheckisvue-tsc --noEmit— a different thing from the real declaration emit, and it passes while the build fails.A
Build the modulestep now runs between typecheck and the suite.Verification
The fix and the guard were each checked by making them fail:
pnpm buildmaintoday)TS2883So the new CI step demonstrably goes red on the very breakage it is being added for, rather than being assumed to.
Gate with
CI=true:lint·typecheck·build·test(7472 passed, 6 skipped, 318 files) — green.Checklist
Generated by Claude Code