I define a function with multiple generics, and give them default types. For example:
function fun<A = any, B = any>(a: A, b: B) {
return [a, b] as const;
}
If I don't assign any types to them, the generics will be infered correctly.
let a: number;
let b: string;
const res = fun(a, b); // [number, string]
But if I assign a certain type to part of them, the rest generics will be infered by their default types.
let a: number;
let b: string;
const res = fun<number>(a, b); // [number, any]
How can I assign some generics as well as keeping the rest generics inferring themselves?