Closed
Description
TypeScript Version: 2.1.1 / nightly (2.2.0-dev.201xxxxx)
Code
function add<T extends string | number>(x: T, y: T): T {
return x + y;
}
add<string>("a", "b");
add<number>(5, 3);
add("a", "b");
add(5, 3);
Expected behavior:
Code to compile fine, because T
is of type string | number
and therefore can have the +
operator applied.
Actual behavior:
Operator '+' cannot be applied to types 'T' and 'T'.