Here is generics infer(not infer keyword) demo:
function foo<A>(a: A): A {}
const result = foo({ a: 1 });
// const result: {
// a: number;
// }
But it seems i can't add some "extra" types to function foo, otherwise infer will not working:
function foo<Extra, A>(a: A): A & Extra {}
const result = foo<{ b: number }>({ a: 1 });
// const result: {
// b: number;
// }
So, what i want is the function foo can both has type a and b in the above example, can anyone help?