Typescript type for router.query is incorrect since it can be undefined (on first render in frontend) #65035
Labels
bug
Issue was opened via the bug report template.
invalid link
The issue was auto-closed due to a missing/invalid reproduction link. A new issue should be opened.
Pages Router
Related to Pages Router.
Link to the code that reproduces this issue
NA
To Reproduce
On first render in nexjs router router.query in useRouter from 'next/router' is/can be undefined however the typescript type assumes it is ParsedUrlQuery rather than ParsedUrlQuery | undefined.
Current vs. Expected behavior
Current Behaviour:
Expected Behaviour
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.3.0: Wed Dec 20 21:33:31 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T8112 Available memory (MB): 16384 Available CPU cores: 8 Binaries: Node: 20.10.0 npm: 10.5.2 Yarn: N/A pnpm: 9.0.5 Relevant Packages: next: 14.2.3 // Latest available version is detected (14.2.3). eslint-config-next: 14.2.2 react: 18.2.0 react-dom: 18.2.0 typescript: 5.4.5 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Pages Router
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local)
Additional context
No response
The text was updated successfully, but these errors were encountered: