Skip to content

refactor: ban TypeScript enums across internal-snaps - #213

Closed
ulissesferreira wants to merge 1 commit into
mainfrom
refactor/ban-enums
Closed

refactor: ban TypeScript enums across internal-snaps#213
ulissesferreira wants to merge 1 commit into
mainfrom
refactor/ban-enums

Conversation

@ulissesferreira

@ulissesferreira ulissesferreira commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Superseded

This monolith PR has been split into per-network PRs. Please review those instead:

  1. Bitcoin: #216
  2. Solana: #217
  3. Tron: #218

Note: Stellar is still incomplete (half-applied, partially wrong state) and was excluded from the split. It should land separately once fully completed.

Closing this in favor of the per-network PRs.

Convert all locally-declared `enum` and `const enum` declarations
to `as const` objects with derived union types (Pattern A).

**BREAKING CHANGES:**
- Type signatures change: `Enum` is now a union of string/number
  literals instead of a nominal enum type
- `typeof Enum.Member` expressions in type positions now refer to
  literal values instead of enum member types

**Packages affected:**
- bitcoin-wallet-snap: 10 enums converted
- solana-wallet-snap: 16 enums converted
- tron-wallet-snap: 11 enums converted
- stellar-wallet-snap: converted (deferred, partial)

**Also included:**
- ESLint rule banning new `TSEnumDeclaration` via `no-restricted-syntax`
- Changelogs for bitcoin, solana, and tron packages
- Type fixes for template literal types, namespace usage patterns,
  and array .includes() typing after enum-to-const conversion

Refs: MetaMask/utils#280, MetaMask/eslint-config#417
@ulissesferreira

Copy link
Copy Markdown
Contributor Author

Superseded by #216, #217, #218. See updated description for details.

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