Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typings of dynamic suspense #28740

Merged
merged 3 commits into from Sep 2, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/next/shared/lib/dynamic.tsx
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