fix(monty-js): publish the component facade declaration in dist

Merged
YI
2mo ago
+36-7

Fixes #982

scripts/build-component.mjs builds two declarations for the WASI component: Jco's raw one, and a small facade that re-exports the WIT types with export * from './interfaces/pydantic-monty-worker.js'. Only the facade is imported by the library — host.ts pulls DispatchResult and Request from it, transport.ts pulls ConfigureRequest — and only the facade was written into the TypeScript source tree. dist/ got Jco's version, which declares just ImportObject, Root and instantiate.

The shipped dist/worker/host.d.ts and dist/worker/transport.d.ts therefore import names that ./component/monty.component.js does not export. Against @pydantic/monty@1.1.0, import { Monty } from '@pydantic/monty/wasm' with skipLibCheck: false:

node_modules/@pydantic/monty/dist/worker/host.d.ts(1,15): error TS2305: Module '"./component/monty.component.js"' has no exported member 'DispatchResult'.
node_modules/@pydantic/monty/dist/worker/host.d.ts(1,58): error TS2305: Module '"./component/monty.component.js"' has no exported member 'Request'.
node_modules/@pydantic/monty/dist/worker/transport.d.ts(3,15): error TS2305: Module '"./component/monty.component.js"' has no exported member 'ConfigureRequest'.

The fix

  • build-component.mjs writes the facade into dist/ as well, replacing Jco's monty.component.d.ts (nothing imports it). Both copies are byte-identical, and the file list Jco returns is otherwise unchanged.
  • make check-wasm-types gains npm run check:dist-types: a skipLibCheck: false pass over the built dist/worker/index.d.ts, in a new tsconfig.dist.json. The package's own tsconfig.json builds from ts, so it can never catch this. I confirmed the new check reports the three TS2305 errors against the published 1.1.0 dist and is clean against a dist built with this change.

npm run lint (oxlint + tsc -p __test__/tsconfig.json) and prettier --check are clean.


Summary by cubic

Fixes #982: consumers of @pydantic/monty/wasm no longer hit TS2305 errors on DispatchResult, Request, and ConfigureRequest when compiling with skipLibCheck: false.

Previously the published dist/worker/component/monty.component.d.ts was Jco's generated declaration, not the facade that re-exports the WIT types, so host.d.ts and transport.d.ts shipped dangling imports.

  • Copies the facade into dist in place of Jco's declaration, which nothing imports.
  • Adds npm run check:dist-types, a strict consumer-side pass over the built declarations, run by make check-wasm-types.