-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix!: Prevent calling set on the return value of 'computed()'
BREAKING CHANGE: 'set()' method now only exists if a 'set()' is provided Signed-off-by: Sebastian Malton <[email protected]>
- Loading branch information
Showing
6 changed files
with
45 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
"mobx": major | ||
--- | ||
|
||
Only expose IComputedValue.set as a typescript type when it won't throw an error | ||
|
||
The breaking change is that it is now a typescript compile error to call the `set(value: T)` method on an `IComputedValue` that is not writable. | ||
This is a breaking change because it is possible to create an `IComputedValue` that is not writable, and then call `set` on it. | ||
This will now throw a runtime error. | ||
|
||
This change was made to help with refactoring code, especially between `IObservableValue<T>` and `IComputedValue<T>` which both have a similar interface but one of them throws more errors. | ||
|
||
To fix your code, you will need to change the type annotations for any updatable computed value to `IComputedValue<T, true>`. |
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