File: jsDeclarationsFunctionLikeClasses2.types

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (257 lines) | stat: -rw-r--r-- 7,432 bytes parent folder | download | duplicates (4)
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
=== tests/cases/conformance/jsdoc/declarations/source.js ===
/**
 * @param {number} len
 */
export function Vec(len) {
>Vec : typeof Vec
>len : number

    /**
     * @type {number[]}
     */
    this.storage = new Array(len);
>this.storage = new Array(len) : any[]
>this.storage : number[]
>this : this
>storage : number[]
>new Array(len) : any[]
>Array : ArrayConstructor
>len : number
}

Vec.prototype = {
>Vec.prototype = {    /**     * @param {Vec} other     */    dot(other) {        if (other.storage.length !== this.storage.length) {            throw new Error(`Dot product only applicable for vectors of equal length`);        }        let sum = 0;        for (let i = 0; i < this.storage.length; i++) {            sum += (this.storage[i] * other.storage[i]);        }        return sum;    },    magnitude() {        let sum = 0;        for (let i = 0; i < this.storage.length; i++) {            sum += (this.storage[i] ** 2);        }        return Math.sqrt(sum);    }} : { dot(other: Vec): number; magnitude(): number; }
>Vec.prototype : { dot(other: Vec): number; magnitude(): number; }
>Vec : typeof Vec
>prototype : { dot(other: Vec): number; magnitude(): number; }
>{    /**     * @param {Vec} other     */    dot(other) {        if (other.storage.length !== this.storage.length) {            throw new Error(`Dot product only applicable for vectors of equal length`);        }        let sum = 0;        for (let i = 0; i < this.storage.length; i++) {            sum += (this.storage[i] * other.storage[i]);        }        return sum;    },    magnitude() {        let sum = 0;        for (let i = 0; i < this.storage.length; i++) {            sum += (this.storage[i] ** 2);        }        return Math.sqrt(sum);    }} : { dot(other: Vec): number; magnitude(): number; }

    /**
     * @param {Vec} other
     */
    dot(other) {
>dot : (other: Vec) => number
>other : Vec

        if (other.storage.length !== this.storage.length) {
>other.storage.length !== this.storage.length : boolean
>other.storage.length : number
>other.storage : number[]
>other : Vec
>storage : number[]
>length : number
>this.storage.length : number
>this.storage : number[]
>this : this
>storage : number[]
>length : number

            throw new Error(`Dot product only applicable for vectors of equal length`);
>new Error(`Dot product only applicable for vectors of equal length`) : Error
>Error : ErrorConstructor
>`Dot product only applicable for vectors of equal length` : "Dot product only applicable for vectors of equal length"
        }
        let sum = 0;
>sum : number
>0 : 0

        for (let i = 0; i < this.storage.length; i++) {
>i : number
>0 : 0
>i < this.storage.length : boolean
>i : number
>this.storage.length : number
>this.storage : number[]
>this : this
>storage : number[]
>length : number
>i++ : number
>i : number

            sum += (this.storage[i] * other.storage[i]);
>sum += (this.storage[i] * other.storage[i]) : number
>sum : number
>(this.storage[i] * other.storage[i]) : number
>this.storage[i] * other.storage[i] : number
>this.storage[i] : number
>this.storage : number[]
>this : this
>storage : number[]
>i : number
>other.storage[i] : number
>other.storage : number[]
>other : Vec
>storage : number[]
>i : number
        }
        return sum;
>sum : number

    },
    magnitude() {
>magnitude : () => number

        let sum = 0;
>sum : number
>0 : 0

        for (let i = 0; i < this.storage.length; i++) {
>i : number
>0 : 0
>i < this.storage.length : boolean
>i : number
>this.storage.length : number
>this.storage : number[]
>this : this
>storage : number[]
>length : number
>i++ : number
>i : number

            sum += (this.storage[i] ** 2);
>sum += (this.storage[i] ** 2) : number
>sum : number
>(this.storage[i] ** 2) : number
>this.storage[i] ** 2 : number
>this.storage[i] : number
>this.storage : number[]
>this : this
>storage : number[]
>i : number
>2 : 2
        }
        return Math.sqrt(sum);
>Math.sqrt(sum) : number
>Math.sqrt : (x: number) => number
>Math : Math
>sqrt : (x: number) => number
>sum : number
    }
}

/**
 * @param {number} x
 * @param {number} y
 */
export function Point2D(x, y) {
>Point2D : typeof Point2D
>x : number
>y : number

    if (!(this instanceof Point2D)) {
>!(this instanceof Point2D) : boolean
>(this instanceof Point2D) : boolean
>this instanceof Point2D : boolean
>this : this
>Point2D : typeof Point2D

        return new Point2D(x, y);
>new Point2D(x, y) : Point2D
>Point2D : typeof Point2D
>x : number
>y : number
    }
    Vec.call(this, 2);
>Vec.call(this, 2) : any
>Vec.call : (this: Function, thisArg: any, ...argArray: any[]) => any
>Vec : typeof Vec
>call : (this: Function, thisArg: any, ...argArray: any[]) => any
>this : this
>2 : 2

    this.x = x;
>this.x = x : number
>this.x : number
>this : this
>x : number
>x : number

    this.y = y;
>this.y = y : number
>this.y : number
>this : this
>y : number
>y : number
}

Point2D.prototype = {
>Point2D.prototype = {    __proto__: Vec,    get x() {        return this.storage[0];    },    /**     * @param {number} x     */    set x(x) {        this.storage[0] = x;    },    get y() {        return this.storage[1];    },    /**     * @param {number} y     */    set y(y) {        this.storage[1] = y;    }} : { __proto__: typeof Vec; x: number; y: number; }
>Point2D.prototype : { __proto__: typeof Vec; x: number; y: number; }
>Point2D : typeof Point2D
>prototype : { __proto__: typeof Vec; x: number; y: number; }
>{    __proto__: Vec,    get x() {        return this.storage[0];    },    /**     * @param {number} x     */    set x(x) {        this.storage[0] = x;    },    get y() {        return this.storage[1];    },    /**     * @param {number} y     */    set y(y) {        this.storage[1] = y;    }} : { __proto__: typeof Vec; x: number; y: number; }

    __proto__: Vec,
>__proto__ : typeof Vec
>Vec : typeof Vec

    get x() {
>x : number

        return this.storage[0];
>this.storage[0] : any
>this.storage : any
>this : { __proto__: typeof Vec; x: number; y: number; }
>storage : any
>0 : 0

    },
    /**
     * @param {number} x
     */
    set x(x) {
>x : number
>x : number

        this.storage[0] = x;
>this.storage[0] = x : number
>this.storage[0] : any
>this.storage : any
>this : { __proto__: typeof Vec; x: number; y: number; }
>storage : any
>0 : 0
>x : number

    },
    get y() {
>y : number

        return this.storage[1];
>this.storage[1] : any
>this.storage : any
>this : { __proto__: typeof Vec; x: number; y: number; }
>storage : any
>1 : 1

    },
    /**
     * @param {number} y
     */
    set y(y) {
>y : number
>y : number

        this.storage[1] = y;
>this.storage[1] = y : number
>this.storage[1] : any
>this.storage : any
>this : { __proto__: typeof Vec; x: number; y: number; }
>storage : any
>1 : 1
>y : number
    }
};

=== tests/cases/conformance/jsdoc/declarations/referencer.js ===
import {Point2D} from "./source";
>Point2D : typeof Point2D

export const origin = new Point2D(0, 0);
>origin : Point2D
>new Point2D(0, 0) : Point2D
>Point2D : typeof Point2D
>0 : 0
>0 : 0

// export const res = Point2D(2, 3).dot(origin); // TODO: when __proto__ works, validate this