`defineProps` is unable to parse the types generated from `ExtractPropTypes`
Vue version
3.3.10
Link to minimal reproduction
Steps to reproduce
see the reproduction
What is expected?
I hope that defineProps
can parse the types generated from ExtractPropTypes
.
What is actually happening?
Currently, attempting to parse with defineProps from ExtractPropTypes results in errors. Any reference for a workaround or solution would be appreciated.
System Info
No response
Any additional comments?
No response
List of TypeScript errors in Vue (SFC) files I faced
- [@vue/compiler-sfc] Unresolvable type: TSConditionalType
- [@vue/compiler-sfc] Unresolvable type: TSTypeQuery
- [@vue/compiler-sfc] Failed to resolve extends base type. If this previously worked in 3.2, you can instruct the compiler to ignore this extend by adding /* @vue-ignore */ before it
@so1ve Can we expect @vue.ts/complex-types
in the Vue Core :pray:?
I wonder how the Svelte compiler supports complex types? Class Variance Authority Svelte example
https://github.com/vuejs/rfcs/discussions/549 https://github.com/vuejs/rfcs/discussions/547
https://github.com/vuejs/core/pull/9556
If we don't get complex types support for SFC
some of the type helpers will be pointless,
But it's working in .ts
or .tsx
right? but Vue Compiler can optimize .vue
files
@sadeghbarati Svelte doesn't "resolve" types to runtime props actually - these type definitions are only used for IDE usage, and they don't affect runtime behavior. But vue needs them to cast types.
@aibayanyu20 do you mind providing an use case for this?
The only use case I see this is when retrieving props from an imported component, if that's the use case I believe is better accessing the component props directly instead of generating through types
<script setup>
import Comp from './Comp.vue'
// this will be supported on https://github.com/vuejs/core/pull/9556
defineProps(Comp.props)
</script>
Since of the limitation when using defineProps
with type based, I would recommend object based instead.
like this online demo ?
like this online demo ?
No, not a reproduction, but actual use case, why do you take that approach instead of another approach
This does seem to be a problem, regardless of the usage and writing method, I still hope this situation can be dealt with, thanks
Maybe I explained here why this is used
It's the exact use case for Tailwind Variants, where you get variants as typeof from VariantProps util, Vue compiler resolve as TSConditionalType bug.