Skip to content

Commit 17a46db

Browse files
feat: Add testing
1 parent 74a5577 commit 17a46db

6 files changed

Lines changed: 291 additions & 6 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
dist
2-
node_modules
2+
node_modules

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/index.test.*

index.test.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { Equal, Expect } from '@type-challenges/utils'
2+
import type { Slots, SlotsCreator, SlotsProps } from "./index"
3+
import type { ComponentProps, PropsWithChildren, JSX } from 'react'
4+
5+
const SLOTS = {
6+
Name1: 'a',
7+
Custom: () => <></>,
8+
Custom1: (props: PropsWithChildren) => <></>
9+
} satisfies Slots
10+
11+
type SlotsConfig = SlotsCreator<typeof SLOTS, { Name1: [number], Custom: [{ id: number, name: string }] }>
12+
13+
type Props = SlotsProps<SlotsConfig, { Custom: (props: PropsWithChildren) => JSX.Element }>
14+
15+
type Cases = [
16+
Expect<Equal<Props,
17+
{
18+
slots?: {
19+
Custom: (props: PropsWithChildren) => JSX.Element;
20+
},
21+
slotProps?: {
22+
name1?: Partial<ComponentProps<'a'>> | ((...args: [number]) => Partial<ComponentProps<'a'>>);
23+
custom?: Partial<PropsWithChildren> | ((...args: [{ id: number, name: string }]) => Partial<Partial<PropsWithChildren>>)
24+
custom1?: Partial<PropsWithChildren>
25+
}
26+
}
27+
>>
28+
]

0 commit comments

Comments
 (0)