next-auth-typescript-example icon indicating copy to clipboard operation
next-auth-typescript-example copied to clipboard

Fixing TS error on property 'session'

Open lucagrandicelli opened this issue 3 years ago • 1 comments

Actually, this configuration throws an error on Next.js 12.3.1^ /w Typescript support: Type error: Property 'session' does not exist on type '{}'

Since release of Next.js v12.3.0, https://github.com/vercel/next.js/releases#:%7E:text=Compare-,v12.3.0,-Latest the interface AppProps takes a generic for pageProps as shown in the details of this merged PR (https://github.com/vercel/next.js/pull/38867)

Importing the Session type and passing it to the AppProps generic fixes this issue.

lucagrandicelli avatar Oct 14 '22 15:10 lucagrandicelli

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
next-auth-typescript-example ❌ Failed (Inspect) Oct 14, 2022 at 3:48PM (UTC)

vercel[bot] avatar Oct 14 '22 15:10 vercel[bot]