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

Cannot build using TypeScript 4.8.2 #40108

Closed
1 task done
nbouvrette opened this issue Aug 30, 2022 · 7 comments
Closed
1 task done

Cannot build using TypeScript 4.8.2 #40108

nbouvrette opened this issue Aug 30, 2022 · 7 comments
Labels
bug Issue was opened via the bug report template. TypeScript Related to types with Next.js.

Comments

@nbouvrette
Copy link
Contributor

Verify canary release

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

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Home
Binaries:
  Node: 14.18.3
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant packages:
  next: 12.2.6-canary.6
  eslint-config-next: 12.2.5
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

N/A

How are you deploying your application? (if relevant)

N/A

Describe the Bug

When upgrading to TypeScript 4.8.2 (from 4.7.4), I can no longer build my application that requires Next.js as a dependency:

> next-multilingual@1.4.2 build
> rm -Rf ./lib && tsc

node_modules/next/dist/client/with-router.d.ts:8:121 - error TS2344: Type 'C' does not satisfy the constraint 'BaseContext'.

8 export default function withRouter<P extends WithRouterProps, C = NextPageContext>(ComposedComponent: NextComponentType<C, any, P>): 
React.ComponentType<ExcludeRouterProps<P>>;
                                                                                                                          ~

  node_modules/next/dist/client/with-router.d.ts:8:63
    8 export default function withRouter<P extends WithRouterProps, C = NextPageContext>(ComposedComponent: NextComponentType<C, any, P>): React.ComponentType<ExcludeRouterProps<P>>;
                                                                    ~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends BaseContext` constraint.


Found 1 error in node_modules/next/dist/client/with-router.d.ts:8

Expected Behavior

The application should just build, as it is using TypeScript 4.7.4

Link to reproduction

https://github.com/Avansai/next-multilingual

To Reproduce

  1. Clone https://github.com/Avansai/next-multilingual
  2. run npm run build -> it works!
  3. Upgrade TypeScript to 4.8.2
  4. run npm run build -> it fails
@nbouvrette nbouvrette added the bug Issue was opened via the bug report template. label Aug 30, 2022
@huozhi
Copy link
Member

huozhi commented Aug 30, 2022

We upgraded the typings support for typescript 4.8.2 in the latest canary 12.2.6-canary.7 (publishing), can you try it later once it's on the npm?

@nbouvrette
Copy link
Contributor Author

Sure, I only had access to 12.2.6-canary.6

@SukkaW
Copy link
Contributor

SukkaW commented Aug 31, 2022

@nbouvrette 12.2.6-canary.7 has already been released and includes @huozhi's fix #39979.

@huozhi
Copy link
Member

huozhi commented Aug 31, 2022

Verified the reproduction works with typescript 4.8.2 and next@12.2.6-canary.7

@huozhi huozhi closed this as completed Aug 31, 2022
@huozhi huozhi added the TypeScript Related to types with Next.js. label Aug 31, 2022
@nbouvrette
Copy link
Contributor Author

Sorry, I just had a chance to check and I confirm that this is also working on next@12.2.6-canary.9 - thanks

@huozhi
Copy link
Member

huozhi commented Sep 5, 2022

Glad it works! Thanks for reporting

@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. TypeScript Related to types with Next.js.
Projects
None yet
Development

No branches or pull requests

3 participants