Skip to content

Commit f11ea90

Browse files
authored
Demonstrate state as optional in controller guidelines (#4910)
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> In various examples in the controller guidelines, the `state` controller option was not optional, even though there is a guideline that says it should be. This commit updates the documentation so that it shown as optional. ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> I discovered that the examples were incorrect when reviewing [this PR](MetaMask/metamask-extension#28113 (comment)). ## Changelog <!-- If you're making any consumer-facing changes, list those changes here as if you were updating a changelog, using the template below as a guide. (CATEGORY is one of BREAKING, ADDED, CHANGED, DEPRECATED, REMOVED, or FIXED. For security-related issues, follow the Security Advisory process.) Please take care to name the exact pieces of the API you've added or changed (e.g. types, interfaces, functions, or methods). If there are any breaking changes, make sure to offer a solution for consumers to follow once they upgrade to the changes. Finally, if you're only making changes to development scripts or tests, you may replace the template below with "None". --> N/A ## 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 - [x] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
1 parent a71a8a8 commit f11ea90

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/writing-controllers.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class FooController extends BaseController</* ... */> {
4949
state = {},
5050
}: {
5151
messenger: FooControllerMessenger;
52-
state: Partial<FooControllerState>;
52+
state?: Partial<FooControllerState>;
5353
}) {
5454
super({
5555
// ...
@@ -87,7 +87,7 @@ class FooController extends BaseController</* ... */> {
8787
state = {},
8888
}: {
8989
messenger: FooControllerMessenger;
90-
state: Partial<FooControllerState>;
90+
state?: Partial<FooControllerState>;
9191
}) {
9292
super({
9393
name,
@@ -158,7 +158,7 @@ class FooController extends BaseController</* ... */> {
158158
state = {},
159159
}: {
160160
messenger: FooControllerMessenger;
161-
state: Partial<FooControllerState>;
161+
state?: Partial<FooControllerState>;
162162
},
163163
isEnabled: boolean,
164164
) {
@@ -177,7 +177,7 @@ class FooController extends BaseController</* ... */> {
177177
isEnabled,
178178
}: {
179179
messenger: FooControllerMessenger;
180-
state: Partial<FooControllerState>;
180+
state?: Partial<FooControllerState>;
181181
isEnabled: boolean;
182182
}) {
183183
// ...

0 commit comments

Comments
 (0)