…ished types (trpc#7748)
## Why
Prompted by [ghiscoding's list of lerna-lite
extras](lerna-lite/lerna-lite#1433 (comment)).
Comparing our releases before and after the lerna-lite switch turned up
these problems:
- **`main` CI is red.** Since the `v11.22.1` release commit, `pnpm
install --frozen-lockfile` fails with `ERR_PNPM_OUTDATED_LOCKFILE`
([run](https://github.com/trpc/trpc/actions/runs/40786499219)).
Unrelated PRs fail for the same reason, e.g. trpc#7747 fails 3 jobs.
- Each release bumps the `@trpc/*` versions in every `package.json`, but
`pnpm-lock.yaml` still records the old ones.
- Old lerna re-synced the lockfile and put it in every release commit
(`v11.17.0`–`v11.21.0`). lerna-lite doesn't, so the switch broke this.
- **Canaries point at the last stable release.** `@trpc/client@canary`
has peer `@trpc/server: 11.21.1`, so installing the canaries together
fails with `ERESOLVE`. Cause: our `prepack` hook (`scripts/version.ts`)
strips the prerelease suffix from every `@trpc/*` pin.
- **`npx @trpc/upgrade` and `trpc-openapi` don't run.** Since `11.19.0`,
`bin` points at `.js` files, but tsdown 0.23.0 builds `.mjs`. npm skips
the missing links.
- **Our type declarations break consumers who type-check them**
(`skipLibCheck: false`):
- Every `@trpc/client` user needs `@types/ws`, because client imports
`Encoder` from the server's ws adapter.
- The server ws adapter's types are broken against `@types/ws` 8.18,
which added ESM types.
- `next` deep imports don't resolve for ESM consumers using `nodenext`.
- The server adapters import `next`, `fastify`, `express`, `ws` and
`aws-lambda` types without declaring them.
- `@trpc/openapi/heyapi`'s CJS types fail on TypeScript 5.7, because
`@hey-api/openapi-ts` is ESM-only.
- **Nothing caught this, because the build fails silently.** An
unresolved type becomes `any` and the build still passes.
## What
- **Release tooling**
- `lerna.json`: `syncWorkspaceLock` re-syncs the lockfile in the release
commit, as old lerna did.
- `lerna.json`: `exact` keeps lerna-lite's version bumps exact, as old
lerna did. Without it the bumps become `^11.x.y`, then `version.ts`
re-pins them and the lockfile is stale again.
- `pnpm-lock.yaml`: fix the 15 stale workspace specifiers, which turns
`main` green.
- `scripts/version.ts`: pin each `@trpc/*` dep to that package's real
version. Stable releases are unchanged (openapi keeps `-alpha` on stable
deps). Canaries now depend on each other.
- **Bins:** `@trpc/upgrade` and `@trpc/openapi` point at `dist/*.mjs`.
- **Declarations** (runtime JS is byte-identical):
- client: import `Encoder` from
`@trpc/server/unstable-core-do-not-import`, which now re-exports it from
the ws-free `wsEncoder`.
- server ws adapter: import `WebSocket` and `WebSocketServer` from `ws`
by name, which works with both old and new `@types/ws`.
- server and next: add `.js` to type-only deep imports from `next`.
Runtime imports are unchanged.
- openapi: raise the `typescript` peer from `>=5.7.2 <7` to `>=5.8.2
<7`. 5.8.2 is the first release that lets the CJS types reference the
ESM-only `@hey-api/openapi-ts`.
- server: add optional peers `next`, `fastify`, `@types/express`,
`@types/ws` and `@types/aws-lambda`. Ranges are `*`: npm rejects an
installed optional peer that is outside its range, so narrower ranges
would break existing users' installs.
- **New CI job `verify-packed`** (`scripts/verify-packed.ts`): packs
every package, then checks it the way a consumer would.
- Every `bin`, `exports` and `types` target is in the tarball, and every
`bin` has a shebang.
- No `catalog:` or `workspace:` specifiers end up in dependencies.
- The tarballs install together with npm, which enforces peers.
- Every entry point type-checks with `skipLibCheck: false`, under
`nodenext` (ESM and CJS) and `bundler`. Core consumers (server and
client, no optional peers) are tested on TypeScript 5.7, 6 and 7. Full
consumers (everything) are tested on 5.8.2 and 6.
- Includes assertions on the types that silently became `any` before,
plus the hey-api types.
## Links
None. No docs or example changes.
## Alternatives considered
- **lerna-lite's `stripPackageKeys`** (tried, then dropped). lerna-lite
strips the keys *before* it runs our root `prepublish` build.
- Stripping `scripts` meant turbo found no `build` tasks, so the
tarballs shipped with no `dist/`.
- Stripping `devDependencies` removed turbo's build-order edges.
Client's declarations were then built before server's, and types became
`any`.
- **`--allow-peer-dependencies-update`:** wouldn't fix canaries, because
the `prepack` hook overwrites what lerna writes.
- **Narrow optional peer ranges** (e.g. `fastify@^5`): rejected, because
existing users on other versions would get install errors.
- **hey-api on TypeScript 5.7:** inline `import()` types with
`resolution-mode: "import"` keep 5.7 working, but cost lint exceptions
and harder-to-read source. Raising openapi's floor is simpler; it's an
alpha package.
- **Not done here:**
- lerna-lite dropped old lerna's `sha-` canary version prefix
(lerna/lerna#1118). A SHA that is all digits with a leading zero is
invalid semver, which happens about once every 690 commits. This should
be fixed upstream.
- `--generate-release-notes`.
## Testing
- **Old lerna vs this PR, same sources.** Both were published for real
to throwaway local registries (verdaccio), stable and canary.
- The release commits are line-for-line identical, lockfile included.
- All tarball contents are identical. Only `catalog:` specifiers differ:
old lerna publishes them literally, which is why `@trpc/[email protected]`
on npm depends on `typescript: "catalog:ts-api"`.
- **Release dry runs** of `release.yml`'s exact commands, built from
scratch:
- patch `11.22.1 → 11.22.2` and minor `→ 11.23.0` both bump correctly,
and openapi keeps `-alpha`.
- `pnpm install --frozen-lockfile` passes on the synced lockfile. The
unsynced lockfile fails with `ERR_PNPM_OUTDATED_LOCKFILE`.
- **Canary dry run:** every `@trpc/*` pin, peers included, is the canary
version. The published canaries fail `npm install` with `ERESOLVE`;
these install.
- **`verify-packed`** on this branch: all pass, with no exceptions. On
the commit before the fixes it fails: both missing bins, the `ws` leak
on TypeScript 5.7, 6 and 7, and the `next` imports.
- **Runtime JS:** all 122 files are byte-identical to the published
`11.22.1`.
- **Bins:** installed from the packed tarballs, `upgrade --help` and
`trpc-openapi --help` both run.
- **Repo checks:** `pnpm typecheck-packages` passes. Tests: 1346 of 1349
pass.
- The 2 `openapi` CLI tests timed out under load and pass when run
alone.
- `httpSubscriptionLink.memory` also fails locally on the unchanged code
(local Node 26; it passes in CI on Node 24).
- **Nothing was published:** npm dist-tags are unchanged, and no tags
were pushed.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Chores**
* Package releases now use exact version numbers and synchronize the
workspace lockfile. Internal package dependencies are pinned to their
recorded versions; dependencies without a recorded version are left
unchanged, with a warning.
* Added automated checks that validate package installation and verify
exported entry points and types across module-resolution scenarios.
* Updated package metadata and type references for compatibility with
current tooling and framework versions.
* Marked common adapter integrations as optional peer dependencies.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Alex / KATT <[email protected]>
Why
What
Links
Alternatives considered
Testing
manual screenshot...
Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit