TypeScript Version:
3.8.3
Search Terms:
type inference
Reproduction link:
https://codesandbox.io/s/dreamy-chandrasekhar-7pqfh
Steps to reproduce:
Check src/index.ts line 5.
Expected behavior:
Type of a.a is number.
Actual behavior:
Type of a.a is Ref<number>.
Related Issues:
https://github.com/vuejs/vue-next/issues/1083
See the comments in src/index.ts.
This is not an typescript issue, this is an issue of vue UnwrapRef implementation.
~I doesn't look like an issue at all, you probably meant a.a.value++.~
I doesn't look like an issue at all, you probably meant
a.a.value++.
At runtime, a.a is 0 and a.a.value is undefined, and after executing a.a++ a.a is now 1, so no.
The problem is that Vue 3 expects Node and Window to be defined; without it, it implicitly has an error. When we look up Node or Window, it's treated as any instead of some opaque type. Maybe @yyx990803 should see this.
If we had opaque placeholder types/forward declarations (https://github.com/microsoft/TypeScript/issues/31894) for Node and the like, I think this would be a non-issue, but this is likely to only be available in the next version. (@ahejlsberg)
A hack that Vue 3.0 can make in the meantime is add some global declarations that are certain not to conflict for Node and the rest:
interface Node {
nodeName: string;
nodeType: number;
textContent: string;
}
Thanks @DanielRosenwasser - tracking in https://github.com/vuejs/vue-next/issues/1083, I think we can close this one.
Thanks everyone, as you said this is not an typescript issue.
Most helpful comment
At runtime,
a.ais0anda.a.valueisundefined, and after executinga.a++a.ais now1, so no.