File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -95,5 +95,15 @@ describe("Params namespace", () => {
95
95
log : "world" ,
96
96
} as const ) ;
97
97
} ) ;
98
+
99
+ it ( "extracts strings with params interpolated" , ( ) => {
100
+ // NOTE: be wary of this test. Hover over the types to see what they're
101
+ // parsing as. When doing TDD this test surprisingly passed. That's
102
+ // because ParamsOf was returning the empty interface because it did
103
+ // not special case for Record<string, never>. This meant that any input
104
+ // would pass the test. Fixing this issue in the test suite is as copmlex
105
+ // as fixing the bug to begin with and would probably share implementations.
106
+ expectType < ParamsOf < `${string } /{uid}`> > ( { uid : "uid" } ) ;
107
+ } ) ;
98
108
} ) ;
99
109
} ) ;
Original file line number Diff line number Diff line change @@ -36,7 +36,10 @@ export type Split<S extends string, D extends string> =
36
36
S extends `${D } ${infer Tail } `
37
37
? [ ...Split < Tail , D > ]
38
38
: S extends `${infer Head } ${D } ${infer Tail } `
39
- ? [ Head , ...Split < Tail , D > ]
39
+ ? // Drop types that are exactly string; they'll eat up literal string types
40
+ string extends Head
41
+ ? [ ...Split < Tail , D > ]
42
+ : [ Head , ...Split < Tail , D > ]
40
43
: // A string without delimiters splits into an array of itself
41
44
[ S ] ;
42
45
You can’t perform that action at this time.
0 commit comments