Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dist
node_modules
node_modules
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/index.test.*
28 changes: 28 additions & 0 deletions index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import type { Equal, Expect } from '@type-challenges/utils'
import type { Slots, SlotsCreator, SlotsProps } from "./index"
import type { ComponentProps, PropsWithChildren, JSX } from 'react'

const SLOTS = {
Name1: 'a',
Custom: () => <></>,
Custom1: (props: PropsWithChildren) => <></>
} satisfies Slots

type SlotsConfig = SlotsCreator<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>
}
}
>>
]
Loading