-
-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[base-controller] Make
allowed{Actions,Events}
required parameters …
…of `getRestricted` (#4035) ## Explanation This commit implements a fundamental solution to aligning runtime and type-level behavior for `getRestricted`: removing the option to omit its function parameters altogether. ### Impact - This makes the expected runtime behavior of the method explicit and predictable. - This completely prevents type inference from deriving ambiguous conclusions from the omission of function or generic parameters, or otherwise exhibiting unexpected behavior. The downsides of this approach are a bit more redundant code and inconvenience, but having to write an extra empty array or two doesn't seem like a terrible cost for getting unambiguous, explicit behavior. ### Caveat Note that this solution does not directly resolve the observed bug that motivated this ticket. It does make the bug irrelevant for `getRestricted`, because passing in both allowlist params fixes the issue, but in general, there may still be cases where generic default arguments fail to apply. See #4033 for repro steps and more details on this bug. ### Overview - This change is implemented entirely in this commit: 9988d18 - All of the other diffs in the test files are simply applying this breaking change. ## References - Closes #4033 ## Changelog ### `@metamask/base-controller` #### Changed - **BREAKING:** The `getRestricted` method of the `ControllerMessenger` class now expects both `allowedActions` and `allowedEvents` as required parameters. ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've highlighted breaking changes using the "BREAKING" category above as appropriate
- Loading branch information
Showing
25 changed files
with
166 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.