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
Element Plus prop values not typechecked #2176
Comments
I used the element-plus: export type SFCWithInstall = T & Plugin // vue/runtime-core.d.ts
declare type Plugin_2 = (PluginInstallFunction & {
install?: PluginInstallFunction;
}) | {
install: PluginInstallFunction;
};
export { Plugin_2 as Plugin }
declare type PluginInstallFunction = (app: App, ...options: any[]) => any;
// VLS_type.ts
export type ComponentProps<T> =
Record<string, unknown> &
(
T extends (...args: any) => any ? (T extends (...args: any) => { props: infer Props } ? Props : {})
: T extends new (...args: any) => any ? (T extends new (...args: any) => { $props: infer Props } ? Props : {})
: T // IntrinsicElement
); After removing |
@Sight-wcg Could you try does reverse export type ComponentProps<T> =
Record<string, unknown> &
(
T extends new (...args: any) => any ? (T extends new (...args: any) => { $props: infer Props } ? Props : {})
: T extends (...args: any) => any ? (T extends (...args: any) => { props: infer Props } ? Props : {})
: T // IntrinsicElement
); |
edit: Yeah this seems to be working perfectly. My test method is wrong, should exit the takeover mode for testing @johnsoncodehk |
FIxed by #2180 |
Thank you for the quick resolution! |
This may be a problem beyond the usage of Element Plus, but I will describe what happens for me:
When working inside a Vue template and using imported Element Plus components, there is no typechecking for values passed to a prop. It's strange, because when hovering over the component itself, it will correctly list the props and its accepted types.
For example: the
<el-image>
component has a prop calledfit
which can take the following values:'fill' | 'contain' | 'cover' | 'none' | 'scale-down'
. The prop 'fit' correctly shows as available with intellisense (though I have to select it from the list, it won't autocomplete while typing inside the component tag). However, the prop itself is typed asstring
and has no mention of the correct list of strings as defined by the component.Is there anything wrong with the type recognition, or did I set something up the wrong way?
The text was updated successfully, but these errors were encountered: