-
Notifications
You must be signed in to change notification settings - Fork 12.2k
/
newOperatorConformance.errors.txt
68 lines (51 loc) · 2.05 KB
/
newOperatorConformance.errors.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
tests/cases/conformance/expressions/newOperator/newOperatorConformance.ts(32,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'c1' must be of type 'T<unknown>', but here has type 'T<{}>'.
==== tests/cases/conformance/expressions/newOperator/newOperatorConformance.ts (1 errors) ====
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<{}>;
~~
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'c1' must be of type 'T<unknown>', but here has type '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();