question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug(typedef): AppType typedef changed in 12.3

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

    Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 21.6.0: Wed Aug 10 14:28:23 PDT 2022; root:xnu-8020.141.5~2/RELEASE_ARM64_T6000
    Binaries:
      Node: 16.15.1
      npm: 8.11.0
      Yarn: 1.22.19
      pnpm: 7.10.0
    Relevant packages:
      next: 12.3.0
      eslint-config-next: 12.3.0
      react: 18.2.0
      react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

When bumping version to Next 12.3.0 we ran into some troubles with the AppType typedefinition:

CleanShot 2022-09-08 at 22 30 41

The AppType typedefinition and specifically the pageProps seems to have been broken in 12.3.0 and the pageProps now evaluates to {}: CleanShot 2022-09-08 at 22 34 22

Expected Behavior

I am not sure if this is a bug or if it’s intended, but this change is not present in the changelog and seems to be a “breaking” one worth noting. Maybe we are required to augment some part to make it work with 3rd party dependencies?

Link to reproduction

https://github.com/juliusmarminge/apptype-repro

To Reproduce

Create a new next-app (using reproduction template):

npx create-next-app -e reproduction-template

Install NextAuth:

nom install next-auth

Create pages/_app.tsx with the following content:

import { SessionProvider } from "next-auth/react";
import type { AppType } from "next/dist/shared/lib/utils";

const MyApp: AppType = ({ Component, pageProps }) => {
  return (
    <SessionProvider session={pageProps.session}>
      <Component {...pageProps} />
    </SessionProvider>
  );
};

Hover pageProps, it evaluates to {} and the pageProps.session will error. This was not an issue in 12.2.5.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:6
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
juliusmarmingecommented, Sep 8, 2022

Appears to be related to this typedef change

12.2:


export declare type AppInitialProps = {

    pageProps: any;

};

export declare type AppPropsType<R extends NextRouter = NextRouter, P = {}> = AppInitialProps & {

    Component: NextComponentType<NextPageContext, any, P>;

    router: R;

    __N_SSG?: boolean;

    __N_SSP?: boolean;

    __N_RSC?: boolean;

};

12.3:


export declare type AppInitialProps<P = any> = {

    pageProps: P;

};

export declare type AppPropsType<R extends NextRouter = NextRouter, P = {}> = AppInitialProps<P> & {

    Component: NextComponentType<NextPageContext, any, any>;

    router: R;

    __N_SSG?: boolean;

    __N_SSP?: boolean;

    __N_RSC?: boolean;

};

To be clear i think this is a very good improvement and seems like it would allow for a more typesafe usage in the root app.

Maybe the AppType should be a generic like NextPage, or React.FC and letting me pass in the props like

const MyApp: AppType<{ session: Session }> = ...
4reactions
balazsorban44commented, Sep 9, 2022

Yes, it makes more sense as a feature request, I started working on it already. See #40391

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's new in the updates for macOS Monterey
macOS Monterey 12.3.1 includes bug fixes and security updates for your Mac. This update fixes the following issues: USB-C or Thunderbolt ...
Read more >
typedef changes meaning - c++
In case a global level A is used before the local A is declared, this error will occur. That said, any use of...
Read more >
EPICS Application Developer's Guide - Argonne National Laboratory
typedef void (*REGISTRAR)(void);. This function normally registers things, as described in Chapter 21, “Registry” on page 331. The makeBaseApp.
Read more >
Cisco Nexus 3500 Series NX-OS Programmability Guide, ...
New and Changed Information. This table summarizes the new and changed features for the Cisco Nexus 3500 Series NX-OS Programmability.
Read more >
TOTALFLOW
The contents are subject to change without ... error messages and provides a troubleshooting ... typedef struct. /* Alarm Log Record */.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found