Skip to content

Commit b6d421c

Browse files
committed
test: improve functional slots test case
1 parent e7742da commit b6d421c

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

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

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,28 @@ const Qux: FunctionalComponent<{}, ['foo', 'bar']> = (props, { emit }) => {
6969

7070
expectType<Component>(Qux)
7171

72-
const Quux: FunctionalComponent<{}, {}, { default: { foo: number } }> = (
73-
props,
74-
{ emit, slots }
75-
) => {
76-
expectType<{ default: undefined | ((scope: { foo: number }) => VNode[]) }>(
77-
slots
78-
)
72+
const Quux: FunctionalComponent<
73+
{},
74+
{},
75+
{
76+
default: { foo: number }
77+
optional?: { foo: number }
78+
}
79+
> = (props, { emit, slots }) => {
80+
expectType<{
81+
default: (scope: { foo: number }) => VNode[]
82+
optional?: (scope: { foo: number }) => VNode[]
83+
}>(slots)
84+
85+
slots.default({ foo: 123 })
86+
// @ts-expect-error
87+
slots.default({ foo: 'fesf' })
88+
89+
slots.optional?.({ foo: 123 })
90+
// @ts-expect-error
91+
slots.optional?.({ foo: 'fesf' })
92+
// @ts-expect-error
93+
slots.optional({ foo: 123 })
7994
}
8095
expectType<Component>(Quux)
8196
;<Quux />

packages/runtime-core/src/componentRenderUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function renderComponentRoot(
102102
markAttrsAccessed()
103103
return attrs
104104
},
105-
slots: slots,
105+
slots,
106106
emit
107107
}
108108
: { attrs, slots, emit }

0 commit comments

Comments
 (0)