Closed Cherry closed 2 months ago
as a workaround use defineProps<Props>()
: playground
FYI: This doesn't seem to be a Vue type issue, ref TypeScript playground
This seems to only happen in the playground, maybe due to outdated Volar used?
I can't reproduce this locally in VSCode either.
That's very interesting, thank you for taking a look.
With a fresh npm create vue@latest
project, I'm also unable to reproduce this. But in a project at work, I still am able to when using vue@3.4.31
, @vue/language-core@2.0.26
and VSCode extension vue.volar
at v2.0.26
within VSCode, all latest versions.
I didn't think to test this way since I was able to repro quickly in the playground. Let me see if I can do some more digging and get back to you.
Closing as a duplicate of #11733 - neither can be reproduced on my end so let's keep only one open.
Here's a minimal reproduction (just vue
+ vue-tsc
) showing the issue:
https://stackblitz.com/edit/stackblitz-starters-zu6gov
To be clear, this issue is only reproducible with strict: false
. It's not reproducible on the SFC playground for some reason, even when updating tsconfig.json
.
Vue version
3.4.31
Link to minimal reproduction
https://play.vuejs.org/#eNqNVMtu2zAQ/JUFL04A10KbnhTFQVvkkB7qIM1RQKHHyqYjkSxJOW4N/3t3KVl+pHkYBkzuLoczu0NvxBdjJqsWRSwSV1hpPDj0rYE6U/OrVHiXimmqZGO09fBNNwYqqxsYTSLe8NHRZaqGig1YrGDbF3GWk4VWzoP02MAVF5xtUgVQaR2Dty2OeZdnNoZPqdqeB7wk6ujQ5bShk6bOPNIOIOGbeQGw+pBLVcaMTGT5JxVHGe0XaG9P09MksCe0JDqAFmPSS1wrOZ8snVbUlEA0FQVVyxrtzHhJWlIRQ8hwLqtr/fQ9xAYx4cwCi8f/xJduzbFU3Fl0aFeYiiHnMztH36Vvfv7ANa2HZKPLtqbqV5L36HTdMseu7GurSqJ9UBfY3oZhSTV/cDdrj8rtRDFRrtyG+lTQALlRL0nf072YfA7naH7UxZ013nAVQO8a/8cgWefOavPAy0P/kBuGug14fX/ir+AWqlAebZUVCDztHUWy2HUMudY1ZiogsdH+Uky1TY42hIj0McJsZ5oDmPeidFY3pMSR10uspELW5TrP0zWEO7QQgvQYZvkSCw+ZG3qQ8P3TfmxAj+Z3Ky2WR17qpgQwmPw9uIO4t8CDqO4x7mT1LzgM4SxoHMOIg6PzS4iibo6VtuAX0gF9W/Wo9JO63kMMXJ/hDJkeLG97YxwCko1e/28o5SosaGlsF+NP351NJ2EbxFFJtK85Kg9N2h/ak35+Mom6K0//SX6t0PK7ojdAj2Ny8VFs/wEOa8gQ
Steps to reproduce
Comp.vue
fileitem
isunknown
otherItem
is set toOtherItem
What is expected?
The type for
item
on line 26 should be theItem
interface defined on line 5.What is actually happening?
The type for
item
is returningunknown
.System Info
Any additional comments?
It seems that whenever an Interface/type contains only optional properties, the type that's inferred is always
unknown
.