Skip to content

chore!: bump TypeScript target and lib to ES2022 - #333

Open
cryptodev-2s wants to merge 1 commit into
migrate/pr2k-typescriptfrom
migrate/es2022
Open

chore!: bump TypeScript target and lib to ES2022#333
cryptodev-2s wants to merge 1 commit into
migrate/pr2k-typescriptfrom
migrate/es2022

Conversation

@cryptodev-2s

@cryptodev-2s cryptodev-2s commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Top of stack #331, on #325. Mirrors MetaMask/core#10019, the last of core's foundational chain.

Before After
target ES2020 ES2022
lib ["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

wrapError sets cause behind two @ts-ignore comments, with this note in the source:

Error causes are not supported by our current tsc target (ES2020, we need ES2022 to make this work)

Error.cause is 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: ES2020 a tsc pass over the tests reports 11 errors, nearly all Property 'cause' does not exist. With lib: ES2022 it 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
Semver-breaking compiler target change can affect downstream bundlers or runtimes below ES2022, though the project already requires Node 22+/24.

Overview
Breaking: Raises TypeScript compilerOptions.target and lib from ES2020 to ES2022 (DOM lib unchanged), so emitted JS and type definitions align with MetaMask core. The unreleased changelog notes that build output may use ES2022 syntax; callers on the package’s supported Node range should be fine.

With ES2022 in lib, Error’s optional cause is part of the standard typings. In wrapError, the @ts-ignore suppressions and comments that explained the old ES2020 limitation are removednew Error(message, { cause: originalError }) and the ErrorWithCause fallback are unchanged at runtime but now type-check cleanly.

Reviewed by Cursor Bugbot for commit 069ae2f. Bugbot is set up for automated code reviews on this repo. Configure here.

@cryptodev-2s
cryptodev-2s added this pull request to stack #331 September 9, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant