From 4a59be725bc300a4e6bead931cf674bc134a46d8 Mon Sep 17 00:00:00 2001 From: Salah-Eddine Saakoun Date: Wed, 9 Sep 2026 22:30:21 +0200 Subject: [PATCH 1/2] chore!: bump TypeScript target and lib to ES2022 --- CHANGELOG.md | 2 ++ src/errors.ts | 7 ------- tsconfig.json | 4 ++-- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b543f7e6..b7624a209 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- **BREAKING:** Bump the TypeScript `target` and `lib` to `ES2022` ([#332](https://github.com/MetaMask/utils/pull/332)) + - Emitted output now uses ES2022 syntax, matching core. Consumers on the supported Node range are unaffected. - **BREAKING:** Drop support for Node 18 and 20 ([#328](https://github.com/MetaMask/utils/pull/328)) - **BREAKING:** Drop CommonJS support ([#9536](https://github.com/MetaMask/core/pull/9536)) - This package is now ESM-only, but can still be used in CommonJS projects via `require(esm)` in modern Node.js versions (22+), or dynamic imports in older Node.js versions. diff --git a/src/errors.ts b/src/errors.ts index 6ae07f0f3..b1df41f1e 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -95,15 +95,8 @@ export function wrapError( if (isError(originalError)) { let error: Error & { code?: string }; if (Error.length === 2) { - // for some reason `tsserver` is not complaining that the - // Error constructor doesn't support a second argument in the editor, - // but `tsc` does. Error causes are not supported by our current tsc target (ES2020, we need ES2022 to make this work) - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore error = new Error(message, { cause: originalError }); } else { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore error = new ErrorWithCause(message, { cause: originalError }); } diff --git a/tsconfig.json b/tsconfig.json index c38d8f82c..28664b234 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,14 +4,14 @@ "exactOptionalPropertyTypes": true, "forceConsistentCasingInFileNames": true, "isolatedModules": true, - "lib": ["ES2020", "DOM"], + "lib": ["ES2022", "DOM"], "module": "Node16", "moduleResolution": "Node16", "noEmit": true, "noErrorTruncation": true, "noUncheckedIndexedAccess": true, "strict": true, - "target": "ES2020" + "target": "ES2022" }, "exclude": ["./dist/**/*"] } From 6242b3e584a89dd8a4adf7a3c06c8439ab6ede4b Mon Sep 17 00:00:00 2001 From: Salah-Eddine Saakoun Date: Thu, 10 Sep 2026 11:10:43 +0200 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7624a209..32065502b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- **BREAKING:** Bump the TypeScript `target` and `lib` to `ES2022` ([#332](https://github.com/MetaMask/utils/pull/332)) - - Emitted output now uses ES2022 syntax, matching core. Consumers on the supported Node range are unaffected. +- **BREAKING:** Bump TypeScript target to ES2022 ([#332](https://github.com/MetaMask/utils/pull/332)) + - This package now ships ES2022 code, requiring a compatible modern environment or bundler configuration to consume. - **BREAKING:** Drop support for Node 18 and 20 ([#328](https://github.com/MetaMask/utils/pull/328)) - **BREAKING:** Drop CommonJS support ([#9536](https://github.com/MetaMask/core/pull/9536)) - This package is now ESM-only, but can still be used in CommonJS projects via `require(esm)` in modern Node.js versions (22+), or dynamic imports in older Node.js versions.