-
Notifications
You must be signed in to change notification settings - Fork 12.2k
/
newOperatorErrorCases.errors.txt
55 lines (43 loc) · 2.13 KB
/
newOperatorErrorCases.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
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(26,16): error TS1005: ',' expected.
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(26,16): error TS2695: Left side of comma operator is unused and has no side effects.
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(30,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/newOperatorErrorCases.ts(31,23): error TS1005: '(' expected.
tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts(36,9): error TS2350: Only a void function can be called with the 'new' keyword.
==== tests/cases/conformance/expressions/newOperator/newOperatorErrorCases.ts (5 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 b = new C0 32, ''; // Parse error
~~
!!! error TS1005: ',' expected.
~~
!!! error TS2695: Left side of comma operator is unused and has no side effects.
// 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<{}>'.
var c2 = new T<string>; // Parse error
~
!!! error TS1005: '(' expected.
// Construct expression of non-void returning function
function fnNumber(): number { return 32; }
var s = new fnNumber(); // Error
~~~~~~~~~~~~~~
!!! error TS2350: Only a void function can be called with the 'new' keyword.