Multiple inference in template literal type
1type MultipleInference<S extends string> = S extends `${infer X}${infer Y}` ? {x: X, y: Y} : never2type Result = MultipleInference<"abcde">34// OK5// type Result = {6// x: "a";7// y: "bcde";8// }910// NG11// type Result = {12// x: "ab";13// y: "cde";14// }
Good Type Challenges
-
ReplaceAll https://github.com/type-challenges/type-challenges/blob/master/questions/119-medium-replaceall/README.md
-
IsNever https://github.com/type-challenges/type-challenges/blob/master/questions/1042-medium-isnever/README.md
-
IsUnion https://github.com/type-challenges/type-challenges/blob/master/questions/1097-medium-isunion/README.md
-
PickByType https://github.com/type-challenges/type-challenges/blob/master/questions/2595-medium-pickbytype/README.md