Skip to content

Commit d10b574

Browse files
committed
fix: types
1 parent a655521 commit d10b574

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

packages/dts-test/defineComponent.test-d.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1415,8 +1415,8 @@ describe('slots', () => {
14151415
item: [number]
14161416
}>,
14171417
setup(props, { slots }) {
1418-
expectType<(foo: string, bar: number) => any>(slots.default)
1419-
expectType<(scope: number) => any>(slots.item)
1418+
expectType<undefined | ((foo: string, bar: number) => any)>(slots.default)
1419+
expectType<undefined | ((scope: number) => any)>(slots.item)
14201420
}
14211421
})
14221422

packages/dts-test/functionalComponent.test-d.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { h, Text, FunctionalComponent, Component, SlotsType, VNode } from 'vue'
1+
import { h, Text, FunctionalComponent, Component, VNode } from 'vue'
22
import { expectType } from './utils'
33

44
// simple function signature
@@ -73,7 +73,7 @@ const Quux: FunctionalComponent<{}, {}, { default: [foo: number] }> = (
7373
props,
7474
{ emit, slots }
7575
) => {
76-
expectType<{ default: (foo: number) => VNode[] }>(slots)
76+
expectType<{ default: undefined | ((foo: number) => VNode[]) }>(slots)
7777
}
7878
expectType<Component>(Quux)
7979
;<Quux />

packages/runtime-core/src/component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export interface ComponentInternalOptions {
125125
export interface FunctionalComponent<
126126
P = {},
127127
E extends EmitsOptions = {},
128-
S extends Record<string, any[]> = {}
128+
S extends Record<string, any[]> = Record<string, any[]>
129129
> extends ComponentInternalOptions {
130130
// use of any here is intentional so it can be a valid JSX Element constructor
131131
(props: P, ctx: Omit<SetupContext<E, SlotsType<S>>, 'expose'>): any

packages/runtime-core/src/componentSlots.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ export type TypedSlots<S extends SlotsType> = [keyof S] extends [never]
4141
? Slots
4242
: Readonly<
4343
Prettify<{
44-
[K in keyof NonNullable<S[typeof SlotSymbol]>]: Slot<
45-
NonNullable<S[typeof SlotSymbol]>[K]
46-
>
44+
[K in keyof NonNullable<S[typeof SlotSymbol]>]:
45+
| Slot<NonNullable<S[typeof SlotSymbol]>[K]>
46+
| undefined
4747
}>
4848
>
4949

0 commit comments

Comments
 (0)