type PathParams<S extends string> =
S extends `/${string}/:${infer Param}/${infer REST}`
? Param | PathParams<`/${REST}`>
: S extends `${string}/:${infer Param}`
? Param
: never;
[
Expect<Equal<PathParams<"/profile">, never>>,
Expect<Equal<PathParams<"/profile/:userId">, "userId">>,
Expect<
Equal<PathParams<"/profile/:userId/posts/:postId">, "userId" | "postId">
>,
];