Carried over from MetaMask/utils#280, which was approved but still open when @metamask/utils moved into core.
TypeScript is structurally typed nearly everywhere, but enums are nominal. Two enums that look identical are not assignable to each other, so a value produced by one copy of a package fails to typecheck against a function from another copy. That bites hardest in a monorepo with duplicated versions in the tree.
packages/utils still exports three:
KnownCaipNamespace in src/caip-types.ts:134
JsonSize in src/misc.ts:137
Duration in src/time.ts:4
The original PR replaces them with const objects plus derived union types, which keeps the call sites working while making the types structural.
Note this is a breaking change for consumers who use the enum types nominally, so it wants a major. The PR's .eslintrc.js rule does not port directly since core has its own shared config.
Carried over from MetaMask/utils#280, which was approved but still open when
@metamask/utilsmoved into core.TypeScript is structurally typed nearly everywhere, but enums are nominal. Two enums that look identical are not assignable to each other, so a value produced by one copy of a package fails to typecheck against a function from another copy. That bites hardest in a monorepo with duplicated versions in the tree.
packages/utilsstill exports three:KnownCaipNamespaceinsrc/caip-types.ts:134JsonSizeinsrc/misc.ts:137Durationinsrc/time.ts:4The original PR replaces them with const objects plus derived union types, which keeps the call sites working while making the types structural.
Note this is a breaking change for consumers who use the enum types nominally, so it wants a major. The PR's
.eslintrc.jsrule does not port directly since core has its own shared config.