Upgrade to TypeScript v5.1
As part of the Wallet Framework Team's Q2 2024 OKRs (O3/KR4), we are upgrading all core packages to use TypeScript v5.1, with the goal of eventually upgrading to the latest version.
Prior to starting the upgrade process, we should read through the v5.1 release announcements and make note of the following in this ticket:
- New language features that we should apply in our code (e.g.
satisfiesoperator in v4.9). - Breaking changes and possible regressions (e.g. change in type narrowing behavior in v5.0).
- For breaking changes, look at the wiki.
- For regressions, also look at google search results: e.g. site:github.com typescript 5.1 regression
- Blockers for implementation (e.g. fixing type declarations in dependencies to be ESM-compatible was a prerequisite for the v5.0 upgrade).
We should also do a trial run of bumping TypeScript versions in core packages and seeing what (if any) error messages we get when we run yarn build and yarn test. These errors should be recorded in this ticket.
@kanthesha Will you take this one to see what the potential issues might be so we can do refinement on it?
For the trial run, branch from this PR where the v5.0 upgrade is in place: https://github.com/MetaMask/core/pull/3645. If the PR is merged, use the latest version of core.
I went through what's new in 5.1. And most of the 5.1 improvements are automatically applied (developer experience and optimisation related changes, ). Particularly from 5.1, we can incorporate this new feature Easier Implicit Returns for undefined.
I see that we are also talking about the changes in the earlier versions like satisfies in this ticket. When I looked at the current version, it's 4.9.5! And I also see upgrade to v5.0 in-progress! So bit unclear about what's already covered or what's been left from earlier versions?
@kanthesha should this be in "needs dev review"? Or "ready for dev"?
We can move to "ready to Dev".
Should we move this to Blocked since it's dependent on first bumping to TypeScript 5.0?