File: constructorFunctions.types

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (184 lines) | stat: -rw-r--r-- 3,245 bytes parent folder | download
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
=== tests/cases/conformance/salsa/index.js ===
function C1() {
>C1 : typeof C1

    if (!(this instanceof C1)) return new C1();
>!(this instanceof C1) : boolean
>(this instanceof C1) : boolean
>this instanceof C1 : boolean
>this : any
>C1 : typeof C1
>new C1() : C1
>C1 : typeof C1

    this.x = 1;
>this.x = 1 : 1
>this.x : any
>this : any
>x : any
>1 : 1
}

const c1_v1 = C1();
>c1_v1 : C1
>C1() : C1
>C1 : typeof C1

const c1_v2 = new C1();
>c1_v2 : C1
>new C1() : C1
>C1 : typeof C1

var C2 = function () {
>C2 : typeof C2
>function () {    if (!(this instanceof C2)) return new C2();    this.x = 1;} : typeof C2

    if (!(this instanceof C2)) return new C2();
>!(this instanceof C2) : boolean
>(this instanceof C2) : boolean
>this instanceof C2 : boolean
>this : any
>C2 : typeof C2
>new C2() : C2
>C2 : typeof C2

    this.x = 1;
>this.x = 1 : 1
>this.x : any
>this : any
>x : any
>1 : 1

};

const c2_v1 = C2();
>c2_v1 : C2
>C2() : C2
>C2 : typeof C2

const c2_v2 = new C2();
>c2_v2 : C2
>new C2() : C2
>C2 : typeof C2

/** @class */
function C3() {
>C3 : typeof C3

    if (!(this instanceof C3)) return new C3();
>!(this instanceof C3) : boolean
>(this instanceof C3) : boolean
>this instanceof C3 : boolean
>this : C3
>C3 : typeof C3
>new C3() : C3
>C3 : typeof C3

};

const c3_v1 = C3(); // error: @class tag requires 'new'
>c3_v1 : any
>C3() : any
>C3 : typeof C3

const c3_v2 = new C3();
>c3_v2 : C3
>new C3() : C3
>C3 : typeof C3

/** @class */
var C4 = function () {
>C4 : typeof C4
>function () {    if (!(this instanceof C4)) return new C4();} : typeof C4

    if (!(this instanceof C4)) return new C4();
>!(this instanceof C4) : boolean
>(this instanceof C4) : boolean
>this instanceof C4 : boolean
>this : C4
>C4 : typeof C4
>new C4() : C4
>C4 : typeof C4

};

const c4_v1 = C4(); // error: @class tag requires 'new'
>c4_v1 : any
>C4() : any
>C4 : typeof C4

const c4_v2 = new C4();
>c4_v2 : C4
>new C4() : C4
>C4 : typeof C4

var c5_v1;
>c5_v1 : any

c5_v1 = function f() { };
>c5_v1 = function f() { } : () => void
>c5_v1 : any
>function f() { } : () => void
>f : () => void

new c5_v1();
>new c5_v1() : any
>c5_v1 : () => void

var c5_v2;
>c5_v2 : any

c5_v2 = class { };
>c5_v2 = class { } : typeof c5_v2
>c5_v2 : any
>class { } : typeof c5_v2

new c5_v2();
>new c5_v2() : c5_v2
>c5_v2 : typeof c5_v2

/** @class */
function C6() {
>C6 : typeof C6

  this.functions = [x => x, x => x + 1, x => x - 1]
>this.functions = [x => x, x => x + 1, x => x - 1] : ((x: any) => any)[]
>this.functions : ((x: any) => any)[]
>this : C6
>functions : ((x: any) => any)[]
>[x => x, x => x + 1, x => x - 1] : ((x: any) => any)[]
>x => x : (x: any) => any
>x : any
>x : any
>x => x + 1 : (x: any) => any
>x : any
>x + 1 : any
>x : any
>1 : 1
>x => x - 1 : (x: any) => number
>x : any
>x - 1 : number
>x : any
>1 : 1

};

var c6_v1 = new C6();
>c6_v1 : C6
>new C6() : C6
>C6 : typeof C6


/**
 * @constructor
 * @param {number} num
 */
function C7(num) {}
>C7 : typeof C7
>num : number

var c7_v1 = new C7();
>c7_v1 : any
>new C7() : any
>C7 : typeof C7