chore: migrate workspace to TypeScript 7 (native compiler) - #41932
chore: migrate workspace to TypeScript 7 (native compiler)#41932KevLehman wants to merge 5 commits into
Conversation
Bump `typescript` to ~7.0.2 (the native compiler) across the monorepo and migrate everything TS7 no longer accepts. Builds on the chore/ts7-spike work: the typia/ttsc and ajv-normalization changes are ported from that branch onto current develop. Shared config (@rocket.chat/tsconfig): - target es5 -> es2022 (ES3/ES5 removed), moduleResolution node -> bundler (node10 removed; TS7 allows bundler with module commonjs, which TS5.9 didn't — the reason the spike had to keep the base config frozen) - types: [node, jest] — TS7 no longer auto-includes ambient @types (livechat additionally names webpack-env for module.hot/require.context) Per-package config fixes: - explicit rootDir wherever outDir is set (new TS5011 requirement); the cross-importing services (authorization-service, ddp-streamer) root at the repo root to keep the monorepo-mirrored dist layout the ee/apps Dockerfile overlays - baseUrl removed everywhere (TS5102): paths resolve relative to the tsconfig now, and meteor's "/*" mapping becomes "./*" (TS5090); paths entries added for tinykeys (no types condition in its exports map) and swiper/swiper-react - apps-engine and memo dual builds off the removed moduleResolution node; TS5.9-pinned packages that inherit the base (livechat, emitter) set module preserve, which both compilers accept with bundler resolution typia toolchain (ported from the spike, adapted): - core-typings and ui-kit emit via ttsc driving the tsgo binary; typia 9.7.2 (patched) -> 13.0.2 repo-wide (apps/meteor aligned, patch dropped); schema emit normalized for ajv/dist/2020 strict; OpenAPI doc at 3.1.0 - TS7 canary workflow + scripts/ts7-typecheck.sh, simplified: the shared config now carries the TS7 options, so the canary runs with no overrides Pinned to typescript ~5.9.3 (toolchain still needs the JS compiler API, which typescript@7 no longer ships): core-typings, ui-kit (typia TS5 path), eslint-config (typescript-eslint peer <6.1, with hoistingLimits so the lint toolchain nests beside its TS), message-parser, livechat (ts-node-loaded webpack configs), emitter, mp3-encoder (@rollup/plugin-typescript). Vestigial ts-jest devDeps dropped (suites run on @swc/jest); jest 30 loads jest.config.ts without ts-node on Node 22. Code fixes for TS7's sharper checking: - release-action: cast at the GitHub.plugin(throttling) boundary — the two bundled @octokit/core type trees no longer unify - MessageListProvider: annotate callbacks in conditional branches that no longer receive contextual types - saveCannedResponse: normalize optional tags to [] where the model type requires an array Validated locally: all workspace package + ee app builds green (the only failures in this environment are deno-cache steps — deno is not installed here); typia transform verified at runtime (199 component schemas); jest suites and eslint spot-checked green. TS7 canary: 72/73 tsconfigs green; apps/meteor remains red on a single root cause (legacy ChatEndpoints vs migrated chat route augmentation, TS2320 x140) tracked in docs/typescript-7-migration.md. Co-authored-by: Guilherme Gazzo <guilherme@gazzo.xyz> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014kBpQd6yQsB9qif313UvSQ
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
🦋 Changeset detectedLatest commit: 033bea5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- root: declare `globals` as a devDependency — the root eslint.config.mjs imports it directly and previously resolved it by hoisting accident; the eslint-config hoistingLimits change let a transitive globals@11 win the root spot, crashing every lint run using the root config (livechat, meteor) with the trailing-whitespace AudioWorkletGlobalScope bug - apps/meteor: jest.config.ts -> jest.config.mjs. The package declares "type": "commonjs", which disables Node's ESM syntax-detection fallback for .ts configs, and jest 30's .mts loader drops the `projects` array (suites then ran with default testMatch, no jsdom, no mappers). Plain ESM .mjs loads correctly: 305/305 jest suites + both mocha passes green - server-fetch: jest 29 -> ~30.2.0; jest 29 requires ts-node for TS configs, which crashes against the TS7 API - packages/apps: pin typescript ~5.9.3 (node --test suites load TS via ts-node; extensionless CJS-style relative imports rule out native type stripping) and pass TS_NODE_COMPILER_OPTIONS so ts-node (TS5.9) doesn't see the base config's bundler resolution abac unit-test failures reproduce locally only because mongodb-memory-server cannot download its binary through the sandbox proxy; CI restores it from cache. The remaining red CI check is the documented apps/meteor typecheck burn-down (TS2320 x140, single root cause). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014kBpQd6yQsB9qif313UvSQ
Pinning packages/apps to TS5.9 left its build:default on the shared base's commonjs + bundler pair, which TS5.9 rejects (TS5095). node16/node16 is accepted by both compilers and emits the same CommonJS dist; the TS7 canary stays green on this package. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014kBpQd6yQsB9qif313UvSQ
The spec drives two full reconnect cycles through real-time mock-socket handshakes (only the retry windows use fake timers); on a loaded CI runner that can exceed jest's default 5s, which is how it flaked on this PR's unit-test job. Passes consistently locally — give it explicit headroom. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014kBpQd6yQsB9qif313UvSQ
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #41932 +/- ##
========================================
Coverage 69.30% 69.30%
========================================
Files 4255 4255
Lines 168645 168696 +51
Branches 30083 30115 +32
========================================
+ Hits 116877 116923 +46
+ Misses 46589 46584 -5
- Partials 5179 5189 +10
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
The explicit parameter annotations added for TS7 pushed two lines past the print width; prettier (via eslint) flags them as errors in Code Lint. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014kBpQd6yQsB9qif313UvSQ
Proposed changes (including videos or screenshots)
Migrates the workspace default compiler to
typescript@~7.0.2(the native Go compiler) and adapts everything TS7 no longer accepts. Builds on thechore/ts7-spikework — the typia/ttsc and ajv-normalization changes are ported from that branch onto current develop.Shared config (
@rocket.chat/tsconfig)targetes5→es2022(ES3/ES5 removed) andmoduleResolutionnode→bundler(node10 removed). TS7 acceptsbundlerwithmodule: commonjs, which TS5.9 didn't — the reason the spike had to keep the base config frozen and inject CLI overrides instead.types: ["node", "jest"]— TS7 no longer auto-includes ambient@types/*(livechat additionally nameswebpack-envformodule.hot/require.context).Per-package config fixes
rootDirwhereveroutDiris set (new TS5011 requirement). The cross-importing services (authorization-service,ddp-streamer) root at the repo root, preserving the monorepo-mirrored dist layout theee/apps/Dockerfileoverlay expects.baseUrlremoved everywhere (TS5102);pathsvalues made relative (TS5090); mappings added fortinykeys(notypescondition in its exports map) andswiper/swiper-react.apps-engineandmemodual builds moved off the removedmoduleResolution: node; TS5.9-pinned packages inheriting the base (livechat,emitter) setmodule: "preserve", which both compilers accept withbundlerresolution.typia toolchain (ported from the spike, adapted)
core-typingsandui-kitemit viattscdriving the tsgo binary; typia 9.7.2 (patched) → 13.0.2 repo-wide (apps/meteoraligned, patch dropped); schema emit normalized forajv/dist/2020strict; OpenAPI doc reports 3.1.0.scripts/ts7-typecheck.sh, simplified: the shared config now carries the TS7 options, so the canary runs with no overrides.Pinned to
typescript@~5.9.3(their toolchain still links the JS compiler API, whichtypescript@7no longer ships):core-typings,ui-kit(typia TS5 path),eslint-config(typescript-eslint peer<6.1.0, withinstallConfig.hoistingLimitsso the lint toolchain nests beside its TS),message-parser,livechat(ts-node-loaded webpack configs),emitter,mp3-encoder(@rollup/plugin-typescript). Vestigialts-jestdevDeps dropped (suites run on@swc/jest); jest 30 loadsjest.config.tswithout ts-node on Node 22.Code fixes for TS7's sharper checking
release-action: cast at theGitHub.plugin(throttling)boundary — the two bundled@octokit/coretype trees no longer unify.MessageListProvider: annotate callbacks in conditional branches that no longer receive contextual types.saveCannedResponse: normalize optionaltagsto[]where the model type requires an array.Validation: all workspace package and ee service app builds green locally (the only local failures are deno-cache steps — deno isn't installed in the dev container); typia transform verified at runtime (199 component schemas); jest suites and eslint spot-checked green. TS7 canary: 72/73 tsconfigs green;
apps/meteorremains red on a single root cause (legacyChatEndpointsvs. the migrated chat route augmentation, TS2320 ×140), tracked with the other follow-ups indocs/typescript-7-migration.md. A changeset is included for the typia bump.Issue(s)
N/A — infrastructure migration; remaining work is tracked in
docs/typescript-7-migration.md.Steps to test or reproduce
yarn installyarn turbo run build --filter='./packages/*' --filter='./ee/packages/*' --filter='./ee/apps/*'bash scripts/ts7-typecheck.sh— prints the per-package TS7 canary tally (expected: 72/73 green,apps/meteorred on the chat-endpoints TS2320 only)yarn workspace @rocket.chat/ui-kit test,yarn workspace @rocket.chat/tools lintFurther comments
Draft on purpose: the goal is to switch emit/typecheck to the native compiler now while tools that still require the JS compiler API stay pinned to 5.9.3, each with a documented unpin condition (typescript-eslint, typedoc, rollup-plugin-typescript, ts-node). The
apps/meteorTS2320 burn-down belongs to the chat portion of the API endpoint migration (each/v1/chat.*route should end up declared exactly once), which is deliberately out of scope here. Seedocs/typescript-7-migration.mdfor the full status, pin rationale, and follow-ups.🤖 Generated with Claude Code
https://claude.ai/code/session_014kBpQd6yQsB9qif313UvSQ
Generated by Claude Code