Skip to content

Commit

Permalink
fix: allow props less functional component
Browse files Browse the repository at this point in the history
close #2638
  • Loading branch information
johnsoncodehk committed Apr 21, 2023
1 parent fc093cf commit bf8b431
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/vue-language-core/src/utils/localTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ export type EmitEvent<F, E> =
} ? (...payload: P) => void
: unknown | '[Type Warning] Volar could not infer $emit event more than 4 overloads without DefineComponent. see https://github.com/johnsoncodehk/volar/issues/60';
export declare function asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
T extends (...args: any) => any ? T
T extends () => any ? (props: {}) => ReturnType<T>
: T extends (...args: any) => any ? T
: K extends { $props?: infer Props, $slots?: infer Slots, $emit?: infer Emit }
? (props: Props ${vueCompilerOptions.strictTemplates ? '' : '& Record<string, unknown>'}, ctx?: { attrs?: any, expose?(exposed: K): void, slots?: Slots, emit?: Emit }) => JSX.Element & { __ctx?: typeof ctx, __props?: typeof props }
: (_: T & Record<string, unknown>, ctx?: any) => { __ctx?: { attrs?: undefined, expose?: undefined, slots?: undefined, emit?: undefined }, __props?: T & Record<string, unknown> }; // IntrinsicElement
Expand Down
11 changes: 11 additions & 0 deletions packages/vue-test-workspace/vue-tsc/#2638/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
import { h } from 'vue';
const test = () => {
return h('p', {}, 'test');
};
</script>

<template>
<test foo="123" />
</template>

0 comments on commit bf8b431

Please sign in to comment.