MetaMask / core

This monorepo is a collection of packages used across multiple MetaMask clients
MIT License
250 stars 174 forks source link

Improve type safety by applying `satisfies` operator #1972

Closed MajorLift closed 1 day ago

MajorLift commented 8 months ago

The next version bump for TypeScript in core and metamask-module-template will mark an update to version 4.9, which will make the satisfies operator keyword available for use (https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/#satisfies).

The satisfies operator is a safer alternative to type annotations (val: T) and type assertions (val as T). We should investigate opportunities to improve type safety in the codebase by applying this feature to existing code.

desi commented 4 months ago

As we are going through other work we should be on the lookout for places to replace Type Annotations with satisfies. Typescript guidelines should give indicators for when to use satisfies

desi commented 4 months ago

There are currently 135 Type Annotations in core.

desi commented 4 months ago

@MajorLift will do a bit more investigation and we will revisit as part of next refinement.

MajorLift commented 4 months ago

Type annotations count in core as of 3/21/2024 (test files excluded):