Skip to content

Commit

Permalink
fix: support props type-checking for functional components with one p…
Browse files Browse the repository at this point in the history
…arameter

close #2686
  • Loading branch information
johnsoncodehk committed Apr 23, 2023
1 parent 6d88299 commit 6b13f8f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vue-language-core/src/generators/template.ts
Expand Up @@ -538,7 +538,7 @@ export function generate(
...createPropsCode(node, 'props', propsFailedExps),
'}',
['', 'template', startTagOffset + node.tag.length, capabilitiesPresets.diagnosticOnly], // diagnostic end
', {} as any);\n',
`, ...(await import('./__VLS_types')).functionalComponentArgsRest(${componentVar}));\n`,
);

if (node.tag !== 'template') {
Expand Down
1 change: 1 addition & 0 deletions packages/vue-language-core/src/utils/localTypes.ts
Expand Up @@ -95,6 +95,7 @@ export declare function asFunctionalComponent<T, K = T extends new (...args: any
: T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
: T extends (...args: any) => any ? T
: (_: T & Record<string, unknown>, ctx?: any) => { __ctx?: { attrs?: unknown, expose?: unknown, slots?: unknown, emit?: unknown }, __props?: T & Record<string, unknown> }; // IntrinsicElement
declare function functionalComponentArgsRest<T>(t: T): Parameters<T>['length'] extends 2 ? [any] : [];
export declare function pickEvent<Emit, K, E>(emit: Emit, emitKey: K, event: E): FillingEventArg<
PickNotAny<
AsFunctionOrAny<NonNullable<E>>,
Expand Down

0 comments on commit 6b13f8f

Please sign in to comment.