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">
>,
];
标签:Typescript,string,Param,PathParams,Medium,Expect,92,infer From: https://www.cnblogs.com/Answer1215/p/16875427.html