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

feat: add type-level `readonly()` api #593

Merged
merged 3 commits into from Dec 7, 2020
Merged

feat: add type-level `readonly()` api #593

merged 3 commits into from Dec 7, 2020

Conversation

@antfu
Copy link
Member

@antfu antfu commented Nov 22, 2020

No description provided.

* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
export function readonly<T extends object>(

This comment has been minimized.

@pikax

pikax Nov 23, 2020
Member

Not sure if is worth to have readonly if it's the same as shallowReadonly

This comment has been minimized.

@antfu

antfu Nov 23, 2020
Author Member

It's for the API alignment with Vue 3, lowing the difference between them. Thinking import { readonly } from 'vue-demi will work for Vue 3 but failed on Vue 2. This implementation acts like a noop but providing the type-level checking as the same as Vue 3. Should be good enough for users using TypeScript.

src/reactivity/readonly.ts Outdated Show resolved Hide resolved
antfu added 2 commits Nov 25, 2020
@antfu antfu requested a review from pikax Dec 3, 2020
@pikax
pikax approved these changes Dec 3, 2020
@antfu antfu merged commit 3b726d4 into vuejs:master Dec 7, 2020
2 checks passed
2 checks passed
build (10.x)
Details
build (12.x)
Details
@antfu antfu deleted the antfu:feat/readonly branch Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.