Skip to content

feat: add AllPermissionKeys type for i18n label keys in permission schema#279

Open
mj-kiwi wants to merge 2 commits into
mainfrom
feat/permission-label-keys-type
Open

feat: add AllPermissionKeys type for i18n label keys in permission schema#279
mj-kiwi wants to merge 2 commits into
mainfrom
feat/permission-label-keys-type

Conversation

@mj-kiwi

@mj-kiwi mj-kiwi commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

📝 Description

Adds an AllPermissionKeys exported type in @metamask/7715-permission-types — a union of all i18n labelKey string literals used across permission schema field definitions.

🔄 What Changed?

  • Added AllPermissionKeys union type (21 label key literals) in permissions/schema/types.ts
  • Tightened BaseField.labelKey from string to AllPermissionKeys
  • Exported AllPermissionKeys from permissions/schema/index.ts and the package root index.ts

🚀 Why?

  • Consumers (e.g. the extension) need a typed key set to build exhaustive Record<AllPermissionKeys, string> i18n maps, so new label keys fail to compile until translations are added
  • Tightening labelKey from string catches typos/unknown keys in schema field definitions at compile time

🧪 How to Test?

  • Manual testing steps:
  1. yarn tsc --noEmit in packages/7715-permission-types — should pass
  2. yarn build in packages/7715-permission-types — should succeed
  3. Import AllPermissionKeys from @metamask/7715-permission-types in a consumer and confirm it resolves to the 21-key union
  • Automated tests added/updated
  • All existing tests pass

⚠️ Breaking Changes

  • No breaking changes
  • Breaking changes (describe below):

📋 Checklist

  • Code follows the project's coding standards
  • Self-review completed
  • Documentation updated (if needed)
  • Tests added/updated
  • Changelog updated (if needed)
  • All CI checks pass

🔗 Related Issues

Closes #
Related to #

📚 Additional Notes

AllPermissionKeys is currently a hand-maintained literal union mirrored from the labelKey strings used in sections.ts / tokenApprovalRevocation.ts / unknownPermissionType.ts. It will catch unknown-key typos at compile time, but won't catch dead/unused keys — fine at 21 entries, worth revisiting if this list grows and starts drifting.


Note

Low Risk
Compile-time typing and public type exports only; no runtime behavior or security-sensitive logic changes.

Overview
Adds and exports AllPermissionKeys, a union of the 21 i18n labelKey literals used in permission schema field definitions, so consumers can build exhaustive translation maps (e.g. Record<AllPermissionKeys, string>).

BaseField.labelKey is narrowed from string to AllPermissionKeys, so schema definitions must use known keys at compile time. The type is re-exported from the schema module and @metamask/7715-permission-types package entry; the changelog documents the addition.

Reviewed by Cursor Bugbot for commit b96dd8b. Bugbot is set up for automated code reviews on this repo. Configure here.

@mj-kiwi
mj-kiwi requested a review from a team as a code owner July 16, 2026 01:22
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