feat: add AllPermissionKeys type for i18n label keys in permission schema#279
Open
mj-kiwi wants to merge 2 commits into
Open
feat: add AllPermissionKeys type for i18n label keys in permission schema#279mj-kiwi wants to merge 2 commits into
mj-kiwi wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
Adds an
AllPermissionKeysexported type in@metamask/7715-permission-types— a union of all i18nlabelKeystring literals used across permission schema field definitions.🔄 What Changed?
AllPermissionKeysunion type (21 label key literals) inpermissions/schema/types.tsBaseField.labelKeyfromstringtoAllPermissionKeysAllPermissionKeysfrompermissions/schema/index.tsand the package rootindex.ts🚀 Why?
Record<AllPermissionKeys, string>i18n maps, so new label keys fail to compile until translations are addedlabelKeyfromstringcatches typos/unknown keys in schema field definitions at compile time🧪 How to Test?
yarn tsc --noEmitinpackages/7715-permission-types— should passyarn buildinpackages/7715-permission-types— should succeedAllPermissionKeysfrom@metamask/7715-permission-typesin a consumer and confirm it resolves to the 21-key union📋 Checklist
🔗 Related Issues
Closes #
Related to #
📚 Additional Notes
AllPermissionKeysis currently a hand-maintained literal union mirrored from thelabelKeystrings used insections.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 i18nlabelKeyliterals used in permission schema field definitions, so consumers can build exhaustive translation maps (e.g.Record<AllPermissionKeys, string>).BaseField.labelKeyis narrowed fromstringtoAllPermissionKeys, so schema definitions must use known keys at compile time. The type is re-exported from the schema module and@metamask/7715-permission-typespackage 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.