TypeScript/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.js
2014-07-12 17:30:19 -07:00

36 lines
1 KiB
JavaScript

//// [genericCallWithObjectTypeArgsAndInitializers.ts]
// Generic typed parameters with initializers
function foo<T>(x: T = null) { return x; } // ok
function foo2<T>(x: T = undefined) { return x; } // ok
function foo3<T extends Number>(x: T = 1) { } // error
function foo4<T, U extends T>(x: T, y: U = x) { } // error
function foo5<T, U extends T>(x: U, y: T = x) { } // ok
function foo6<T, U extends T, V extends U>(x: T, y: U, z: V = y) { } // error
function foo7<T, U extends T, V extends U>(x: V, y: U = x) { } // should be ok
//// [genericCallWithObjectTypeArgsAndInitializers.js]
function foo(x) {
if (x === void 0) { x = null; }
return x;
}
function foo2(x) {
if (x === void 0) { x = undefined; }
return x;
}
function foo3(x) {
if (x === void 0) { x = 1; }
}
function foo4(x, y) {
if (y === void 0) { y = x; }
}
function foo5(x, y) {
if (y === void 0) { y = x; }
}
function foo6(x, y, z) {
if (z === void 0) { z = y; }
}
function foo7(x, y) {
if (y === void 0) { y = x; }
}