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 toolchain changes; runtime behavior is unchanged aside from type assertions at existing crypto digest call sites.
Overview
Aligns dev tooling with MetaMask core’s dual TypeScript setup: primary
typescriptresolves to@typescript/typescript6@^6.0.2(fortsc,typescript-eslint,ts-jest, typedoc),@typescript/nativepins TS 7 for future use, and Yarn bumps to 4.17.1 so TS 7 installs don’t break on the oldcompat/typescriptpatch.Jest/ts-jest adds
ignoreDeprecations: '6.0'so test compilation can keep Node (node10) module resolution under TS 6 without deprecation noise.Two small source fixes for stricter TS 6/7 typing: in
hashing.ts,Uint8Arrayargs tocrypto.subtle.digestare cast toBufferSourceat the three call sites (signatures stayUint8Arrayfor callers). Inerrors.ts, an eslint-disable documents the intentionalString(error)fallback ingetErrorMessage.Reviewed by Cursor Bugbot for commit 65ff5cc. Bugbot is set up for automated code reviews on this repo. Configure here.