Skip to content

Commit

Permalink
fix(react): change defineSuspense function signature
Browse files Browse the repository at this point in the history
  • Loading branch information
dayongkr committed Oct 26, 2024
1 parent e9d4785 commit 6ed9372
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 30 deletions.
6 changes: 3 additions & 3 deletions packages/react/src/utils/defineSuspense.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
>()
Expand Down
40 changes: 13 additions & 27 deletions packages/react/src/utils/defineSuspense.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,21 @@ export const SuspenseClientOnly = (props: SuspenseProps) => (
</ClientOnly>
)

/* 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,
Expand Down

0 comments on commit 6ed9372

Please sign in to comment.