Mirrors MetaMask/core#9518.
packageManager yarn@4.16.0 -> yarn@4.17.1
typescript ~5.3.3 -> npm:@typescript/typescript6@^6.0.2
@typescript/native added -> npm:typescript@^7.0.2
A plain bump to TypeScript 7 does not work, for two separate reasons found
by trying it:
Yarn 4.16.0 auto applies a builtin compat/typescript patch that targets
lib/_tsc.js. That file does not exist in 7, which is the native port with
a different layout, so the install fails outright. Yarn 4.17.1 fixes it,
which is why core bumps the package manager in the same PR.
typescript-eslint then hard errors on TS 7: "typescript-eslint does not
support TS 7.0 ... to run typescript-eslint using the TS 6 API". Tracked
upstream at typescript-eslint/typescript-eslint#10940.
So the aliases are not incidental. Resolving `typescript` to the TS 6 API is
what keeps typescript-eslint, ts-jest and typedoc working, while TS 7 sits
alongside as @typescript/native. Compilation runs on 6.0.3; nothing in the
toolchain can consume 7 yet.
Two source changes were needed, both from Uint8Array becoming generic:
hashing.ts crypto.subtle.digest takes a BufferSource, which no longer
accepts a plain Uint8Array because the buffer could be a
SharedArrayBuffer. Asserted at the three call sites rather
than narrowing the exported signatures, which would break
callers.
errors.ts no-base-to-string now sees that String(error) can produce
"[object Object]". That is the documented fallback of
getErrorMessage, so it is suppressed with a reason.
Core's third entry, @typescript/old, is a patched 6.0.3 pointing at a patch
file in core's own .yarn/patches. Nothing here needs it and its contents are
not reproducible from outside that repo, so it is left out.
Top of stack #315, on #324. Mirrors MetaMask/core#9518.
packageManageryarn@4.16.0yarn@4.17.1typescript~5.3.3npm:@typescript/typescript6@^6.0.2@typescript/nativenpm:typescript@^7.0.2Why not just bump to TypeScript 7
I tried that first. It fails for two independent reasons:
1. Yarn. 4.16.0 auto-applies a builtin
compat/typescriptpatch targetinglib/_tsc.js. That file doesn't exist in TS 7, which is the native port with a different layout, so the install fails outright:Yarn 4.17.1 resolves it, which is why core bumps the package manager in the same PR.
2. typescript-eslint. With the install fixed, linting then hard-errors:
Tracked upstream at typescript-eslint#10940.
So the aliases aren't incidental overhead. Resolving
typescriptto the TS 6 API is what keepstypescript-eslint,ts-jestandtypedocworking, while TS 7 sits alongside as@typescript/native. Compilation runs on 6.0.3; nothing in the toolchain can consume 7 yet. Same position core is in.Source changes
Two, both from
Uint8Arraybecoming generic:hashing.ts—crypto.subtle.digesttakes aBufferSource, which no longer accepts a plainUint8Arraybecause the buffer could be aSharedArrayBuffer. Asserted at the three call sites rather than narrowing the exported signatures, which would break callers.errors.ts—no-base-to-stringnow sees thatString(error)can produce[object Object]. That is the documented fallback ofgetErrorMessage, so it's suppressed with a reason.Not carried over
Core's third entry,
@typescript/old, is a patched 6.0.3 pointing at a patch file in core's own.yarn/patches. Nothing here needs it and its contents aren't reproducible from outside that repo.Note
Medium Risk
Toolchain and lockfile changes affect build, lint, and tests repo-wide; hashing edits are compile-time assertions only with unchanged runtime behavior.
Overview
Aligns the repo with MetaMask core’s dual TypeScript setup: primary
typescriptresolves to@typescript/typescript6@^6.0.2(TS 6 API fortsc, eslint, jest, typedoc),@typescript/nativeadds TS 7 alongside, and Yarn bumps to 4.17.1 so installs don’t break on TS 7’s layout.Jest/ts-jest sets
ignoreDeprecations: '6.0'so test compilation can keepmoduleResolution: 'Node'under TS 6 without deprecation noise.Two small source fixes for stricter TS 6/7 typing:
hashing.tscastsUint8ArraytoBufferSourceatcrypto.subtle.digestcall sites (keeps publicUint8Arraysignatures);errors.tsdocuments and suppressesno-base-to-stringon the intentionalString(error)fallback ingetErrorMessage.Reviewed by Cursor Bugbot for commit 9962b7e. Bugbot is set up for automated code reviews on this repo. Configure here.