From 7acc48875780ba4e59f28434db95943adb2875ce Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 6 May 2015 17:23:04 -0700 Subject: [PATCH] Removed Object.defineProperty for function name --- src/compiler/emitter.ts | 11 ++--------- .../reference/decoratedClassFromExternalModule.js | 1 - 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 5a9a654ce60..6d5146a6801 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -3898,6 +3898,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { emitToken(SyntaxKind.CloseBraceToken, node.members.end); scopeEmitEnd(); + // TODO(rbuckton): Need to go back to `let _a = class C {}` approach, removing the defineProperty call for now. + // For a decorated class, we need to assign its name (if it has one). This is because we emit // the class as a class expression to avoid the double-binding of the identifier: // @@ -3907,15 +3909,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { // if (thisNodeIsDecorated) { write(";"); - if (node.name) { - writeLine(); - write("Object.defineProperty("); - emitDeclarationName(node); - write(", \"name\", { value: \""); - emitDeclarationName(node); - write("\", configurable: true });"); - writeLine(); - } } // Emit static property assignment. Because classDeclaration is lexically evaluated, diff --git a/tests/baselines/reference/decoratedClassFromExternalModule.js b/tests/baselines/reference/decoratedClassFromExternalModule.js index 36cffbb6677..163a4a094b4 100644 --- a/tests/baselines/reference/decoratedClassFromExternalModule.js +++ b/tests/baselines/reference/decoratedClassFromExternalModule.js @@ -21,7 +21,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, function decorate() { } let Decorated = class { }; -Object.defineProperty(Decorated, "name", { value: "Decorated", configurable: true }); Decorated = __decorate([ decorate ], Decorated);