Type inference The infer keyword allows you to instruct the TypeScript compiler to infer a more specific type. Inference with template literals type StringToNumber<T extends string> = T extends `${infer N extends number}` ? N : never