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 Type to solve issue found in #36008 #36671

Merged
merged 4 commits into from
May 23, 2022
Merged

Fix Type to solve issue found in #36008 #36671

merged 4 commits into from
May 23, 2022

Conversation

Josehower
Copy link
Contributor

Bug

when using styled-components following the official integration example

It seems the DocumentInitialProps types are not right (i.e when a fragment is used)

Class static side 'typeof MyDocument' incorrectly extends base class static side 'typeof Document'.
  The types returned by 'getInitialProps(...)' are incompatible between these types.
    Type 'Promise<{ styles: Element; html: string; head?: (Element | null)[] | undefined; }>' is not assignable to type 'Promise<DocumentInitialProps>'.
      Type '{ styles: JSX.Element; html: string; head?: (JSX.Element | null)[] | undefined; }' is not assignable to type 'DocumentInitialProps'.
        Type '{ styles: JSX.Element; html: string; head?: (JSX.Element | null)[] | undefined; }' is not assignable to type '{ styles?: ReactElement<any, string | JSXElementConstructor<any>>[] | ReactFragment | undefined; }'.
          Types of property 'styles' are incompatible.
            Type 'Element' is not assignable to type 'ReactElement<any, string | JSXElementConstructor<any>>[] | ReactFragment | undefined'.

image
image

The issue is documented here #36008

In advance thanks for your attention.

Good energy 👍👍👍👍

It seems the types inside of `DocumentInitialProps` have inconsistencies with the type coming from a fragment 

The issue is documented here #36008
Copy link
Member

@timneutkens timneutkens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for this change?

@Josehower
Copy link
Contributor Author

Sure I would be open to creating that, Just I have never created a test for a type. Can you maybe give some hints on where to start and what is the workflow for tests in Next.js?

Copy link
Member

@ijjk ijjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, updated type was landed in another PR so landing test here, thanks for looking into this!

@ijjk ijjk merged commit 0162911 into vercel:canary May 23, 2022
@Josehower Josehower deleted the patch-4 branch May 23, 2022 08:24
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants