chore!: bump TypeScript target and lib to ES2022 - #333
Merged
Conversation
cryptodev-2s
added this pull request to stack #331
September 9, 2026 20:38
Mrtenz
reviewed
Sep 10, 2026
Comment on lines
+12
to
+13
| - **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. |
Member
There was a problem hiding this comment.
Suggested change
| - **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. |
cryptodev-2s
force-pushed
the
migrate/es2022
branch
from
September 10, 2026 09:32
475c5c9 to
ead0e28
Compare
cryptodev-2s
force-pushed
the
migrate/es2022
branch
from
September 10, 2026 10:15
ead0e28 to
f1c4f44
Compare
cryptodev-2s
force-pushed
the
migrate/es2022
branch
from
September 10, 2026 10:28
f1c4f44 to
387f0eb
Compare
cryptodev-2s
removed this pull request from stack #331
September 10, 2026 10:40
cryptodev-2s
force-pushed
the
migrate/es2022
branch
from
September 10, 2026 10:41
387f0eb to
44f18d6
Compare
cryptodev-2s
added this pull request to stack #335
September 10, 2026 10:41
cryptodev-2s
force-pushed
the
migrate/es2022
branch
from
September 10, 2026 11:05
44f18d6 to
38137ab
Compare
Mrtenz
approved these changes
Sep 10, 2026
cryptodev-2s
force-pushed
the
migrate/es2022
branch
from
September 10, 2026 12:46
38137ab to
dbffd96
Compare
cryptodev-2s
force-pushed
the
migrate/es2022
branch
2 times, most recently
from
September 10, 2026 13:08
bdc12a4 to
717e23d
Compare
cryptodev-2s
force-pushed
the
migrate/es2022
branch
from
September 10, 2026 13:15
717e23d to
223a1b5
Compare
cryptodev-2s
force-pushed
the
migrate/es2022
branch
from
September 10, 2026 13:21
223a1b5 to
f514f2a
Compare
cryptodev-2s
force-pushed
the
migrate/es2022
branch
from
September 10, 2026 13:27
f514f2a to
7babb70
Compare
cryptodev-2s
force-pushed
the
migrate/es2022
branch
from
September 10, 2026 13:33
7babb70 to
914a3ee
Compare
cryptodev-2s
force-pushed
the
migrate/es2022
branch
from
September 10, 2026 13:40
914a3ee to
676e4fe
Compare
cryptodev-2s
force-pushed
the
migrate/es2022
branch
from
September 10, 2026 13:50
676e4fe to
6242b3e
Compare
cryptodev-2s
added a commit
that referenced
this pull request
Sep 10, 2026
Top of stack #331, on #333. Opts this package into the progressive test type checking rollout core is doing (16 of its 100 packages so far). ## Tests were not type checked at all Verified by injecting `const deliberateTypeError: number = "a string"` into a test file: | Check | Result | | --- | --- | | `yarn build` | passes, `tsconfig.build.json` excludes tests | | `yarn test:source` | passes, see below | | `yarn test:types` | passes, tsd only reads `*.test-d.ts` | | `yarn lint` | passes | `test:source` can never catch it: `isolatedModules` puts ts-jest on its `transpileModule` path, which erases types without checking them. ## The change ``` lint:tsc = tsc --noEmit --project tsconfig.lint.json ← added to `lint` ``` `tsconfig.lint.json` extends `tsconfig.json` (which already covers everything the build does not) and adds `skipLibCheck`, because dependency declarations do not satisfy the strict flags used here. ## Why `*.test-d.ts` is excluded Those belong to `tsd`, which checks them itself via `yarn test:types` (fixed in #322). Including them here pulls `tsd`'s own types into the program, and those reach `type-fest`, whose `basic.d.ts` carries `/// <reference lib="esnext" />`. That silently widens built in types past this package's `lib`, producing a spurious failure where `FrozenSet` no longer satisfies `ReadonlySet` because of Set methods we do not target. Traced with `tsc --explainFiles`. ## Why this stacks on ES2022 With `lib: ES2020` a `tsc` pass over the tests reports **11 errors**, nearly all `Property 'cause' does not exist`. With `lib: ES2022`, **zero**. #333 has to land first. ## Confirmed not vacuous A deliberate type error in a test file now exits non-zero with `TS2322`, and `tsd` still independently catches a bad `expectAssignable` in a `.test-d.ts` file. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Dev-only lint and TypeScript config changes; no runtime or shipped library behavior changes. > > **Overview** > **`yarn lint` now runs TypeScript on test and other non-build code** through a new `lint:tsc` script, closing a gap where `tsconfig.build.json` and transpile-only Jest never validated types in `*.test.ts` files. > > A new **`tsconfig.lint.json`** extends the root config with `skipLibCheck`, incremental **`emitDeclarationOnly`** output under **`.tsc-lint-cache/`** (gitignored and ignored by ESLint), and an **exclude** for **`*.test-d.ts`** so `tsd`-owned type tests are not double-checked or polluted by `tsd`’s wider `lib` types. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 670fa8a. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Top of stack #331, on #325. Mirrors MetaMask/core#10019, the last of core's foundational chain.
targetES2020ES2022lib["ES2020", "DOM"]["ES2022", "DOM"]Correctly last in the order: raising the emit target is only defensible once the Node floor guarantees the runtime supports it, which #328 established.
It is not cosmetic
wrapErrorsetscausebehind two@ts-ignorecomments, with this note in the source:Error.causeis ES2022, so both suppressions are now obsolete and are removed. The types are genuine rather than ignored.The evidence came from enabling test type checking: with
lib: ES2020atscpass over the tests reports 11 errors, nearly allProperty 'cause' does not exist. Withlib: ES2022it reports zero. That is why the type checking PR stacks on top of this one rather than below it.Verification
Build, tests, tsd, eslint and lint all pass.
Note
Medium Risk
Breaking for consumers on older runtimes or TS configs that assumed ES2020 output; error utilities are widely used but the change is configuration and type hygiene rather than new logic.
Overview
BREAKING: Raises the TypeScript
targetandlibfrom ES2020 to ES2022, so published output expects a modern runtime or bundler that can consume ES2022. The unreleased changelog documents this alongside the existing Node/ESM breaking changes.In
wrapError, theError(message, { cause })path no longer needs@ts-ignoreor the comment about ES2020 lackingError.causetypes—ES2022libmakescausea first-class typed option.No runtime behavior change in
wrapErrorbeyond what was already implemented; this is primarily a compile/emit floor and type-checking cleanup that unblocks stricter testtsc(e.g.causeon errors) in follow-up work.Reviewed by Cursor Bugbot for commit 6242b3e. Bugbot is set up for automated code reviews on this repo. Configure here.