Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Mar 30, 2023
1 parent 32bfe92 commit 25bdf10
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/dts-test/defineComponent.test-d.tsx
Expand Up @@ -1415,8 +1415,8 @@ describe('slots', () => {
item: [number]
}>,
setup(props, { slots }) {
expectType<(foo: string, bar: number) => any>(slots.default)
expectType<(scope: number) => any>(slots.item)
expectType<undefined | ((foo: string, bar: number) => any)>(slots.default)
expectType<undefined | ((scope: number) => any)>(slots.item)
}
})

Expand Down
4 changes: 2 additions & 2 deletions packages/dts-test/functionalComponent.test-d.tsx
@@ -1,4 +1,4 @@
import { h, Text, FunctionalComponent, Component, SlotsType, VNode } from 'vue'
import { h, Text, FunctionalComponent, Component, VNode } from 'vue'
import { expectType } from './utils'

// simple function signature
Expand Down Expand Up @@ -73,7 +73,7 @@ const Quux: FunctionalComponent<{}, {}, { default: [foo: number] }> = (
props,
{ emit, slots }
) => {
expectType<{ default: (foo: number) => VNode[] }>(slots)
expectType<{ default: undefined | ((foo: number) => VNode[]) }>(slots)
}
expectType<Component>(Quux)
;<Quux />
2 changes: 1 addition & 1 deletion packages/runtime-core/src/component.ts
Expand Up @@ -125,7 +125,7 @@ export interface ComponentInternalOptions {
export interface FunctionalComponent<
P = {},
E extends EmitsOptions = {},
S extends Record<string, any[]> = {}
S extends Record<string, any[]> = Record<string, any[]>
> extends ComponentInternalOptions {
// use of any here is intentional so it can be a valid JSX Element constructor
(props: P, ctx: Omit<SetupContext<E, SlotsType<S>>, 'expose'>): any
Expand Down
6 changes: 3 additions & 3 deletions packages/runtime-core/src/componentSlots.ts
Expand Up @@ -41,9 +41,9 @@ export type TypedSlots<S extends SlotsType> = [keyof S] extends [never]
? Slots
: Readonly<
Prettify<{
[K in keyof NonNullable<S[typeof SlotSymbol]>]: Slot<
NonNullable<S[typeof SlotSymbol]>[K]
>
[K in keyof NonNullable<S[typeof SlotSymbol]>]:
| Slot<NonNullable<S[typeof SlotSymbol]>[K]>
| undefined
}>
>

Expand Down

0 comments on commit 25bdf10

Please sign in to comment.