Skip to content

fix(module): annotate the runtime plugins so declaration emit succeeds - #510

Merged
IgorShevchik merged 1 commit into
mainfrom
fix/module-build-declaration-types
Aug 29, 2026
Merged

fix(module): annotate the runtime plugins so declaration emit succeeds#510
IgorShevchik merged 1 commit into
mainfrom
fix/module-build-declaration-types

Conversation

@IgorShevchik

Copy link
Copy Markdown
Collaborator

Linked issue

Found while porting #509. Independent of it — this is a defect on main.

Type of change

  • Bug fix (a non-breaking change that fixes an issue)
  • Chore (updates to the build process or auxiliary tools and libraries)

Description

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 pluginsruntime/plugins/{colors,platform,ui-version}.ts 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> 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: a2d632cb builds clean, f288620b (#500) does not. Worth noting how nearly I got this wrong: my first pass counted TS2883 lines 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: ObjectPlugin plus export default plugin — so the emitted .d.ts no 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:coverage and test:module. typecheck is vue-tsc --noEmit — a different thing from the real declaration emit, and it passes while the build fails.

A Build the module step now runs between typecheck and the suite.

Verification

The fix and the guard were each checked by making them fail:

state pnpm build
annotations removed (i.e. main today) exit 1, twelve TS2883
as shipped exit 0

So 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

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Generated by Claude Code

`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.
@IgorShevchik
IgorShevchik merged commit 05f1e81 into main Aug 29, 2026
2 checks passed
@IgorShevchik
IgorShevchik deleted the fix/module-build-declaration-types branch August 29, 2026 05:41
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.

2 participants