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
When left and right types are incompatible, the expected type constraint is that they must implement options.direction corresponding to options.transform. However, in reality, options are optional, which may lead to unexpected runtime behavior.
constnum=ref(0)// Ref<number>constbool=ref(true)// Ref<boolean>// Expected(in typescript): compile-time error// Actual: allowedsyncRef(num,bool)num.value++// Causes "bool" to be assigned a number typeexpect(bool).toBeTypeOf('boolean')// Errorbool.value=false// Causes "num" to be assigned a boolean typeexpect(num).toBeTypeOf('number')// Error
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a VueUse issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
Check that this is a concrete bug. For Q&A open a GitHub Discussion.
Describe the bug
When left and right types are incompatible, the expected type constraint is that they must implement options.direction corresponding to options.transform. However, in reality, options are optional, which may lead to unexpected runtime behavior.
Is this a compromise for some necessary scenario?
If not, try fixing it in the following ways:
The most straightforward way:
Or consider treating direction as a generic:
After the fix, the behavior aligns with expectations:
Reproduction
https://stackblitz.com/edit/vitejs-vite-t3mvtk/?file=src%2FApp.vue,src%2Ftest.ts
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: