next.js
b5408d1f - cleanup FlightDataPath array access/slicing (#69241)

Commit
1 year ago
cleanup FlightDataPath array access/slicing (#69241) Working with `FlightDataPath` and `FlightSegmentPath` is tricky because they're typed as `any[]`. Array access and slicing is sprinkled throughout the router code which makes it difficult to add/remove/re-order properties. It also results in more untyped code, because anything that touches `FlightDataPath` becomes `any`. To improve the DX around working with this data structure, I'm starting by moving all of the array slicing/property access into a single location. And `getFlightDataPartsFromPath` provides types for the different properties it returns so things like `seedData` aren't `any`. There's currently two similarly named but different paths that get returned by this function to support forked handling (ppr vs non-PPR): `pathToSegment` and `segmentPath`. Open to alternative names here, but my goal in an upcoming PR is to just have a single segment path and unify the handling. To get there, I first need to investigate all the `// TODO-APP remove ''` comments because we're inconsistent with how the segment path is constructed & consumed.
Author
Parents
Loading