File: constructorFunctionsStrict.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 (94 lines) | stat: -rw-r--r-- 1,508 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
=== tests/cases/conformance/salsa/a.js ===
/** @param {number} x */
function C(x) {
>C : typeof C
>x : number

    this.x = x
>this.x = x : number
>this.x : any
>this : any
>x : any
>x : number
}
C.prototype.m = function() {
>C.prototype.m = function() {    this.y = 12} : () => void
>C.prototype.m : any
>C.prototype : any
>C : typeof C
>prototype : any
>m : any
>function() {    this.y = 12} : () => void

    this.y = 12
>this.y = 12 : 12
>this.y : number | undefined
>this : C
>y : number | undefined
>12 : 12
}
var c = new C(1)
>c : C
>new C(1) : C
>C : typeof C
>1 : 1

c.x = undefined // should error
>c.x = undefined : undefined
>c.x : number
>c : C
>x : number
>undefined : undefined

c.y = undefined // ok
>c.y = undefined : undefined
>c.y : number | undefined
>c : C
>y : number | undefined
>undefined : undefined

/** @param {number} x */
function A(x) {
>A : typeof A
>x : number

    if (!(this instanceof A)) {
>!(this instanceof A) : boolean
>(this instanceof A) : boolean
>this instanceof A : boolean
>this : any
>A : typeof A

        return new A(x)
>new A(x) : A
>A : typeof A
>x : number
    }
    this.x = x
>this.x = x : number
>this.x : any
>this : any
>x : any
>x : number
}
var k = A(1)
>k : A
>A(1) : A
>A : typeof A
>1 : 1

var j = new A(2)
>j : A
>new A(2) : A
>A : typeof A
>2 : 2

k.x === j.x
>k.x === j.x : boolean
>k.x : number
>k : A
>x : number
>j.x : number
>j : A
>x : number