Open Q16solver opened 3 weeks ago
This is a TS issue, since you specified an initial value for condition
, which has already narrowed its type.
Even if I downgrade to v2.1.6
, the behavior still hasn't changed.
@KazariEX Yeah you're right, ts seems to have this behaviour for initial values which is interesting, the actual issue that occurred in my own project is from defineProps which has no initial value. I don't know where vue-tsc is in the sfc playground so I created a repro in stackblitz instead where I can control the vue-tsc version
repro link: https://stackblitz.com/edit/github-6c2bqu?file=package.json
Run pnpm typecheck
for error with vue-tsc v2.1.8, but it works with v2.1.6, the narrowing from "A" | "B" no longer narrows to "A", and still has "A" | "B" type
Vue - Official extension or vue-tsc version
2.1.8
VSCode version
1.95.0
Vue version
3.5.12
TypeScript version
5.6.3
System Info
No response
package.json dependencies
No response
Steps to reproduce
Hover over the type of the second div with "condition" const and see that it has a type "never"
What is expected?
After checking the first condition with v-if, the second condition type should have type "B"
What is actually happening?
After checking the first condition with v-if, the second condition type no longer narrows the union type, and instead gives "never". This seems to be a regression introduced since v2.1.8 since it has worked in v.2.1.6
Link to minimal reproduction
https://play.vuejs.org/#eNp9kUFPhDAQhf9KM5e9rGzUeFnBBMwe9KBGPTYxBAbsWtqmLUiy8t+dQpblsNkLMPO+ebxpD5AaE3UtwhZiV1hhPHPoW8NkruqEg3ccHrgqtHKe0bMUXmi1ZYxDyoH90TvjkEzlPVfxZnKhGSo8NkbmHqliLC5Fx7orUZHt7MSSJGGrdEVemyWF0uFZNAvoyMabhT2sKSqhlaijvdOK9jkEuzDfGCHRvppgQuts2agELZdS/z6PvSqnP66PQvGNxc8keNue+nvXhx6HN4sObYccZs3ntkY/ybuPF+zpexYbXbaS6AviOzot2xBywrJWlZR7wY1xnxqjrReq/nS73qNyx61C0EAOI8+BbvXxwu6nuLfR3TjH1UDH+NWhDZ50giRE1zcw/AN2jbAd
Any additional comments?
No response