kwhitley / itty-router

A little router.
MIT License
1.76k stars 78 forks source link

feat: Implements type inferrence for route params in V4 #201

Closed LiamMartens closed 5 months ago

LiamMartens commented 10 months ago

Mostly non breaking

Description

Created a new proposal for Itty Router v4 to support route param type inferrence. The only breaking change would be for users who are passing generics to their route handlers I believe (ie: Router().get<>) because the path now has to extends string for type inference to work.

Feedback welcome of course

Related Issue

https://github.com/kwhitley/itty-router/pull/150

Type of Change (select one and follow subtasks)

LiamMartens commented 10 months ago

I also saw yarn.lock was updated - but also I saw their are 2 conflicting lockfiles - npm and yarn - wasn't sure which one was the right one - might be worth setting a packageManager in the package.json

kwhitley commented 9 months ago

So I love trying to get inference on route params, but not at the price of a breaking change. v4.x is new enough that yet another [breaking] change in the TS signatures this soon would probably be a sign of general instability in the platform.

kwhitley commented 9 months ago

So unless we can get this in without impacting (in a breaking manner) the existing types, I'm leaning towards closing this for now... 😞

kwhitley commented 5 months ago

Closing this for now... there are more heavily typed approaches to solving this, but itty aims to be the lightweight version of all the heavy approaches.