Skip to content

DSL typing: name-less 3-arg path(pattern, component, childrenFn) collapses the route map to never #642

Closed

Description

@ivogt

Symptom

Adding a single name-less route using the 3-arg children-function form:

path("/section/stream", StreamPage, () => [
  loader(StreamLoader),
  loading(<div>Loading...</div>),
])

collapses the entire app's generated route map: Rango.Path resolves to never, producing cascading never type errors across every href/Link.to/named-route usage in the app — not just at the offending route.

Expected

Unnamed routes are deliberately excluded from the route map — ExtractRoutesFromItem maps TName extends UnnamedRoute to {} (src/urls/type-extraction.ts:85) — so a name-less route in any call form should contribute {} and leave sibling routes' types intact. The 2-arg form (path(pattern, component)) and the named 3-arg form both behave correctly.

Actual

With the name-less children-fn overload, the item's inferred type apparently falls through the TypedRouteItem conditional chain in ExtractRoutesFromItem (src/urls/type-extraction.ts:79), and the UnionToIntersection in ExtractRoutesFromItems (:127-135) absorbs the result into never for the whole tuple, wiping the map.

Workaround

Name the route: path("name", "/section/stream", StreamPage, () => [...]) — restores correct inference. (Matches repo conventions anyway, which is why this stayed latent.)

Pointers

  • Extraction: src/urls/type-extraction.ts (ExtractRoutesFromItem :79, ExtractRoutesFromItems :127)
  • Overload types: src/urls/path-helper-types.ts (the children-fn overload's inference is the suspect)
  • Runtime (fine, unaffected): src/urls/path-helper.ts

Discovery context

Hit while adding e2e routes for PPR shell caching (#641) in both tests/cloudflare-basic and e2e/test-app — reproduced identically in two independent apps, so it is the overload, not app-specific augmentation. Likely fix territory: the name-less children-fn overload's TypedRouteItem type parameters (or a defensive never-absorbing guard in ExtractRoutesFromItems so one bad item can never nuke the map — arguably worth doing regardless as a blast-radius fix).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions