I am stumped by this and cannot figure out how to do this without 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 does Typescript not infer the type of B if I fix type A? If I return a function that in turn tries to infer the type of B everything works again.