How TypeScript infers callbacks arguments type
问题 My question is based on this question and answer Let's say we have next code: const myFn = <T,>(p: { a: (n: number) => T, b: (o: T) => void, }) => { // ... } myFn({ a: () => ({ n: 0 }), // Parameter of a is ignored b: o => { o.n }, // Works! }) myFn({ a: i => ({ n: 0 }), // Parameter i is used b: o => { o.n }, // Error at o: Object is of type 'unknown'.ts(2571) }) I was able to fix it. It works with extra generic: const myFn = <T,>(p: { a: (n: number) => T, b: <U extends T /* EXTRA U generic