Skip to content

Instantly share code, notes, and snippets.

@jezzgoodwin
jezzgoodwin / inferenceRouter.ts
Last active October 2, 2025 13:32
Inference Router
// shamelessly taken from tanstack router ;-)
type ParsePathParams<T extends string, TAcc = never> = T &
`${string}:${string}` extends never
? TAcc
: T extends `${string}:${infer TPossiblyParam}`
? TPossiblyParam extends ""
? TAcc
: TPossiblyParam & `${string}/${string}` extends never
? TPossiblyParam | TAcc
: TPossiblyParam extends `${infer TParam}/${infer TRest}`