2014-07-13 01:04:16 +02:00
|
|
|
//// [newOperatorConformance.ts]
|
|
|
|
|
|
|
|
class C0 {
|
|
|
|
|
|
|
|
}
|
|
|
|
class C1 {
|
|
|
|
constructor(n: number, s: string) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
class T<T> {
|
|
|
|
constructor(n?: T) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
var anyCtor: {
|
|
|
|
new (): any;
|
|
|
|
};
|
|
|
|
|
|
|
|
var anyCtor1: {
|
|
|
|
new (n): any;
|
|
|
|
};
|
|
|
|
|
|
|
|
interface nestedCtor {
|
|
|
|
new (): nestedCtor;
|
|
|
|
}
|
|
|
|
var nestedCtor: nestedCtor;
|
|
|
|
|
|
|
|
// Construct expression with no parentheses for construct signature with 0 parameters
|
|
|
|
var a = new C0;
|
|
|
|
var a: C0;
|
|
|
|
|
|
|
|
|
|
|
|
// Generic construct expression with no parentheses
|
|
|
|
var c1 = new T;
|
|
|
|
var c1: T<{}>;
|
|
|
|
|
|
|
|
// Construct expression where constructor is of type 'any' with no parentheses
|
|
|
|
var d = new anyCtor;
|
|
|
|
var d: any;
|
|
|
|
|
|
|
|
// Construct expression where constructor is of type 'any' with > 1 arg
|
|
|
|
var d = new anyCtor1(undefined);
|
|
|
|
|
|
|
|
// Construct expression of type where apparent type has a construct signature with 0 arguments
|
|
|
|
function newFn1<T extends { new (): number }>(s: T) {
|
|
|
|
var p = new s;
|
|
|
|
var p: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Construct expression of type where apparent type has a construct signature with 1 arguments
|
|
|
|
function newFn2<T extends { new (s: number): string}>(s: T) {
|
|
|
|
var p = new s(32);
|
|
|
|
var p: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Construct expression of void returning function
|
|
|
|
function fnVoid(): void { }
|
|
|
|
var t = new fnVoid();
|
|
|
|
var t: any;
|
|
|
|
|
|
|
|
// Chained new expressions
|
|
|
|
var nested = new (new (new nestedCtor())())();
|
|
|
|
var n = new nested();
|
|
|
|
var n = new nested();
|
|
|
|
|
|
|
|
|
|
|
|
//// [newOperatorConformance.js]
|
|
|
|
var C0 = (function () {
|
|
|
|
function C0() {
|
|
|
|
}
|
|
|
|
return C0;
|
|
|
|
})();
|
|
|
|
var C1 = (function () {
|
|
|
|
function C1(n, s) {
|
|
|
|
}
|
|
|
|
return C1;
|
|
|
|
})();
|
|
|
|
var T = (function () {
|
|
|
|
function T(n) {
|
|
|
|
}
|
|
|
|
return T;
|
|
|
|
})();
|
|
|
|
var anyCtor;
|
|
|
|
var anyCtor1;
|
|
|
|
var nestedCtor;
|
2014-08-12 00:54:12 +02:00
|
|
|
// Construct expression with no parentheses for construct signature with 0 parameters
|
2014-07-13 01:04:16 +02:00
|
|
|
var a = new C0;
|
|
|
|
var a;
|
2014-08-12 00:54:12 +02:00
|
|
|
// Generic construct expression with no parentheses
|
2014-07-13 01:04:16 +02:00
|
|
|
var c1 = new T;
|
|
|
|
var c1;
|
2014-08-12 00:54:12 +02:00
|
|
|
// Construct expression where constructor is of type 'any' with no parentheses
|
2014-07-13 01:04:16 +02:00
|
|
|
var d = new anyCtor;
|
|
|
|
var d;
|
2014-08-12 00:54:12 +02:00
|
|
|
// Construct expression where constructor is of type 'any' with > 1 arg
|
2014-07-13 01:04:16 +02:00
|
|
|
var d = new anyCtor1(undefined);
|
2014-08-14 15:21:30 +02:00
|
|
|
// Construct expression of type where apparent type has a construct signature with 0 arguments
|
2014-07-13 01:04:16 +02:00
|
|
|
function newFn1(s) {
|
|
|
|
var p = new s;
|
|
|
|
var p;
|
|
|
|
}
|
2014-08-14 15:21:30 +02:00
|
|
|
// Construct expression of type where apparent type has a construct signature with 1 arguments
|
2014-07-13 01:04:16 +02:00
|
|
|
function newFn2(s) {
|
|
|
|
var p = new s(32);
|
|
|
|
var p;
|
|
|
|
}
|
2014-08-14 15:21:30 +02:00
|
|
|
// Construct expression of void returning function
|
2014-07-13 01:04:16 +02:00
|
|
|
function fnVoid() {
|
|
|
|
}
|
|
|
|
var t = new fnVoid();
|
|
|
|
var t;
|
2014-08-12 00:54:12 +02:00
|
|
|
// Chained new expressions
|
2014-07-13 01:04:16 +02:00
|
|
|
var nested = new (new (new nestedCtor())())();
|
|
|
|
var n = new nested();
|
|
|
|
var n = new nested();
|