Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types: add read-only versions of observables #2563

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

mbest
Copy link
Member

@mbest mbest commented Feb 28, 2021

Based on #2476, this also sets the default return value of ko.computed to a read-only Computed type.

Retsam and others added 5 commits April 12, 2019 17:36
Observables can be cast to readonly observable to indicate that they shouldn't be mutated, or functions can accept readonly observables to indicate that they won't mutate them
ObservableArrays can be cast to this type to prevent mutation, or taken as function arguments to indicate that the function will not mutate the observable
Computeds can be cast to this type to prevent mutation, or taken as function arguments to indicate that the function will not write to this computed

In theory certain ko.computed overrides should return this, but this is not currently the case
To avoid major breaking changes, use `Computed` for read-only computeds
fix some typos
expand readonly tests, especially using @ts-expect-error
@mbest mbest added this to the 3.5.2 milestone Feb 28, 2021
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.

None yet

2 participants