Repository navigation
Conversation
…enext The package is "type": "module", and the build emitted per-file .d.ts files with extensionless relative imports (from './client'). TypeScript cannot resolve those under moduleResolution node16 or nodenext, so every export silently became `any` for consumers using those modes. CommonJS consumers were also handed the ESM declarations. - tsup now bundles declarations into dist/index.d.ts (ESM) and dist/index.d.cts (CommonJS); the separate tsc declaration step and tsconfig.types.json are removed. ignoreDeprecations is set for the declaration build only, because tsup's bundler sets baseUrl, which TypeScript 6 deprecates. - The exports map points the import and require conditions at their own declaration files. - The packed-tarball smoke test now type-checks a consumer under nodenext, node16 (ESM and CommonJS) and bundler, with @ts-expect-error guards that fail if the exports resolve to `any`. - CI runs the smoke test on pull requests, not only at release. Fixes #22 Revert check: with package.json and tsup.config.ts restored from main and the package rebuilt, `npm run test:smoke` exits 1 with TS2834 ("Relative import paths need explicit file extensions...") on dist/index.d.ts and consumer.cts(3,1): error TS2578: Unused '@ts-expect-error' directive. With the fix it passes all three resolution modes. Checks run locally (macOS, Node 22.16.0, TypeScript 6.0.3): npm run typecheck, npm run lint, npm run test:unit (315/315), npm run build, npm run test:smoke. Not run: CI matrix (Linux, Windows) - pending on this push. Not run: TypeScript 7 - the repository pins ^6.0.3. Not run: arethetypeswrong - not installed in the repository.
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.
Summary
The package is
"type": "module", and the build emitted per-file.d.tsfiles with extensionless relative imports (from './client'). TypeScript can't resolve those undermoduleResolution: node16ornodenext, so every export silently becameanyfor consumers using those modes. CommonJS consumers were also handed the ESM declarations.Type of Change
Changes Made
tsup.config.ts: bundle declarations intodist/index.d.ts(ESM) anddist/index.d.cts(CommonJS).ignoreDeprecations: '6.0'is set for the declaration build only, because tsup's declaration bundler setsbaseUrl, which TypeScript 6 deprecates. The project tsconfig is unchanged.package.json: theimportandrequireconditions each point at their own declaration file; the separatetsc --project tsconfig.types.jsonbuild step is removed.tsconfig.types.json: removed (no longer used).tools/smoke-test.mjs: type-checks a consumer against the packed tarball undernodenext,node16(ESM and CommonJS) andbundler, withskipLibCheck: false.@ts-expect-errorguards fail if the exports resolve toany..github/workflows/ci.yml: run the smoke test on pull requests (it previously ran only at release) and check thatdist/index.d.ctsexists.CHANGELOG.md: Unreleased → Fixed entry.Related Issues
Fixes #22
Testing
Revert check: with
package.jsonandtsup.config.tsrestored frommainand the package rebuilt,npm run test:smokeexits 1 withTS2834("Relative import paths need explicit file extensions...") ondist/index.d.ts, plusconsumer.cts(3,1): error TS2578: Unused '@ts-expect-error' directive.(the silentany). With the fix it passes all three resolution modes.Run locally (macOS, Node 22.16.0, TypeScript 6.0.3):
npm run typecheck✅npm run lint✅npm run test:unit✅ 315/315npm run build✅npm run test:smoke✅Not run: CI matrix (Linux, Windows) — pending on this PR.
Not run: TypeScript 7 — the repository pins
^6.0.3.Not run: arethetypeswrong — not installed in the repository.
Notes for reviewers
dist/index.d.tsrather thansrc/..jsextensions on the relative imports insrc/andmoduleResolution: nodenext).