-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.tsx
28 lines (24 loc) · 968 Bytes
/
index.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import type { Equal, Expect } from '@type-challenges/utils'
import type { Slots, SlotsConfigCreator, SlotsProps } from "./index"
import type { ComponentProps, PropsWithChildren, JSX } from 'react'
const SLOTS = {
Name1: 'a',
Custom: () => <></>,
Custom1: (props: PropsWithChildren) => <></>
} satisfies Slots
type SlotsConfig = SlotsConfigCreator<typeof SLOTS, { Name1: [number], Custom: [{ id: number, name: string }] }>
type Props = SlotsProps<SlotsConfig, { Custom: (props: PropsWithChildren) => JSX.Element }>
type Cases = [
Expect<Equal<Props,
{
slots?: {
Custom: (props: PropsWithChildren) => JSX.Element;
},
slotProps?: {
name1?: Partial<ComponentProps<'a'>> | ((...args: [number]) => Partial<ComponentProps<'a'>>);
custom?: Partial<PropsWithChildren> | ((...args: [{ id: number, name: string }]) => Partial<Partial<PropsWithChildren>>)
custom1?: Partial<PropsWithChildren>
}
}
>>
]