chore: unify TypeScript on 6.0.3 across all five packages - #910
chore: unify TypeScript on 6.0.3 across all five packages#910serendipty01 wants to merge 1 commit into
Conversation
The repo ran four TypeScript versions at once (root 5.9.3, client 5.3.2, server 5.5.2, db/migrator 6.0.3), so type-checking was not the same check in each package. Unify all five on ^6.0.3 — the only target no package moves backwards to reach — and regenerate the affected lockfiles. Raise typescript-eslint to ^8.64.0 in server and client: the locked 8.57.2 peers typescript <6.0.0, which TS 6.0.3 violates. Two latent type bugs surface under TS 6 and are fixed here: - collections.ts: Array.isArray is typed `arg is any[]`, which cannot narrow a `readonly T[]` out of a union, widening the return type. Use a readonly-aware type guard. - networkingService: signWith takes an ArrayBuffer but was handed a Uint8Array. TS 6 made Uint8Array generic over its backing buffer, exposing the mismatch. Pass a real ArrayBuffer. Closes roostorg#908 Co-Authored-By: Claude <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks 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 |
There was a problem hiding this comment.
Pull request overview
This pull request standardizes the repository’s tooling on TypeScript ^6.0.3 across the root, client, and server packages (with db/migrator already on 6.0.3), and applies a small set of TS6-driven configuration and type-correctness fixes to keep builds/lints/tests green.
Changes:
- Bump TypeScript to
^6.0.3(root/client/server) and update client/server@typescript-eslint/*tooling to versions compatible with TS 6. - Update TS configs to satisfy TS 6 constraints (
server/tsconfig.jsonexplicittypes,client/tsconfig.jsonmoduleResolution changes and removal of deprecated option). - Fix TS 6-exposed type issues in a few code paths (HTTP signing buffer typing, readonly-array narrowing helper, and removal of now-redundant assertions/casts).
Reviewed changes
Copilot reviewed 12 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| package.json | Bumps root TypeScript devDependency to ^6.0.3. |
| package-lock.json | Regenerates root lockfile with TypeScript 6.0.3 resolved. |
| server/package.json | Bumps server TypeScript to ^6.0.3 and updates typescript-eslint tooling. |
| server/package-lock.json | Regenerates server lockfile for TS 6 + updated eslint tooling. |
| server/tsconfig.json | Explicitly declares types needed under TS 6 + NodeNext behavior changes. |
| server/services/networkingService/index.ts | Ensures signed request bodies are provided as a real ArrayBuffer (not a view) for TS 6-correct typing. |
| client/package.json | Bumps client TypeScript to ^6.0.3 and updates typescript-eslint tooling. |
| client/package-lock.json | Regenerates client lockfile for TS 6 + updated eslint tooling. |
| client/tsconfig.json | Switches to moduleResolution: "bundler" and removes deprecated/no-op downlevelIteration. |
| client/src/utils/collections.ts | Introduces a readonly-aware array type guard to preserve correct narrowing under TS 6. |
| client/src/webpages/dashboard/rules/rule_form/RuleFormReducers.test.ts | Removes now-unnecessary type import/casts after TS 6 tightening. |
| client/src/webpages/dashboard/rules/rule_form/RuleForm.tsx | Drops an unnecessary configuredParameters cast that TS 6 can validate directly. |
| client/src/webpages/dashboard/item_types/ItemTypePreview.tsx | Removes a now-unnecessary cast for the THREAD case when passing roles. |
| client/src/webpages/dashboard/mrt/manual_review_job/v2/ncmec/NCMECReviewUser.tsx | Removes an unnecessary type assertion on a default blur level value. |
| client/src/webpages/dashboard/investigation/ItemInvestigation.tsx | Documents/retains a TS6-required cast and adds a scoped eslint disable to prevent autofix breakage. |
Files not reviewed (2)
- client/package-lock.json: Generated file
- server/package-lock.json: Generated file
Context & Requests for Reviewers
Closes #908.
Sets all five
package.jsonfiles totypescript@^6.0.3and regenerates the root, client, and server lockfiles (db/migratoralready resolved 6.0.3, so their lockfiles are untouched).Three things the issue did not anticipate, all of which reviewers should look at:
1. typescript-eslint had to be upgraded (
^8.57.2→^8.64.0, server + client). The issue claimed typescript-eslint does not block this, citing its peer range>=4.8.4 <6.1.0. That is the range of the latest release; the version actually locked here was 8.57.2, whose peer is>=4.8.4 <6.0.0— TS 6.0.3 falls outside it.npm installdoes not fail on this, it installs anyway and marks the peerinvalid, so it would have shipped quietly. 8.64.0 still supports our eslint 9.2.
client/tsconfig.json:moduleResolution: "node"→"bundler". Required — the old value is the 2015-era CommonJS algorithm, incoherent when paired with"module": "esnext", and TS 6 hard-errors on the combination.3.
downlevelIterationremoved fromclient/tsconfig.json. Deprecated in TS 6 (TS5101) and a no-op here anyway, since the client targetsESNext. Removing it is preferable to silencing withignoreDeprecations.Two latent bugs TS 6 flushed out
Both are pre-existing on
mainand fixed here:client/src/utils/collections.ts—Array.isArray()is typedarg is any[], which cannot narrow areadonly T[]out of a union (readonly arrays aren't assignable toany[]). It leaked into theelsebranch and widenedarrayFromArrayOrSingleItem's return type. Replaced with a readonly-aware type guard.server/services/networkingService/index.ts—signWithis typed(data: ArrayBuffer)but was being handed aUint8ArrayfromTextEncoder.encode(). This was always a type lie that happened to work, because aUint8Arrayis a validBufferSourceat runtime. TS 6 madeUint8Arraygeneric over its backing buffer, which exposes it. Now passes a realArrayBuffer.One scoped lint disable
ItemInvestigation.tsx:407keeps its cast with an added@typescript-eslint/no-unnecessary-type-assertiondisable. This is a rule false positive:getFieldValueForRoleis generic, and the rule compares against the post-inference contextual parameter type — but removing the cast changes which generic instantiation is inferred, andtscthen fails.eslint --fixstripped this cast (and its existing disable comment) and broke the build;tscis the source of truth here. Five other assertions in this diff were genuinely redundant and were removed.Known cosmetic wart
tsconfck(pulled in byvite-tsconfig-paths) peerstypescript: ^5.0.0, so it reports as an invalid peer under TS 6. That peer is declared optional, sonpm cidoes not fail on it, and no published version admits TS 6 yet. Noting it so it isn't mistaken for a real break.Tests
All CI jobs run locally and green:
npm run prettier(check_formatting)docker compose run --rm codegen-checkbackend npm run lint/npm run buildclient npm run lint/npm run builddocker compose run --rm testAll four packages (
client,server,db,migrator) type-check clean under 6.0.3.(Optional) Rollout Plan
None — build-time only, no runtime or behaviour change.
Checklist
Only check items that apply to this PR; leave the rest unchecked.
If you changed anything user-facing (i.e. user interface or APIs):
Did you update the CHANGELOG.md and related docs?
If you changed
server/models/**/{ContentTypeModel,ActionModel,RuleModel,PolicyModel}.ts:Did you update the corresponding history tables and their triggers?
If you changed
db/src/scripts/**and usedCREATE TABLE,ADD COLUMN, orALTER COLUMN:Are as many columns marked
NOT NULLas possible? If some columns can sometimes be null depending on other columns, are thereCHECKconstraints capturing those relationships, and are these also reflected using unions in the associated Kysely types?If you added a new signal in
server/services/signalsService/signals/**:Did you classify every error case as a permanent error (
SignalPermanentError, no retry) or a normal error (retryable)? Any case where the signal can't determine a score should be aSignalPermanentError.