Skip to content

Commit

Permalink
Fix typings of dynamic suspense
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Sep 2, 2021
1 parent 3693ed2 commit bb4f735
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/next/shared/lib/dynamic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,18 @@ export type LoadableBaseOptions<P = {}> = LoadableGeneratedOptions & {
ssr?: boolean
}

export type LoadableSuspenseOptions<P = {}> = {
loader: Loader<P>
export type LoadableSuspenseOptions = {
suspense?: boolean
}

export type LoadableOptions<P = {}> = LoadableBaseOptions<P>

export type DynamicOptions<P = {}> = LoadableBaseOptions<P>
export type DynamicOptions<P = {}> =
| LoadableBaseOptions<P>
| LoadableSuspenseOptions

export type LoadableFn<P = {}> = (
opts: LoadableOptions<P> | LoadableSuspenseOptions<P>
opts: LoadableOptions<P> | LoadableSuspenseOptions
) => React.ComponentType<P>

export type LoadableComponent<P = {}> = React.ComponentType<P>
Expand Down Expand Up @@ -113,7 +114,7 @@ export default function dynamic<P = {}>(
// Support for passing options, eg: dynamic(import('../hello-world'), {loading: () => <p>Loading something</p>})
loadableOptions = { ...loadableOptions, ...options }

const suspenseOptions = loadableOptions as LoadableSuspenseOptions<P>
const suspenseOptions = loadableOptions as LoadableSuspenseOptions
if (!process.env.__NEXT_CONCURRENT_FEATURES) {
// Error if react root is not enabled and `suspense` option is set to true
if (!process.env.__NEXT_REACT_ROOT && suspenseOptions.suspense) {
Expand Down

0 comments on commit bb4f735

Please sign in to comment.