From d7f4009962cad9b448777581635ebe06b15e5b8b Mon Sep 17 00:00:00 2001 From: Salah-Eddine Saakoun Date: Sat, 5 Sep 2026 12:50:54 +0200 Subject: [PATCH 1/2] chore: adopt core's TypeScript 6 and 7 arrangement 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. --- package.json | 5 +- src/errors.ts | 1 + src/hashing.ts | 11 ++- yarn.lock | 254 ++++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 251 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 64f2b351..61a9ebea 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,7 @@ "@types/node": "^22.13.14", "@types/semver": "^7", "@types/uuid": "^9.0.8", + "@typescript/native": "npm:typescript@^7.0.2", "depcheck": "^1.4.7", "eslint": "^9.39.1", "eslint-config-prettier": "^9.1.0", @@ -98,7 +99,7 @@ "ts-node": "^10.7.0", "tsd": "^0.29.0", "typedoc": "^0.25.13", - "typescript": "~5.3.3", + "typescript": "npm:@typescript/typescript6@^6.0.2", "typescript-eslint": "^8.48.0", "web3": "^4.16.0" }, @@ -111,7 +112,7 @@ "engines": { "node": "^22.14.0 || ^24" }, - "packageManager": "yarn@4.16.0", + "packageManager": "yarn@4.17.1+sha256.471ffb15e0523663865bbf46a69e7d157ecf532412eb436c48dfab6e3f2abe88", "lavamoat": { "allowScripts": { "@lavamoat/preinstall-always-fail": false, diff --git a/src/errors.ts b/src/errors.ts index 6c2a8e9e..6ae07f0f 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -71,6 +71,7 @@ export function getErrorMessage(error: unknown): string { return ''; } + // eslint-disable-next-line @typescript-eslint/no-base-to-string -- Stringifying an arbitrary value is the documented fallback here, so `[object Object]` is an accepted result rather than a mistake. return String(error); } diff --git a/src/hashing.ts b/src/hashing.ts index 0405f64f..2d8185c4 100644 --- a/src/hashing.ts +++ b/src/hashing.ts @@ -12,6 +12,11 @@ import { * @param bytes - A byte array. * @returns The SHA-256 hash as a byte array. */ +// `crypto.subtle.digest` takes a `BufferSource`, which TypeScript 7 will not +// accept a plain `Uint8Array` for: it is now generic over the buffer, so it +// could be backed by a `SharedArrayBuffer`. Runtimes accept those, and +// narrowing the exported signatures below would break callers, so the +// assertion is kept at the call sites. export async function sha256(bytes: Uint8Array): Promise { // Use crypto.subtle.digest whenever possible as it is faster. if ( @@ -20,7 +25,7 @@ export async function sha256(bytes: Uint8Array): Promise { globalThis.crypto.subtle?.digest ) { return new Uint8Array( - await globalThis.crypto.subtle.digest('SHA-256', bytes), + await globalThis.crypto.subtle.digest('SHA-256', bytes as BufferSource), ); } return nobleSha256(bytes); @@ -42,7 +47,7 @@ export async function sha512(bytes: Uint8Array): Promise { globalThis.crypto.subtle?.digest ) { return new Uint8Array( - await globalThis.crypto.subtle.digest('SHA-512', bytes), + await globalThis.crypto.subtle.digest('SHA-512', bytes as BufferSource), ); } return nobleSha512(bytes); @@ -64,7 +69,7 @@ export async function sha384(bytes: Uint8Array): Promise { globalThis.crypto.subtle?.digest ) { return new Uint8Array( - await globalThis.crypto.subtle.digest('SHA-384', bytes), + await globalThis.crypto.subtle.digest('SHA-384', bytes as BufferSource), ); } return nobleSha384(bytes); diff --git a/yarn.lock b/yarn.lock index 92a8d8f2..6870b03e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1204,6 +1204,7 @@ __metadata: "@types/node": "npm:^22.13.14" "@types/semver": "npm:^7" "@types/uuid": "npm:^9.0.8" + "@typescript/native": "npm:typescript@^7.0.2" debug: "npm:^4.3.4" depcheck: "npm:^1.4.7" eslint: "npm:^9.39.1" @@ -1229,7 +1230,7 @@ __metadata: ts-node: "npm:^10.7.0" tsd: "npm:^0.29.0" typedoc: "npm:^0.25.13" - typescript: "npm:~5.3.3" + typescript: "npm:@typescript/typescript6@^6.0.2" typescript-eslint: "npm:^8.48.0" uuid: "npm:^9.0.1" web3: "npm:^4.16.0" @@ -2288,6 +2289,227 @@ __metadata: languageName: node linkType: hard +"@typescript/native@npm:typescript@^7.0.2": + version: 7.0.2 + resolution: "typescript@npm:7.0.2" + dependencies: + "@typescript/typescript-aix-ppc64": "npm:7.0.2" + "@typescript/typescript-darwin-arm64": "npm:7.0.2" + "@typescript/typescript-darwin-x64": "npm:7.0.2" + "@typescript/typescript-freebsd-arm64": "npm:7.0.2" + "@typescript/typescript-freebsd-x64": "npm:7.0.2" + "@typescript/typescript-linux-arm": "npm:7.0.2" + "@typescript/typescript-linux-arm64": "npm:7.0.2" + "@typescript/typescript-linux-loong64": "npm:7.0.2" + "@typescript/typescript-linux-mips64el": "npm:7.0.2" + "@typescript/typescript-linux-ppc64": "npm:7.0.2" + "@typescript/typescript-linux-riscv64": "npm:7.0.2" + "@typescript/typescript-linux-s390x": "npm:7.0.2" + "@typescript/typescript-linux-x64": "npm:7.0.2" + "@typescript/typescript-netbsd-arm64": "npm:7.0.2" + "@typescript/typescript-netbsd-x64": "npm:7.0.2" + "@typescript/typescript-openbsd-arm64": "npm:7.0.2" + "@typescript/typescript-openbsd-x64": "npm:7.0.2" + "@typescript/typescript-sunos-x64": "npm:7.0.2" + "@typescript/typescript-win32-arm64": "npm:7.0.2" + "@typescript/typescript-win32-x64": "npm:7.0.2" + dependenciesMeta: + "@typescript/typescript-aix-ppc64": + optional: true + "@typescript/typescript-darwin-arm64": + optional: true + "@typescript/typescript-darwin-x64": + optional: true + "@typescript/typescript-freebsd-arm64": + optional: true + "@typescript/typescript-freebsd-x64": + optional: true + "@typescript/typescript-linux-arm": + optional: true + "@typescript/typescript-linux-arm64": + optional: true + "@typescript/typescript-linux-loong64": + optional: true + "@typescript/typescript-linux-mips64el": + optional: true + "@typescript/typescript-linux-ppc64": + optional: true + "@typescript/typescript-linux-riscv64": + optional: true + "@typescript/typescript-linux-s390x": + optional: true + "@typescript/typescript-linux-x64": + optional: true + "@typescript/typescript-netbsd-arm64": + optional: true + "@typescript/typescript-netbsd-x64": + optional: true + "@typescript/typescript-openbsd-arm64": + optional: true + "@typescript/typescript-openbsd-x64": + optional: true + "@typescript/typescript-sunos-x64": + optional: true + "@typescript/typescript-win32-arm64": + optional: true + "@typescript/typescript-win32-x64": + optional: true + bin: + tsc: bin/tsc + checksum: 10/b0179005349b43dc1febb35c4e79162cdf89b84eae60f6deac142429109041e07582e69a6aacf5a897e085869686d4512ea444a10acf5b5aa2b60910f82a19ca + languageName: node + linkType: hard + +"@typescript/old@npm:typescript@^6": + version: 6.0.3 + resolution: "typescript@npm:6.0.3" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10/0ef2357a4cffd916b52b683a021cdab0f81eea4e9aa35f2d254581c9a5106da02224e3392e1b0ed42b7a48f80c966e5f52b8e1a27941fa0523c1705a9c2e0330 + languageName: node + linkType: hard + +"@typescript/typescript-aix-ppc64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-aix-ppc64@npm:7.0.2" + conditions: os=aix & cpu=ppc64 + languageName: node + linkType: hard + +"@typescript/typescript-darwin-arm64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-darwin-arm64@npm:7.0.2" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + +"@typescript/typescript-darwin-x64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-darwin-x64@npm:7.0.2" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"@typescript/typescript-freebsd-arm64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-freebsd-arm64@npm:7.0.2" + conditions: os=freebsd & cpu=arm64 + languageName: node + linkType: hard + +"@typescript/typescript-freebsd-x64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-freebsd-x64@npm:7.0.2" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + +"@typescript/typescript-linux-arm64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-linux-arm64@npm:7.0.2" + conditions: os=linux & cpu=arm64 + languageName: node + linkType: hard + +"@typescript/typescript-linux-arm@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-linux-arm@npm:7.0.2" + conditions: os=linux & cpu=arm + languageName: node + linkType: hard + +"@typescript/typescript-linux-loong64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-linux-loong64@npm:7.0.2" + conditions: os=linux & cpu=loong64 + languageName: node + linkType: hard + +"@typescript/typescript-linux-mips64el@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-linux-mips64el@npm:7.0.2" + conditions: os=linux & cpu=mips64el + languageName: node + linkType: hard + +"@typescript/typescript-linux-ppc64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-linux-ppc64@npm:7.0.2" + conditions: os=linux & cpu=ppc64 + languageName: node + linkType: hard + +"@typescript/typescript-linux-riscv64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-linux-riscv64@npm:7.0.2" + conditions: os=linux & cpu=riscv64 + languageName: node + linkType: hard + +"@typescript/typescript-linux-s390x@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-linux-s390x@npm:7.0.2" + conditions: os=linux & cpu=s390x + languageName: node + linkType: hard + +"@typescript/typescript-linux-x64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-linux-x64@npm:7.0.2" + conditions: os=linux & cpu=x64 + languageName: node + linkType: hard + +"@typescript/typescript-netbsd-arm64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-netbsd-arm64@npm:7.0.2" + conditions: os=netbsd & cpu=arm64 + languageName: node + linkType: hard + +"@typescript/typescript-netbsd-x64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-netbsd-x64@npm:7.0.2" + conditions: os=netbsd & cpu=x64 + languageName: node + linkType: hard + +"@typescript/typescript-openbsd-arm64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-openbsd-arm64@npm:7.0.2" + conditions: os=openbsd & cpu=arm64 + languageName: node + linkType: hard + +"@typescript/typescript-openbsd-x64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-openbsd-x64@npm:7.0.2" + conditions: os=openbsd & cpu=x64 + languageName: node + linkType: hard + +"@typescript/typescript-sunos-x64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-sunos-x64@npm:7.0.2" + conditions: os=sunos & cpu=x64 + languageName: node + linkType: hard + +"@typescript/typescript-win32-arm64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-win32-arm64@npm:7.0.2" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"@typescript/typescript-win32-x64@npm:7.0.2": + version: 7.0.2 + resolution: "@typescript/typescript-win32-x64@npm:7.0.2" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@ungap/structured-clone@npm:^1.3.0": version: 1.4.0 resolution: "@ungap/structured-clone@npm:1.4.0" @@ -6887,14 +7109,14 @@ __metadata: "resolve@patch:resolve@npm%3A1.22.8#optional!builtin, resolve@patch:resolve@npm%3A^1.10.0#optional!builtin, resolve@patch:resolve@npm%3A^1.22.3#optional!builtin": version: 1.22.8 - resolution: "resolve@patch:resolve@npm%3A1.22.8#optional!builtin::version=1.22.8&hash=c3c19d" + resolution: "resolve@patch:resolve@npm%3A1.22.8#optional!builtin::version=1.22.8&hash=9bd1a5" dependencies: is-core-module: "npm:^2.13.0" path-parse: "npm:^1.0.7" supports-preserve-symlinks-flag: "npm:^1.0.0" bin: resolve: bin/resolve - checksum: 10/f345cd37f56a2c0275e3fe062517c650bb673815d885e7507566df589375d165bbbf4bdb6aa95600a9bc55f4744b81f452b5a63f95b9f10a72787dba3c90890a + checksum: 10/b14c82cbce48701a1e963c60f196b91a289186e8b596334e09c881df8069cefcfb0ac9ce85ea768742b361a58005494bf2428a95dc5056d2ba441aa993731b1f languageName: node linkType: hard @@ -7661,23 +7883,25 @@ __metadata: languageName: node linkType: hard -"typescript@npm:~5.3.3": - version: 5.3.3 - resolution: "typescript@npm:5.3.3" +"typescript@npm:@typescript/typescript6@^6.0.2": + version: 6.0.2 + resolution: "@typescript/typescript6@npm:6.0.2" + dependencies: + "@typescript/old": "npm:typescript@^6" bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 10/6e4e6a14a50c222b3d14d4ea2f729e79f972fa536ac1522b91202a9a65af3605c2928c4a790a4a50aa13694d461c479ba92cedaeb1e7b190aadaa4e4b96b8e18 + tsc6: bin/tsc6 + checksum: 10/e214aa9b2783ac924498ebbb42a4419e1d8681acc10d26daa145e938d6da0ecde46ad36690fc4e9083a4b47cf73cdc83f2c2054f32e07f10920768956c2b00a1 languageName: node linkType: hard -"typescript@patch:typescript@npm%3A~5.3.3#optional!builtin": - version: 5.3.3 - resolution: "typescript@patch:typescript@npm%3A5.3.3#optional!builtin::version=5.3.3&hash=e012d7" +"typescript@patch:typescript@npm%3A@typescript/typescript6@^6.0.2#optional!builtin": + version: 6.0.2 + resolution: "typescript@patch:@typescript/typescript6@npm%3A6.0.2#optional!builtin::version=6.0.2&hash=5786d5" + dependencies: + "@typescript/old": "npm:typescript@^6" bin: - tsc: bin/tsc - tsserver: bin/tsserver - checksum: 10/c93786fcc9a70718ba1e3819bab56064ead5817004d1b8186f8ca66165f3a2d0100fee91fa64c840dcd45f994ca5d615d8e1f566d39a7470fc1e014dbb4cf15d + tsc6: bin/tsc6 + checksum: 10/b190ec6b713b0fa95c059ff8019b740c17591ea83a3b60e6fe592d51d56d73c360b86abce48f616d25c39697cc5f4bb9efe8e2a231096f493758457cb175e11c languageName: node linkType: hard From fdb61df9fb7d2e9f442cc835ba0464fa68c71d20 Mon Sep 17 00:00:00 2001 From: Salah-Eddine Saakoun Date: Sat, 5 Sep 2026 12:58:14 +0200 Subject: [PATCH 2/2] fix: silence the node10 resolution deprecation under TS 6 The ts-jest transform compiles the tests to CommonJS with node10 resolution, which TS 6 now reports as TS5107. Core adds the same ignoreDeprecations: '6.0' to its transform in MetaMask/core#9518. Only CI caught this: a stale ts-jest cache locally was still serving output compiled before the TypeScript change, so test:source passed here until the cache was cleared. --- jest.config.cjs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jest.config.cjs b/jest.config.cjs index 3f0397b5..b28f6b07 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -202,6 +202,9 @@ module.exports = { tsconfig: { module: 'CommonJS', moduleResolution: 'Node', + // TS 6 deprecates node10 resolution. The tests are compiled to + // CommonJS, so node10 is still the correct choice for them. + ignoreDeprecations: '6.0', verbatimModuleSyntax: false, }, },