Skip to content

Layout using parallel routes throw TypeScript invalid "default" export error on next build #58275

Answered by tholder
csalmeida asked this question in Help
Discussion options

You must be logged in to vote

This is a really stupid way to solve this, you can't even ts ignore the entire file but if it has the default expected type it passes build, so this works:

type LayoutProps = {
    children?: React.ReactNode
}

type LayoutPropsExtended = {
    children?: React.ReactNode
    archivePanel?: React.ReactNode
    archiveForm?: React.ReactNode
}

export default function Layout(props: LayoutProps | LayoutPropsExtended) {
    const { children, archivePanel, archiveForm } = {
        ...props,
        archiveForm: undefined,
        archivePanel: undefined,
    }

    return (
        <div className="h-full">
            {children}
            {archiveForm}
            {archivePanel}
        </div…

Replies: 3 comments 11 replies

Comment options

You must be logged in to vote
7 replies
@csalmeida
Comment options

@icyJoseph
Comment options

@csalmeida
Comment options

@tholder
Comment options

Answer selected by csalmeida
@csalmeida
Comment options

@artemis-prime
Comment options

@csalmeida
Comment options

Comment options

You must be logged in to vote
4 replies
@onatyy
Comment options

@artemis-prime
Comment options

@charltoons
Comment options

@thisisankur0
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
8 participants