vercel / next.js

The React Framework
https://nextjs.org
MIT License
123.05k stars 26.29k forks source link

File conventions are applied inside private folders #64162

Open AdisonCavani opened 3 months ago

AdisonCavani commented 3 months ago

Link to the code that reproduces this issue

https://github.com/AdisonCavani/nextjs-file-conv-minimal-reproduction

To Reproduce

  1. Run build: next build
  2. See error:
> build
> next build

 ✓ Creating an optimized production build
 ✓ Compiled successfully
   Linting and checking validity of types  ..Failed to compile.

.next/types/app/_components/page.ts:26:13
Type error: Type 'OmitWithTag<Props, keyof PageProps, "default">' does not satisfy the constraint '{ [x: string]: never; }'.
  Property 'className' is incompatible with index signature.
    Type 'string' is not assignable to type 'never'.

  24 |
  25 | // Check the prop type of the entry function
> 26 | checkFields<Diff<PageProps, FirstArg<TEntry['default']>, 'default'>>()
     |             ^
  27 |
  28 | // Check the arguments and return type of the generateMetadata function
  29 | if ('generateMetadata' in entry) {

Current vs. Expected behavior

File conventions should not be applied inside private folders (with _ prefix).

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 16296
  Available CPU cores: 12
Binaries:
  Node: 21.7.1
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.0-canary.61 // Latest available version is detected (14.2.0-canary.61).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A

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

App Router, TypeScript (plugin, built-in types)

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

next build (local)

Additional context

When I rename the _components/page.tsx to anything other, eg.: _components/page-comp.tsx the error disappears.

lovelyJason commented 2 months ago

这个bug是怎么解决的,没办法next build啊,next dev是正常