diff --git a/.changeset/eleven-laws-appear.md b/.changeset/eleven-laws-appear.md new file mode 100644 index 000000000..c4739a950 --- /dev/null +++ b/.changeset/eleven-laws-appear.md @@ -0,0 +1,5 @@ +--- +"@suspensive/react": patch +--- + +fix(react): change `defineSuspense` function signature diff --git a/packages/react/src/utils/defineSuspense.test-d.ts b/packages/react/src/utils/defineSuspense.test-d.ts index 338400f4a..6322f649f 100644 --- a/packages/react/src/utils/defineSuspense.test-d.ts +++ b/packages/react/src/utils/defineSuspense.test-d.ts @@ -5,21 +5,21 @@ describe('defineSuspense', () => { it('type check', () => { expectTypeOf(defineSuspense({ componentPropsClientOnly: true })).toEqualTypeOf() expectTypeOf(defineSuspense({ defaultPropsClientOnly: true })).toEqualTypeOf() - expectTypeOf(defineSuspense({ componentPropsClientOnly: true, defaultPropsClientOnly: undefined })).toEqualTypeOf< + expectTypeOf(defineSuspense({ defaultPropsClientOnly: undefined, componentPropsClientOnly: true })).toEqualTypeOf< typeof SuspenseClientOnly >() - expectTypeOf(defineSuspense({ componentPropsClientOnly: undefined, defaultPropsClientOnly: true })).toEqualTypeOf< + expectTypeOf(defineSuspense({ defaultPropsClientOnly: true, componentPropsClientOnly: undefined })).toEqualTypeOf< typeof SuspenseClientOnly >() expectTypeOf(defineSuspense({ defaultPropsClientOnly: true, componentPropsClientOnly: true })).toEqualTypeOf< typeof SuspenseClientOnly >() - expectTypeOf(defineSuspense({ defaultPropsClientOnly: true, componentPropsClientOnly: false })).toEqualTypeOf< - typeof SuspenseClientOnly - >() expectTypeOf(defineSuspense({ defaultPropsClientOnly: false, componentPropsClientOnly: true })).toEqualTypeOf< typeof SuspenseClientOnly >() + expectTypeOf(defineSuspense({ defaultPropsClientOnly: true, componentPropsClientOnly: false })).toEqualTypeOf< + typeof Suspense + >() expectTypeOf(defineSuspense({ defaultPropsClientOnly: false, componentPropsClientOnly: false })).toEqualTypeOf< typeof Suspense >() diff --git a/packages/react/src/utils/defineSuspense.tsx b/packages/react/src/utils/defineSuspense.tsx index c1a42a7bc..96f03b17f 100644 --- a/packages/react/src/utils/defineSuspense.tsx +++ b/packages/react/src/utils/defineSuspense.tsx @@ -7,35 +7,23 @@ export const SuspenseClientOnly = (props: SuspenseProps) => ( ) -/* eslint-disable @typescript-eslint/unified-signatures */ -export function defineSuspense(options: { componentPropsClientOnly: true }): typeof SuspenseClientOnly -export function defineSuspense(options: { defaultPropsClientOnly: true }): typeof SuspenseClientOnly -export function defineSuspense(options: { - componentPropsClientOnly: true - defaultPropsClientOnly: undefined -}): typeof SuspenseClientOnly -export function defineSuspense(options: { - componentPropsClientOnly: undefined - defaultPropsClientOnly: true -}): typeof SuspenseClientOnly -export function defineSuspense(options: { - componentPropsClientOnly: true - defaultPropsClientOnly: true -}): typeof SuspenseClientOnly -export function defineSuspense(options: { - componentPropsClientOnly: true - defaultPropsClientOnly: false -}): typeof SuspenseClientOnly -export function defineSuspense(options: { - componentPropsClientOnly: false - defaultPropsClientOnly: true -}): typeof SuspenseClientOnly +export function defineSuspense( + options: + | { + componentPropsClientOnly: true + defaultPropsClientOnly?: boolean + } + | { + componentPropsClientOnly?: undefined + defaultPropsClientOnly: true + } +): typeof SuspenseClientOnly + export function defineSuspense(options: { - componentPropsClientOnly: false - defaultPropsClientOnly: false + componentPropsClientOnly?: boolean + defaultPropsClientOnly?: boolean }): typeof Suspense -// eslint-disable-next-line @typescript-eslint/no-empty-object-type -export function defineSuspense(options: {}): typeof Suspense + export function defineSuspense({ defaultPropsClientOnly, componentPropsClientOnly,