MetaMask / MetaMask/core

Bump TypeScript module output options `target` and `lib` to `ES2022`

Open
#4,507 0 comments 0 reactions 0 assignees View on GitHub
team-wallet-framework wf-typescript-upgrades
Dominant language
TypeScript
Stars
413
Forks
308
Avg merge
1d 4h
Merged PRs (30d)
253

Description

## Motivation

- https://github.com/MetaMask/core/pull/3645 sets the `moduleResolution` option to `node16`, which implies a target of `ES2022`.
- > https://www.typescriptlang.org/docs/handbook/modules/reference.html#implied-and-enforced-options

## Features

**`ES2022`**

- ~Top-level `await` expressions~ -> not available to CJS modules
- Important, because with `moduleResolution` set to `node16`, we can only reference ESM-only modules using dynamic import syntax, which becomes much easier to write with top-level `await`.

**`ES2021`**

- `String.prototype.replaceAll()`
- `Promise.any()`

## Regressions

- The `ErrorOptions` type defined in `@metamask/approval-controller` needs to be renamed, as it shadows a new global variable defined in the [`ES2022.Error` library](https://github.com/microsoft/TypeScript/blob/main/src/lib/es2022.error.d.ts).
- Other exports from the package may also need to be renamed to present a consistent naming scheme.
- See https://github.com/MetaMask/core/actions/runs/9830120317/job/27135954759

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the TypeScript configuration that sets the module output options and review the @metamask/approval-controller exports, especially ErrorOptions. Use the linked CI run to identify affected packages and type errors. Done means target and lib use ES2022 and conflicting exports are consistently renamed without regressions.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
build-system
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.