How does Typescript generic auto-inferrence really works on multiple generics?
20:40 05 Apr 2026

So I have this case where I want to automatically infer a type of second generic using extends keyword:

function b>(u: U) {
    return u
} 

b({name: 'string'})

But when I want to call it, compiler says I need to specify a second generic property too (Expected 2 type arguments, but got 1)

However, if I write it like that:

function b() {
    return function

>(p: P) { return p } } b()({name: 'string'})

It won't ask me for a generic and infer the type automatically.

Why?

typescript