-
-
Notifications
You must be signed in to change notification settings - Fork 444
Support for props extraction on .vue #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is the design limit for now, because DefineComponent<...> & {
__VLS_raw: DefineComponent<...>, // raw type
__VLS_options: ..., // for template components, props, emits services
__VLS_slots: ..., // for slots services
} So it can't infer extends as const a = defineComponent({
props: {
show: Boolean,
title: String,
},
});
type A = typeof a & { __VLS_foo: any }
// We want B is true, but it's false
type B = A extends DefineComponent<
infer _,
any,
any,
any,
any,
any,
any,
any
> ? true : false; If you accept a hack way, you can use |
Will use that for now, do you think if the typed slots are implemented + GlobalComponents, will you still have the need of having? DefineComponent<...> & {
__VLS_raw: DefineComponent<...>, // raw type
__VLS_options: ..., // for template components, props, emits services
__VLS_slots: ..., // for slots services
} |
@pikax Yes it will better, but still need to use this way to support vue 2 / class component. I will find a way to handle this problem. (The most extreme case I can create double typescript language service instances, half for |
I'm not sure if this bug has already been fixed, but the following one seems to be working: import { ComponentOptions } from 'vue'
import Sfc from 'Sfc.vue'
type ExtractProp<Type> = Type extends ComponentOptions<infer Props>
? Props
: never
type SfcProps = ExtractProp<typeof Sfc>; |
@lanyizi not yet, but this problem may only occur with |
Fixed in [email protected] and [email protected]. |
Hey there, is it possible nowadays to infer types from a |
When you want to infer props from a base component, volar currently can't infer the
props
types (vuedx
currently works)This code works in typescript
But as soon as you separate into SFC types, the type gets lost:
The text was updated successfully, but these errors were encountered: