mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
### What? Our [docs](https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#convention) point out that `app/page.js` is equivalent to `app/@children/page.js`, however in practice this is not the case, and causes type errors when using `@children` slots as well as incorrect behavior when matching catch-all routes. ### Why? - When typechecking, `@children` slots would be added to the typeguard file for the associated layout, resulting in duplicate identifiers for the `children` prop - When determining where to insert catchall slots, the `hasMatchedSlots` check wasn't considering that the `@children` slot corresponds with the page component, so matching another page would clobber the previous one. ### How? - Filters out the `@children` slot when collecting slots for typechecking - Filters out the `@children` slot when running the `hasMatchedSlots` function in the catch-all normalizer Closes NEXT-1984
29 lines
820 B
TypeScript
29 lines
820 B
TypeScript
import { createNextDescribe } from 'e2e-utils'
|
|
|
|
createNextDescribe(
|
|
'parallel-routes-catchall-children-slot',
|
|
{
|
|
files: __dirname,
|
|
},
|
|
({ next }) => {
|
|
it('should match the @children slot for a page before attempting to match the catchall', async () => {
|
|
let browser = await next.browser('/')
|
|
await expect(browser.elementById('children').text()).resolves.toBe(
|
|
'Hello from @children/page'
|
|
)
|
|
await expect(browser.elementById('slot').text()).resolves.toBe(
|
|
'@slot content'
|
|
)
|
|
|
|
browser = await next.browser('/nested')
|
|
|
|
await expect(browser.elementById('children').text()).resolves.toBe(
|
|
'Hello from nested @children page'
|
|
)
|
|
await expect(browser.elementById('slot').text()).resolves.toBe(
|
|
'Default @slot'
|
|
)
|
|
})
|
|
}
|
|
)
|