solidjs / solid-router

A universal router for Solid inspired by Ember and React Router
MIT License
1.11k stars 138 forks source link

RouteSectionProps allows children, but why? #347

Open TPReal opened 6 months ago

TPReal commented 6 months ago

Describe the bug

The RouteSectionProps type allows children. This creates two small problems:

  1. I declare my pages as VoidComponent as they cannot have children, they are the whole page components, and right now passing them as the component doesn't compile.
  2. Why allow specifying children at all? How would I specify children to a component used in a route? Does it even make sense?

Your Example Website or App

https://stackblitz.com/edit/solidjs-templates-pheug1?file=src%2FApp.tsx

Steps to Reproduce the Bug or Issue

It just doesn't compile, without a good reason, I think.

Expected behavior

It compiles fine when given a VoidComponent.

Screenshots or Videos

No response

Platform

Additional context

It is a recent change, it used to work reasonably on 0.10.1 I think.

ryansolid commented 6 months ago

If you have a suggestion for the types I'd love it, but its because route sections can have children in that is how outlets work. You inject nested route sections via props.children. So the general type for RouteSectionProps needs to at least have the potential of accepting children I think.

TPReal commented 6 months ago

I see. So the component should be able to accept children, but actually only if the Route element has children, right? Sounds like it's quite possible to declare the types like this.