Skip to content

Commit

Permalink
Fix Get/Set being enumerable (#32264)
Browse files Browse the repository at this point in the history
* Fix Get/Set being enumerable

fixes #3610

* fix tests

Co-authored-by: Nathan Shively-Sanders <[email protected]>
  • Loading branch information
pathurs and sandersn committed Feb 27, 2020
1 parent e7c578a commit 5c85feb
Show file tree
Hide file tree
Showing 296 changed files with 1,541 additions and 1,317 deletions.
2 changes: 1 addition & 1 deletion src/compiler/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ namespace ts {
properties.push(setter);
}

properties.push(createPropertyAssignment("enumerable", createTrue()));
properties.push(createPropertyAssignment("enumerable", getAccessor || setAccessor ? createFalse() : createTrue()));
properties.push(createPropertyAssignment("configurable", createTrue()));

const expression = setTextRange(
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/transformers/es2015.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1675,7 +1675,7 @@ namespace ts {
}

properties.push(
createPropertyAssignment("enumerable", createTrue()),
createPropertyAssignment("enumerable", getAccessor || setAccessor ? createFalse() : createTrue()),
createPropertyAssignment("configurable", createTrue())
);

Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/MemberAccessorDeclaration15.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var C = /** @class */ (function () {
}
Object.defineProperty(C.prototype, "Foo", {
set: function (a) { },
enumerable: true,
enumerable: false,
configurable: true
});
return C;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/abstractProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var C = /** @class */ (function (_super) {
Object.defineProperty(C.prototype, "prop", {
get: function () { return "foo"; },
set: function (v) { },
enumerable: true,
enumerable: false,
configurable: true
});
C.prototype.m = function () { };
Expand Down
8 changes: 4 additions & 4 deletions tests/baselines/reference/abstractPropertyNegative.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var C = /** @class */ (function (_super) {
}
Object.defineProperty(C.prototype, "concreteWithNoBody", {
get: function () { },
enumerable: true,
enumerable: false,
configurable: true
});
return C;
Expand Down Expand Up @@ -104,7 +104,7 @@ var WrongTypeAccessorImpl = /** @class */ (function (_super) {
}
Object.defineProperty(WrongTypeAccessorImpl.prototype, "num", {
get: function () { return "nope, wrong"; },
enumerable: true,
enumerable: false,
configurable: true
});
return WrongTypeAccessorImpl;
Expand All @@ -123,13 +123,13 @@ var AbstractAccessorMismatch = /** @class */ (function () {
}
Object.defineProperty(AbstractAccessorMismatch.prototype, "p1", {
set: function (val) { },
enumerable: true,
enumerable: false,
configurable: true
});
;
Object.defineProperty(AbstractAccessorMismatch.prototype, "p2", {
get: function () { return "should work"; },
enumerable: true,
enumerable: false,
configurable: true
});
return AbstractAccessorMismatch;
Expand Down
28 changes: 14 additions & 14 deletions tests/baselines/reference/accessibilityModifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,34 @@ var C = /** @class */ (function () {
C.privateMethod = function () { };
Object.defineProperty(C, "privateGetter", {
get: function () { return 0; },
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(C, "privateSetter", {
set: function (a) { },
enumerable: true,
enumerable: false,
configurable: true
});
C.protectedMethod = function () { };
Object.defineProperty(C, "protectedGetter", {
get: function () { return 0; },
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(C, "protectedSetter", {
set: function (a) { },
enumerable: true,
enumerable: false,
configurable: true
});
C.publicMethod = function () { };
Object.defineProperty(C, "publicGetter", {
get: function () { return 0; },
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(C, "publicSetter", {
set: function (a) { },
enumerable: true,
enumerable: false,
configurable: true
});
return C;
Expand All @@ -91,34 +91,34 @@ var D = /** @class */ (function () {
D.privateMethod = function () { };
Object.defineProperty(D, "privateGetter", {
get: function () { return 0; },
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(D, "privateSetter", {
set: function (a) { },
enumerable: true,
enumerable: false,
configurable: true
});
D.protectedMethod = function () { };
Object.defineProperty(D, "protectedGetter", {
get: function () { return 0; },
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(D, "protectedSetter", {
set: function (a) { },
enumerable: true,
enumerable: false,
configurable: true
});
D.publicMethod = function () { };
Object.defineProperty(D, "publicGetter", {
get: function () { return 0; },
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(D, "publicSetter", {
set: function (a) { },
enumerable: true,
enumerable: false,
configurable: true
});
return D;
Expand All @@ -130,12 +130,12 @@ var E = /** @class */ (function () {
E.prototype.method = function () { };
Object.defineProperty(E.prototype, "getter", {
get: function () { return 0; },
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(E.prototype, "setter", {
set: function (a) { },
enumerable: true,
enumerable: false,
configurable: true
});
return E;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ var C = /** @class */ (function () {
}
Object.defineProperty(C.prototype, "X", {
set: function (v) { },
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(C, "X", {
set: function (v2) { },
enumerable: true,
enumerable: false,
configurable: true
});
return C;
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/accessorWithES3.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var C = /** @class */ (function () {
get: function () {
return 1;
},
enumerable: true,
enumerable: false,
configurable: true
});
return C;
Expand All @@ -40,7 +40,7 @@ var D = /** @class */ (function () {
Object.defineProperty(D.prototype, "x", {
set: function (v) {
},
enumerable: true,
enumerable: false,
configurable: true
});
return D;
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/accessorWithES5.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var C = /** @class */ (function () {
get: function () {
return 1;
},
enumerable: true,
enumerable: false,
configurable: true
});
return C;
Expand All @@ -37,7 +37,7 @@ var D = /** @class */ (function () {
Object.defineProperty(D.prototype, "x", {
set: function (v) {
},
enumerable: true,
enumerable: false,
configurable: true
});
return D;
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/accessorWithInitializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ var C = /** @class */ (function () {
set: function (v) {
if (v === void 0) { v = 0; }
},
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(C, "X", {
set: function (v2) {
if (v2 === void 0) { v2 = 0; }
},
enumerable: true,
enumerable: false,
configurable: true
});
return C;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/accessorWithLineTerminator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var C = /** @class */ (function () {
Object.defineProperty(C.prototype, "x", {
get: function () { return 1; },
set: function (v) { },
enumerable: true,
enumerable: false,
configurable: true
});
return C;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var C = /** @class */ (function () {
},
set: function (v) {
},
enumerable: true,
enumerable: false,
configurable: true
});
return C;
Expand All @@ -55,7 +55,7 @@ var D = /** @class */ (function () {
},
set: function (v) {
},
enumerable: true,
enumerable: false,
configurable: true
});
return D;
Expand All @@ -69,7 +69,7 @@ var E = /** @class */ (function () {
},
set: function (v) {
},
enumerable: true,
enumerable: false,
configurable: true
});
return E;
Expand All @@ -83,7 +83,7 @@ var F = /** @class */ (function () {
},
set: function (v) {
},
enumerable: true,
enumerable: false,
configurable: true
});
return F;
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/accessorWithRestParam.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var C = /** @class */ (function () {
v[_i] = arguments[_i];
}
},
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(C, "X", {
Expand All @@ -25,7 +25,7 @@ var C = /** @class */ (function () {
v2[_i] = arguments[_i];
}
},
enumerable: true,
enumerable: false,
configurable: true
});
return C;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var C = /** @class */ (function () {
},
set: function (v) {
},
enumerable: true,
enumerable: false,
configurable: true
});
return C;
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/accessorsEmit.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var Test = /** @class */ (function () {
var x = 1;
return null;
},
enumerable: true,
enumerable: false,
configurable: true
});
return Test;
Expand All @@ -42,7 +42,7 @@ var Test2 = /** @class */ (function () {
var x = 1;
return null;
},
enumerable: true,
enumerable: false,
configurable: true
});
return Test2;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/accessorsNotAllowedInES3.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var C = /** @class */ (function () {
}
Object.defineProperty(C.prototype, "x", {
get: function () { return 1; },
enumerable: true,
enumerable: false,
configurable: true
});
return C;
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/accessorsOverrideProperty7.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var B = /** @class */ (function (_super) {
Object.defineProperty(B.prototype, "p", {
get: function () { return 'oh no'; } // error
,
enumerable: true,
enumerable: false,
configurable: true
});
return B;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@ var LanguageSpec_section_4_5_error_cases = /** @class */ (function () {
Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedSetter_SetterFirst", {
get: function () { return ""; },
set: function (a) { },
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedSetter_SetterLast", {
get: function () { return ""; },
set: function (a) { },
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedGetter_GetterFirst", {
get: function () { return ""; },
set: function (aStr) { aStr = 0; },
enumerable: true,
enumerable: false,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedGetter_GetterLast", {
get: function () { return ""; },
set: function (aStr) { aStr = 0; },
enumerable: true,
enumerable: false,
configurable: true
});
return LanguageSpec_section_4_5_error_cases;
Expand Down
Loading

0 comments on commit 5c85feb

Please sign in to comment.