You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src/App.vue:17:3 - error TS2322: Type 'Node[]' is not assignable to type '{ key: number; checked: boolean; }[]'. Type 'Node' is not assignable to type '{ key: number; checked: boolean; }'. Types of property 'checked' are incompatible. Type 'Ref<boolean>' is not assignable to type 'boolean'.17 nodes.value = array; ~~~~~~~~~~~src/App.vue:32:23 - error TS2345: Argument of type '{ key: number; checked: boolean; }' is not assignable to parameter of type 'Node'. Types of property 'checked' are incompatible. Type 'boolean' is not assignable to type 'Ref<boolean>'.32 @input="onInput(toRaw(node))" ~~~~~~~~~~~Found 2 errors.
The value returned by the nodes ref is UnwrapRef<Node[]>, not Node[], because it's an reactive array/object, which unwraps nested refs.
So to make TS happy, you have to wrap the array in reactive() before assigning it. As that would happen anyway after you added it, this isn't real extra work.
node.value=reactive(array)
This is a Typescript caveat we need to document, but nothing we can "fix".
Steps to reproduce
Run
npm run build
in codesandboxWhat is expected?
No typescript errors
What is actually happening?
Got 2 typescript errors:
See also: vuejs/language-tools#908
Additonal content (SFC where the errors happen)
The text was updated successfully, but these errors were encountered: