Skip to content

Commit 360207d

Browse files
committed
Move types in supplement.d.ts to class properties
1 parent 4691ddb commit 360207d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+707
-593
lines changed

lib/productions/base.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ export class Base {
2222
*/
2323
constructor({ source, tokens }) {
2424
Object.defineProperties(this, {
25-
source: { value: source },
26-
tokens: { value: tokens, writable: true },
27-
parent: { value: null, writable: true },
28-
this: { value: this }, // useful when escaping from proxy
25+
source: { value: source, enumerable: false },
26+
tokens: { value: tokens, writable: true, enumerable: false },
27+
parent: { value: null, writable: true, enumerable: false },
28+
this: { value: this, enumerable: false }, // useful when escaping from proxy
2929
});
3030
}
3131

@@ -50,7 +50,6 @@ export class Base {
5050
const descMap = Object.getOwnPropertyDescriptors(proto);
5151
for (const [key, value] of Object.entries(descMap)) {
5252
if (value.enumerable || value.get) {
53-
// @ts-ignore - allow indexing here
5453
json[key] = this[key];
5554
}
5655
}

lib/productions/extended-attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export class SimpleExtendedAttribute extends Base {
146146
constructor({ source, tokens, params }) {
147147
super({ source, tokens });
148148
params.parent = this;
149-
Object.defineProperty(this, "params", { value: params });
149+
Object.defineProperty(this, "params", { value: params, enumerable: false });
150150
}
151151

152152
get type() {

lib/productions/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export { Attribute } from "./attribute.js";
33
export { Base } from "./base.js";
44
export { Constant } from "./constant.js";
55
export { Constructor } from "./constructor.js";
6-
export { Container } from "./container.js";
6+
export { Container, parseContainer } from "./container.js";
77
export { Default } from "./default.js";
88
export {
99
ExtendedAttributes,

lib/productions/type.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,11 @@ export class Type extends Base {
174174

175175
constructor({ source, tokens }) {
176176
super({ source, tokens });
177-
Object.defineProperty(this, "subtype", { value: [], writable: true });
177+
Object.defineProperty(this, "subtype", {
178+
value: [],
179+
writable: true,
180+
enumerable: false,
181+
});
178182
this.extAttrs = new ExtendedAttributes({ source, tokens: {} });
179183
}
180184

test/syntax/baseline/allowany.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
"type": "interface",
44
"name": "B",
55
"inheritance": null,
6+
"extAttrs": [],
67
"members": [
78
{
89
"type": "operation",
910
"name": "g",
11+
"extAttrs": [],
1012
"idlType": {
1113
"type": "return-type",
1214
"extAttrs": [],
@@ -16,12 +18,12 @@
1618
"idlType": "undefined"
1719
},
1820
"arguments": [],
19-
"extAttrs": [],
2021
"special": ""
2122
},
2223
{
2324
"type": "operation",
2425
"name": "g",
26+
"extAttrs": [],
2527
"idlType": {
2628
"type": "return-type",
2729
"extAttrs": [],
@@ -48,12 +50,12 @@
4850
"variadic": false
4951
}
5052
],
51-
"extAttrs": [],
5253
"special": ""
5354
},
5455
{
5556
"type": "operation",
5657
"name": "g",
58+
"extAttrs": [],
5759
"idlType": {
5860
"type": "return-type",
5961
"extAttrs": [],
@@ -87,11 +89,9 @@
8789
"variadic": false
8890
}
8991
],
90-
"extAttrs": [],
9192
"special": ""
9293
}
9394
],
94-
"extAttrs": [],
9595
"partial": false
9696
},
9797
{

test/syntax/baseline/argument-constructor.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,22 @@
33
"type": "interface",
44
"name": "Foo",
55
"inheritance": null,
6+
"extAttrs": [
7+
{
8+
"type": "extended-attribute",
9+
"name": "Exposed",
10+
"rhs": {
11+
"type": "identifier",
12+
"value": "Window"
13+
},
14+
"arguments": []
15+
}
16+
],
617
"members": [
718
{
819
"type": "operation",
920
"name": "foo",
21+
"extAttrs": [],
1022
"idlType": {
1123
"type": "return-type",
1224
"extAttrs": [],
@@ -33,21 +45,9 @@
3345
"variadic": false
3446
}
3547
],
36-
"extAttrs": [],
3748
"special": ""
3849
}
3950
],
40-
"extAttrs": [
41-
{
42-
"type": "extended-attribute",
43-
"name": "Exposed",
44-
"rhs": {
45-
"type": "identifier",
46-
"value": "Window"
47-
},
48-
"arguments": []
49-
}
50-
],
5151
"partial": false
5252
},
5353
{

test/syntax/baseline/argument-extattrs.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
"type": "interface",
44
"name": "Foo",
55
"inheritance": null,
6+
"extAttrs": [],
67
"members": [
78
{
89
"type": "operation",
910
"name": "foo",
11+
"extAttrs": [],
1012
"idlType": {
1113
"type": "return-type",
1214
"extAttrs": [],
@@ -47,11 +49,9 @@
4749
"variadic": false
4850
}
4951
],
50-
"extAttrs": [],
5152
"special": ""
5253
}
5354
],
54-
"extAttrs": [],
5555
"partial": false
5656
},
5757
{

test/syntax/baseline/async-iterable.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
"type": "interface",
44
"name": "AsyncIterable",
55
"inheritance": null,
6+
"extAttrs": [],
67
"members": [
78
{
89
"type": "async_iterable",
10+
"extAttrs": [],
911
"idlType": [
1012
{
1113
"type": null,
@@ -25,21 +27,21 @@
2527
}
2628
],
2729
"arguments": [],
28-
"extAttrs": [],
2930
"readonly": false,
3031
"async": false
3132
}
3233
],
33-
"extAttrs": [],
3434
"partial": false
3535
},
3636
{
3737
"type": "interface",
3838
"name": "AsyncIterableWithExtAttr",
3939
"inheritance": null,
40+
"extAttrs": [],
4041
"members": [
4142
{
4243
"type": "async_iterable",
44+
"extAttrs": [],
4345
"idlType": [
4446
{
4547
"type": null,
@@ -73,21 +75,21 @@
7375
}
7476
],
7577
"arguments": [],
76-
"extAttrs": [],
7778
"readonly": false,
7879
"async": false
7980
}
8081
],
81-
"extAttrs": [],
8282
"partial": false
8383
},
8484
{
8585
"type": "interface",
8686
"name": "AsyncIterableWithNoParam",
8787
"inheritance": null,
88+
"extAttrs": [],
8889
"members": [
8990
{
9091
"type": "async_iterable",
92+
"extAttrs": [],
9193
"idlType": [
9294
{
9395
"type": null,
@@ -107,21 +109,21 @@
107109
}
108110
],
109111
"arguments": [],
110-
"extAttrs": [],
111112
"readonly": false,
112113
"async": false
113114
}
114115
],
115-
"extAttrs": [],
116116
"partial": false
117117
},
118118
{
119119
"type": "interface",
120120
"name": "AsyncIterableWithParam",
121121
"inheritance": null,
122+
"extAttrs": [],
122123
"members": [
123124
{
124125
"type": "async_iterable",
126+
"extAttrs": [],
125127
"idlType": [
126128
{
127129
"type": null,
@@ -158,21 +160,21 @@
158160
"variadic": false
159161
}
160162
],
161-
"extAttrs": [],
162163
"readonly": false,
163164
"async": false
164165
}
165166
],
166-
"extAttrs": [],
167167
"partial": false
168168
},
169169
{
170170
"type": "interface",
171171
"name": "AsyncValueIterable",
172172
"inheritance": null,
173+
"extAttrs": [],
173174
"members": [
174175
{
175176
"type": "async_iterable",
177+
"extAttrs": [],
176178
"idlType": [
177179
{
178180
"type": null,
@@ -184,21 +186,21 @@
184186
}
185187
],
186188
"arguments": [],
187-
"extAttrs": [],
188189
"readonly": false,
189190
"async": false
190191
}
191192
],
192-
"extAttrs": [],
193193
"partial": false
194194
},
195195
{
196196
"type": "interface",
197197
"name": "AsyncValueIterableWithNoParam",
198198
"inheritance": null,
199+
"extAttrs": [],
199200
"members": [
200201
{
201202
"type": "async_iterable",
203+
"extAttrs": [],
202204
"idlType": [
203205
{
204206
"type": null,
@@ -210,21 +212,21 @@
210212
}
211213
],
212214
"arguments": [],
213-
"extAttrs": [],
214215
"readonly": false,
215216
"async": false
216217
}
217218
],
218-
"extAttrs": [],
219219
"partial": false
220220
},
221221
{
222222
"type": "interface",
223223
"name": "AsyncValueIterableWithParams",
224224
"inheritance": null,
225+
"extAttrs": [],
225226
"members": [
226227
{
227228
"type": "async_iterable",
229+
"extAttrs": [],
228230
"idlType": [
229231
{
230232
"type": null,
@@ -269,12 +271,10 @@
269271
"variadic": false
270272
}
271273
],
272-
"extAttrs": [],
273274
"readonly": false,
274275
"async": false
275276
}
276277
],
277-
"extAttrs": [],
278278
"partial": false
279279
},
280280
{

0 commit comments

Comments
 (0)