#Match/filter strings from string literal union that match criteria
1 messages · Page 1 of 1 (latest)
lol i think i found the solution, please let me know if this is the right way or not:ts Input extends `${infer A}.${HTTPCode}` | infer B ? A : neveri literally just added | infer B
original example would work with generics
type Foo<T> = T extends `${infer A}X` ? A : never
that makes it behave distributively on an union
thanks a lot! works very nicely :)
i'm curious about the distributive behaviour. is there any documentation on this or an article?
https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types
Create types which act like if statements in the type system.
thanks again :)