Closed
Description
I used to use generics in Java to define constraints between the different arguments of a function.
In TypeScript, they are a little more limited.
For example:
function test(a: T, b: T): void {
}
test(1, 2); //It works with T as number
test("a", 2); //It works with T as {}
test("a", 2); //Error "a" is not a number
I wish I did not have to specify the "number" type as we can do in Java.
For me test("a", 2) should cause an error. Compiler inference should not find {} as common type.