From 6ed93722b5c2d3a05843fd0e67a779438c08366f Mon Sep 17 00:00:00 2001 From: dayongkr Date: Sat, 26 Oct 2024 13:50:36 +0900 Subject: [PATCH] fix(react): change `defineSuspense` function signature --- .../react/src/utils/defineSuspense.test-d.ts | 6 +-- packages/react/src/utils/defineSuspense.tsx | 40 ++++++------------- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/packages/react/src/utils/defineSuspense.test-d.ts b/packages/react/src/utils/defineSuspense.test-d.ts index 338400f4a..995f76724 100644 --- a/packages/react/src/utils/defineSuspense.test-d.ts +++ b/packages/react/src/utils/defineSuspense.test-d.ts @@ -14,12 +14,12 @@ describe('defineSuspense', () => { 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..60ca8a598 100644 --- a/packages/react/src/utils/defineSuspense.tsx +++ b/packages/react/src/utils/defineSuspense.tsx @@ -7,35 +7,21 @@ 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?: boolean + } + | { + componentPropsClientOnly?: undefined + 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: 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,