Skip to content

Commit 82ac83d

Browse files
Enhance __setFunctionName to check for writable name property before defining it
1 parent 9c990ed commit 82ac83d

16 files changed

+32
-0
lines changed

tests/baselines/reference/blockScopedVariablesUseBeforeDef.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
200200
};
201201
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
202202
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
203+
var d = Object.getOwnPropertyDescriptor(f, "name");
204+
if (d && d.writable !== false) return f;
203205
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
204206
};
205207
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }

tests/baselines/reference/capturedParametersInInitializers2.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ function foo2(y = class {[x] = x}, x = 1) {
1919
//// [capturedParametersInInitializers2.js]
2020
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
2121
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
22+
var d = Object.getOwnPropertyDescriptor(f, "name");
23+
if (d && d.writable !== false) return f;
2224
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
2325
};
2426
function foo(y, x, z) {

tests/baselines/reference/classStaticBlock18(target=es2015).js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ function foo () {
1919
//// [classStaticBlock18.js]
2020
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
2121
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
22+
var d = Object.getOwnPropertyDescriptor(f, "name");
23+
if (d && d.writable !== false) return f;
2224
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
2325
};
2426
function foo() {

tests/baselines/reference/classStaticBlock18(target=es5).js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ function foo () {
1919
//// [classStaticBlock18.js]
2020
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
2121
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
22+
var d = Object.getOwnPropertyDescriptor(f, "name");
23+
if (d && d.writable !== false) return f;
2224
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
2325
};
2426
function foo() {

tests/baselines/reference/classWithStaticFieldInParameterInitializer(target=es2015).js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
//// [classWithStaticFieldInParameterInitializer.js]
88
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
99
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
10+
var d = Object.getOwnPropertyDescriptor(f, "name");
11+
if (d && d.writable !== false) return f;
1012
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
1113
};
1214
// https://github.com/microsoft/TypeScript/issues/36295

tests/baselines/reference/classWithStaticFieldInParameterInitializer(target=es5).js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
//// [classWithStaticFieldInParameterInitializer.js]
88
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
99
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
10+
var d = Object.getOwnPropertyDescriptor(f, "name");
11+
if (d && d.writable !== false) return f;
1012
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
1113
};
1214
// https://github.com/microsoft/TypeScript/issues/36295

tests/baselines/reference/decoratorOnClass8.es6.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
1717
};
1818
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
1919
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
20+
var d = Object.getOwnPropertyDescriptor(f, "name");
21+
if (d && d.writable !== false) return f;
2022
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
2123
};
2224
var _a;

tests/baselines/reference/emitClassExpressionInDeclarationFile2.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ var __extends = (this && this.__extends) || (function () {
5050
})();
5151
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
5252
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
53+
var d = Object.getOwnPropertyDescriptor(f, "name");
54+
if (d && d.writable !== false) return f;
5355
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
5456
};
5557
var _a;

tests/baselines/reference/privateFieldsInClassExpressionDeclaration.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export const ClassExpressionStatic = class {
1717
//// [privateFieldsInClassExpressionDeclaration.js]
1818
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
1919
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
20+
var d = Object.getOwnPropertyDescriptor(f, "name");
21+
if (d && d.writable !== false) return f;
2022
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
2123
};
2224
var _instances, _context, _method, _a, _b, _ClassExpressionStatic_staticPrivate, _ClassExpressionStatic_instancePrivate;

tests/baselines/reference/privateNameFieldClassExpression.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class B {
1919
//// [privateNameFieldClassExpression.js]
2020
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
2121
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
22+
var d = Object.getOwnPropertyDescriptor(f, "name");
23+
if (d && d.writable !== false) return f;
2224
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
2325
};
2426
var _B_foo, _B_foo2;

0 commit comments

Comments
 (0)