I'm completely stuck on this and can't seem to figure it out without using a second function:
interface Fixed { a: number }
const fn = <A, B extends {} = {}>(b: B) => {
return b
}
fn({ a: 1 }) // { a: number }
fn<Fixed>({ a: 1 }) // {}
const fn2 = <A>() => <B extends {} = {}>(b: B) => {
return b
}
const result = fn2<Fixed>()({ a: 1 }) // { a: number }
Why is TypeScript not able to infer the type of B when I specify type A? Everything works again if I return a function that attempts to infer the type of B.