You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's good, but I believe adding this test case Expect<Equal<DynamicRoute<'/[[...foo]]/[...]/[...bar]'>, never>> will result in a failure, even though it is supposed to pass.
It's good, but I believe adding this test case Expect<Equal<DynamicRoute<'/[[...foo]]/[...]/[...bar]'>, never>> will result in a failure, even though it is supposed to pass.
Thanks for testing. This is my fix.
type IsArr<T> = T extends `${string}...${string}` ? true : false
type Extract<T> = T extends `[...${infer F}]` | `...${infer F}` ? F : T
- type DynamicRoute<T extends string, _Res extends Record<string, string | string[]> = {}> = T extends `${infer A}[...]${infer B}`+ type DynamicRoute<T extends string, _Res extends Record<string, string | string[]> = {}> = T extends `${infer A}/[...]${infer B}`
? DynamicRoute<`${A}${B}`, _Res & { '...': string }>
: T extends `${string}]/[...${string}`
? never
: T extends `${infer A}[[${ infer F }]]${ infer B }`
? DynamicRoute<`${A}${B}`, _Res & ( Extract<F> extends '' ? {} : { [K in Extract<F>]?: IsArr<F> extends true ? string[] : string } ) >
: T extends `${infer A}[${ infer F }]${ infer B }`
? DynamicRoute<`${A}${B}`, _Res & ( Extract<F> extends '' ? {} : { [K in Extract<F>]: IsArr<F> extends true ? string[] : string } ) >
: { [K in keyof _Res]: _Res[K] }
The text was updated successfully, but these errors were encountered: