TypeScript/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.js
Sheetal Nandi 6ab3adfd43 Modified the emitComment logic to handle emitting leading or trailing spaces depending on flags
Leading comments have trailing separator while trailing comments have leading space
This removes the extra trailing space in the trailing comments
2014-08-15 14:32:08 -07:00

37 lines
1.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]
// Generic typed parameters with initializers
function foo(x) {
if (x === void 0) { x = null; }
return x;
} // ok
function foo2(x) {
if (x === void 0) { x = undefined; }
return x;
} // ok
function foo3(x) {
if (x === void 0) { x = 1; }
} // error
function foo4(x, y) {
if (y === void 0) { y = x; }
} // error
function foo5(x, y) {
if (y === void 0) { y = x; }
} // ok
function foo6(x, y, z) {
if (z === void 0) { z = y; }
} // error
function foo7(x, y) {
if (y === void 0) { y = x; }
} // should be ok