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

experimental.typedRoutes throws TS error for group routes inside dynamic routes #58226

Closed
1 task done
AhmedBaset opened this issue Nov 8, 2023 · 5 comments
Closed
1 task done
Labels
bug Issue was opened via the bug report template. locked TypeScript Related to types with Next.js.

Comments

@AhmedBaset
Copy link
Contributor

AhmedBaset commented Nov 8, 2023

Link to the code that reproduces this issue

Code Sand Box

To Reproduce

  1. see the code in app/page.tsx
  2. run next build
  3. the build process will not succeed.

Current vs. Expected behavior

It's supposed to catch /[locale]/(main)/page.tsx correctly as /${string}/.

Current: throws TS error.

path href status
(group)/page.tsx /
[dynamic]/about/(group)/page.tsx /en/about
[dynamic]/(group)/page.tsx /en/

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 Single Language
Binaries:
  Node: 20.0.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: canary
  eslint-config-next: canary
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

TypeScript (plugin, built-in types)

Additional context

No response

@AhmedBaset AhmedBaset added the bug Issue was opened via the bug report template. label Nov 8, 2023
@github-actions github-actions bot added the TypeScript Related to types with Next.js. label Nov 8, 2023
@AhmedBaset AhmedBaset changed the title experimental.typedRoutes throws TS error for group routes inside dynamic routes with experimental.typedRoutes throws TS error for group routes inside dynamic routes Nov 8, 2023
@controversial
Copy link
Contributor

The codesandbox reproduction you left is broken for me, however I’m running into the same bug

Running next dev creates a link.d.ts containing all my routes, however when i run next build it’s replaced by a link.d.ts containing fewer routes (excluding those that are a part of route groups)

@controversial
Copy link
Contributor

I looked into the next-types-plugin source, and I found that

I found that in my case, some modules (as returned by compilation.chunkGraph.getChunkModulesIterable(chunk)) were given an empty string (or undefined) for module.resource by Webpack, instead of the actual path to the resource.

I wasn’t able to track down the cause of this bug, but I patched next-types-plugin/index.js as follows, and that seems to work for now

Screenshot 2023-12-18 at 1 14 18 PM

@controversial
Copy link
Contributor

I don’t think this reproduces for me anymore; I was able to remove my patch from next-types-plugin.

@huozhi
Copy link
Member

huozhi commented Jan 13, 2025

Close per #58226 (comment)
As the orginal codesandbox repro is not valid anymore

@huozhi huozhi closed this as completed Jan 13, 2025
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. 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 Jan 28, 2025
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. locked TypeScript Related to types with Next.js.
Projects
None yet
Development

No branches or pull requests

3 participants