automatically infer
No response
function test<T>(t1: T, t2: T): never { throw Error('todo'); } function custom<T>(f: (data: T) => T): T { throw Error('todo'); } async function main() { test(10, custom((data) => { throw Error('todo') })) }
Function custom correctly inffered
custom
function test<T>(options: { t1: T, t2: T }): never { throw Error('todo'); } function custom<T>(f: (data: T) => T): T { throw Error('todo'); } async function main() { test({ t1: 10, t2: custom((data) => { throw Error('todo') }) }) }
Function custom incorrectly inffered, the T should be number instead of unknown
T
number
unknown
Function custom incorrectly infered, the T infered as unknown
Function custom correctly infered, the T infered as number
#47599
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
Activity
RyanCavanaugh commentedon Mar 25, 2024
#47599
typescript-bot commentedon Mar 28, 2024
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.