Skip to content

Commit 5c85feb

Browse files
pathurssandersn
andauthored
Fix Get/Set being enumerable (#32264)
* Fix Get/Set being enumerable fixes #3610 * fix tests Co-authored-by: Nathan Shively-Sanders <[email protected]>
1 parent e7c578a commit 5c85feb

File tree

296 files changed

+1541
-1317
lines changed

Some content is hidden

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

296 files changed

+1541
-1317
lines changed

src/compiler/factory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ namespace ts {
566566
properties.push(setter);
567567
}
568568

569-
properties.push(createPropertyAssignment("enumerable", createTrue()));
569+
properties.push(createPropertyAssignment("enumerable", getAccessor || setAccessor ? createFalse() : createTrue()));
570570
properties.push(createPropertyAssignment("configurable", createTrue()));
571571

572572
const expression = setTextRange(

src/compiler/transformers/es2015.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,7 @@ namespace ts {
16751675
}
16761676

16771677
properties.push(
1678-
createPropertyAssignment("enumerable", createTrue()),
1678+
createPropertyAssignment("enumerable", getAccessor || setAccessor ? createFalse() : createTrue()),
16791679
createPropertyAssignment("configurable", createTrue())
16801680
);
16811681

tests/baselines/reference/MemberAccessorDeclaration15.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var C = /** @class */ (function () {
99
}
1010
Object.defineProperty(C.prototype, "Foo", {
1111
set: function (a) { },
12-
enumerable: true,
12+
enumerable: false,
1313
configurable: true
1414
});
1515
return C;

tests/baselines/reference/abstractProperty.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var C = /** @class */ (function (_super) {
5151
Object.defineProperty(C.prototype, "prop", {
5252
get: function () { return "foo"; },
5353
set: function (v) { },
54-
enumerable: true,
54+
enumerable: false,
5555
configurable: true
5656
});
5757
C.prototype.m = function () { };

tests/baselines/reference/abstractPropertyNegative.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ var C = /** @class */ (function (_super) {
7171
}
7272
Object.defineProperty(C.prototype, "concreteWithNoBody", {
7373
get: function () { },
74-
enumerable: true,
74+
enumerable: false,
7575
configurable: true
7676
});
7777
return C;
@@ -104,7 +104,7 @@ var WrongTypeAccessorImpl = /** @class */ (function (_super) {
104104
}
105105
Object.defineProperty(WrongTypeAccessorImpl.prototype, "num", {
106106
get: function () { return "nope, wrong"; },
107-
enumerable: true,
107+
enumerable: false,
108108
configurable: true
109109
});
110110
return WrongTypeAccessorImpl;
@@ -123,13 +123,13 @@ var AbstractAccessorMismatch = /** @class */ (function () {
123123
}
124124
Object.defineProperty(AbstractAccessorMismatch.prototype, "p1", {
125125
set: function (val) { },
126-
enumerable: true,
126+
enumerable: false,
127127
configurable: true
128128
});
129129
;
130130
Object.defineProperty(AbstractAccessorMismatch.prototype, "p2", {
131131
get: function () { return "should work"; },
132-
enumerable: true,
132+
enumerable: false,
133133
configurable: true
134134
});
135135
return AbstractAccessorMismatch;

tests/baselines/reference/accessibilityModifiers.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,34 +52,34 @@ var C = /** @class */ (function () {
5252
C.privateMethod = function () { };
5353
Object.defineProperty(C, "privateGetter", {
5454
get: function () { return 0; },
55-
enumerable: true,
55+
enumerable: false,
5656
configurable: true
5757
});
5858
Object.defineProperty(C, "privateSetter", {
5959
set: function (a) { },
60-
enumerable: true,
60+
enumerable: false,
6161
configurable: true
6262
});
6363
C.protectedMethod = function () { };
6464
Object.defineProperty(C, "protectedGetter", {
6565
get: function () { return 0; },
66-
enumerable: true,
66+
enumerable: false,
6767
configurable: true
6868
});
6969
Object.defineProperty(C, "protectedSetter", {
7070
set: function (a) { },
71-
enumerable: true,
71+
enumerable: false,
7272
configurable: true
7373
});
7474
C.publicMethod = function () { };
7575
Object.defineProperty(C, "publicGetter", {
7676
get: function () { return 0; },
77-
enumerable: true,
77+
enumerable: false,
7878
configurable: true
7979
});
8080
Object.defineProperty(C, "publicSetter", {
8181
set: function (a) { },
82-
enumerable: true,
82+
enumerable: false,
8383
configurable: true
8484
});
8585
return C;
@@ -91,34 +91,34 @@ var D = /** @class */ (function () {
9191
D.privateMethod = function () { };
9292
Object.defineProperty(D, "privateGetter", {
9393
get: function () { return 0; },
94-
enumerable: true,
94+
enumerable: false,
9595
configurable: true
9696
});
9797
Object.defineProperty(D, "privateSetter", {
9898
set: function (a) { },
99-
enumerable: true,
99+
enumerable: false,
100100
configurable: true
101101
});
102102
D.protectedMethod = function () { };
103103
Object.defineProperty(D, "protectedGetter", {
104104
get: function () { return 0; },
105-
enumerable: true,
105+
enumerable: false,
106106
configurable: true
107107
});
108108
Object.defineProperty(D, "protectedSetter", {
109109
set: function (a) { },
110-
enumerable: true,
110+
enumerable: false,
111111
configurable: true
112112
});
113113
D.publicMethod = function () { };
114114
Object.defineProperty(D, "publicGetter", {
115115
get: function () { return 0; },
116-
enumerable: true,
116+
enumerable: false,
117117
configurable: true
118118
});
119119
Object.defineProperty(D, "publicSetter", {
120120
set: function (a) { },
121-
enumerable: true,
121+
enumerable: false,
122122
configurable: true
123123
});
124124
return D;
@@ -130,12 +130,12 @@ var E = /** @class */ (function () {
130130
E.prototype.method = function () { };
131131
Object.defineProperty(E.prototype, "getter", {
132132
get: function () { return 0; },
133-
enumerable: true,
133+
enumerable: false,
134134
configurable: true
135135
});
136136
Object.defineProperty(E.prototype, "setter", {
137137
set: function (a) { },
138-
enumerable: true,
138+
enumerable: false,
139139
configurable: true
140140
});
141141
return E;

tests/baselines/reference/accessorParameterAccessibilityModifier.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ var C = /** @class */ (function () {
1010
}
1111
Object.defineProperty(C.prototype, "X", {
1212
set: function (v) { },
13-
enumerable: true,
13+
enumerable: false,
1414
configurable: true
1515
});
1616
Object.defineProperty(C, "X", {
1717
set: function (v2) { },
18-
enumerable: true,
18+
enumerable: false,
1919
configurable: true
2020
});
2121
return C;

tests/baselines/reference/accessorWithES3.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var C = /** @class */ (function () {
2929
get: function () {
3030
return 1;
3131
},
32-
enumerable: true,
32+
enumerable: false,
3333
configurable: true
3434
});
3535
return C;
@@ -40,7 +40,7 @@ var D = /** @class */ (function () {
4040
Object.defineProperty(D.prototype, "x", {
4141
set: function (v) {
4242
},
43-
enumerable: true,
43+
enumerable: false,
4444
configurable: true
4545
});
4646
return D;

tests/baselines/reference/accessorWithES5.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var C = /** @class */ (function () {
2626
get: function () {
2727
return 1;
2828
},
29-
enumerable: true,
29+
enumerable: false,
3030
configurable: true
3131
});
3232
return C;
@@ -37,7 +37,7 @@ var D = /** @class */ (function () {
3737
Object.defineProperty(D.prototype, "x", {
3838
set: function (v) {
3939
},
40-
enumerable: true,
40+
enumerable: false,
4141
configurable: true
4242
});
4343
return D;

tests/baselines/reference/accessorWithInitializer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ var C = /** @class */ (function () {
1212
set: function (v) {
1313
if (v === void 0) { v = 0; }
1414
},
15-
enumerable: true,
15+
enumerable: false,
1616
configurable: true
1717
});
1818
Object.defineProperty(C, "X", {
1919
set: function (v2) {
2020
if (v2 === void 0) { v2 = 0; }
2121
},
22-
enumerable: true,
22+
enumerable: false,
2323
configurable: true
2424
});
2525
return C;

0 commit comments

Comments
 (0)