-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Closed
Labels
Description
Version
3.0.3
Reproduction link
https://github.com/brlodi/vue3.0.3-ToRefs-repro
Steps to reproduce
- Run
yarn/npm install
andyarn/npm serve
on main branch - Observe project builds successfully and dev server finds no issues
- Switch to 3.0.3 branch and repeat
yarn
/npm
commands - Observe multiple Typescript type errors, caused by
ToRefs<T>
members having different types in 3.0.3.- e.g. if
type Foo = { bar: string | number }
- under 3.0.2: the shape of
ToRefs<Foo>
is{ bar: Ref<string | number> }
- in 3.0.3: the shape of
ToRefs<Foo>
is{ bar: Ref<string> | Ref<number>
}, which cannot accept assignment of aRef<string | number>
- under 3.0.2: the shape of
- e.g. if
What is expected?
Typescript code using the Composition API which works in Vue 3.0.2 should work in all future patch versions of Vue 3.0.x
What is actually happening?
Changes to Vue's reactivity types in 3.0.3 break code that worked in 3.0.2.
This is obviously an extremely contrived and overly manually-typed example. In practice this came up with a composition function that returns a toRef
-ed version of a reactive object for concise destructuring, as well as a component cycling its own state like the App component in the repro does.
Note this isn't value judgement of the new typings, just that changing them introduced an unexpected breaking change in a patch release.