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
Low Risk
Mostly dependency and test-config changes; runtime behavior in hashing is unchanged aside from type assertions, with noble fallbacks unchanged.
Overview
Aligns dev tooling with MetaMask/core’s TypeScript 6 + native TS 7 setup instead of a straight jump to TS 7, which would break Yarn’s
compat/typescriptpatch andtypescript-eslint.Tooling:
typescriptmoves from~5.3.3tonpm:@typescript/typescript6@^6.0.2(TS 6 API fortsc, ESLint, Jest, TypeDoc).@typescript/native(typescript@^7.0.2) is added alongside for the native compiler port. Yarn is bumped 4.16.0 → 4.17.1 so TS 7 installs cleanly. Jest/ts-jest getsignoreDeprecations: '6.0'formoduleResolution: 'Node'under TS 6.Source fixes for stricter TS 6/7 typings: In
hashing.ts,Uint8Arrayinputs tocrypto.subtle.digestare cast toBufferSourceat the three call sites so publicUint8ArrayAPIs stay unchanged. Inerrors.ts, an ESLint suppression documents the intentionalString(error)fallback ingetErrorMessage.Lockfile updates reflect the new TypeScript packages and Yarn bump.
Reviewed by Cursor Bugbot for commit fdb61df. Bugbot is set up for automated code reviews on this repo. Configure here.