File: checkExportsObjectAssignPrototypeProperty.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 (220 lines) | stat: -rw-r--r-- 6,575 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
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
=== tests/cases/conformance/jsdoc/validator.ts ===
import "./";

import Person = require("./mod1");
>Person : typeof Person

const m1 = new Person("Name")
>m1 : Person
>new Person("Name") : Person
>Person : typeof Person
>"Name" : "Name"

m1.thing;
>m1.thing : number
>m1 : Person
>thing : number

m1.readonlyProp;
>m1.readonlyProp : string
>m1 : Person
>readonlyProp : string

m1.rwAccessors;
>m1.rwAccessors : number
>m1 : Person
>rwAccessors : number

m1.readonlyAccessor;
>m1.readonlyAccessor : number
>m1 : Person
>readonlyAccessor : number

m1.setonlyAccessor;
>m1.setonlyAccessor : string
>m1 : Person
>setonlyAccessor : string

// allowed assignments
m1.thing = 10;
>m1.thing = 10 : 10
>m1.thing : number
>m1 : Person
>thing : number
>10 : 10

m1.rwAccessors = 11;
>m1.rwAccessors = 11 : 11
>m1.rwAccessors : number
>m1 : Person
>rwAccessors : number
>11 : 11

m1.setonlyAccessor = "yes";
>m1.setonlyAccessor = "yes" : "yes"
>m1.setonlyAccessor : string
>m1 : Person
>setonlyAccessor : string
>"yes" : "yes"

// disallowed assignments
m1.readonlyProp = "name";
>m1.readonlyProp = "name" : "name"
>m1.readonlyProp : any
>m1 : Person
>readonlyProp : any
>"name" : "name"

m1.readonlyAccessor = 12;
>m1.readonlyAccessor = 12 : 12
>m1.readonlyAccessor : any
>m1 : Person
>readonlyAccessor : any
>12 : 12

m1.thing = "no";
>m1.thing = "no" : "no"
>m1.thing : number
>m1 : Person
>thing : number
>"no" : "no"

m1.rwAccessors = "no";
>m1.rwAccessors = "no" : "no"
>m1.rwAccessors : number
>m1 : Person
>rwAccessors : number
>"no" : "no"

m1.setonlyAccessor = 0;
>m1.setonlyAccessor = 0 : 0
>m1.setonlyAccessor : string
>m1 : Person
>setonlyAccessor : string
>0 : 0


=== tests/cases/conformance/jsdoc/mod1.js ===
/**
 * @constructor
 * @param {string} name
 */
function Person(name) {
>Person : typeof Person
>name : string

    this.name = name;
>this.name = name : string
>this.name : string
>this : Person
>name : string
>name : string
}
Person.prototype.describe = function () {
>Person.prototype.describe = function () {    return "Person called " + this.name;} : () => string
>Person.prototype.describe : any
>Person.prototype : any
>Person : typeof Person
>prototype : any
>describe : any
>function () {    return "Person called " + this.name;} : () => string

    return "Person called " + this.name;
>"Person called " + this.name : string
>"Person called " : "Person called "
>this.name : string
>this : Person
>name : string

};
Object.defineProperty(Person.prototype, "thing", { value: 42, writable: true });
>Object.defineProperty(Person.prototype, "thing", { value: 42, writable: true }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Person.prototype : any
>Person : typeof Person
>prototype : any
>"thing" : "thing"
>{ value: 42, writable: true } : { value: number; writable: true; }
>value : number
>42 : 42
>writable : true
>true : true

Object.defineProperty(Person.prototype, "readonlyProp", { value: "Smith", writable: false });
>Object.defineProperty(Person.prototype, "readonlyProp", { value: "Smith", writable: false }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Person.prototype : any
>Person : typeof Person
>prototype : any
>"readonlyProp" : "readonlyProp"
>{ value: "Smith", writable: false } : { value: string; writable: false; }
>value : string
>"Smith" : "Smith"
>writable : false
>false : false

Object.defineProperty(Person.prototype, "rwAccessors", { get() { return 98122 }, set(_) { /*ignore*/ } });
>Object.defineProperty(Person.prototype, "rwAccessors", { get() { return 98122 }, set(_) { /*ignore*/ } }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Person.prototype : any
>Person : typeof Person
>prototype : any
>"rwAccessors" : "rwAccessors"
>{ get() { return 98122 }, set(_) { /*ignore*/ } } : { get(): number; set(_: any): void; }
>get : () => number
>98122 : 98122
>set : (_: any) => void
>_ : any

Object.defineProperty(Person.prototype, "readonlyAccessor", { get() { return 21.75 } });
>Object.defineProperty(Person.prototype, "readonlyAccessor", { get() { return 21.75 } }) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Person.prototype : any
>Person : typeof Person
>prototype : any
>"readonlyAccessor" : "readonlyAccessor"
>{ get() { return 21.75 } } : { get(): number; }
>get : () => number
>21.75 : 21.75

Object.defineProperty(Person.prototype, "setonlyAccessor", {
>Object.defineProperty(Person.prototype, "setonlyAccessor", {    /** @param {string} str */    set(str) {        this.rwAccessors = Number(str)    }}) : any
>Object.defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Object : ObjectConstructor
>defineProperty : (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any
>Person.prototype : any
>Person : typeof Person
>prototype : any
>"setonlyAccessor" : "setonlyAccessor"
>{    /** @param {string} str */    set(str) {        this.rwAccessors = Number(str)    }} : { set(str: string): void; }

    /** @param {string} str */
    set(str) {
>set : (str: string) => void
>str : string

        this.rwAccessors = Number(str)
>this.rwAccessors = Number(str) : number
>this.rwAccessors : number
>this : Person
>rwAccessors : number
>Number(str) : number
>Number : NumberConstructor
>str : string
    }
});
module.exports = Person;
>module.exports = Person : typeof Person
>module.exports : typeof Person
>module : { "tests/cases/conformance/jsdoc/mod1": typeof Person; }
>exports : typeof Person
>Person : typeof Person