ts-toolbelt
ts-toolbelt copied to clipboard
`Narrow` doesn't work on template literal types
🐞 Bug Report
Reproduce the bug
declare const foo: <T extends number>(value: Narrow<`${T}`>) => void
foo('12')
Screenshots

Additional context
trying to make a toNumber function that knows the value at compiletime
const toNumber = <T extends number>(value: Narrow<`${T}`>): T => Number(value) as T
const value: 12 = toNumber('12') //TS2322: Type 'number' is not assignable to type '12'.
may be a limitation in the compiler related to https://github.com/microsoft/TypeScript/issues/42938