You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
You can use the latest bits in master right now. For a Visual Studio release this will be in 1.4, unfortunately we can't share a date right now but you can track the progress here:
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.
The text was updated successfully, but these errors were encountered: