diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index f0c58c66bef..676a3afb561 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2174,8 +2174,8 @@ namespace ts { // A GetAccessor or SetAccessor is ES5 syntax. excludeFlags = TransformFlags.MethodOrAccessorExcludes; - // A GetAccessor or SetAccessor is TypeScript syntax if it is either abstract, - // or has a decorator. + // A GetAccessor or SetAccessor is TypeScript syntax if it has async or abstract + // modifiers, or has a decorator. if ((node).body === undefined || hasModifier(node, ModifierFlags.Async | ModifierFlags.Abstract) || subtreeFlags & TransformFlags.ContainsDecorators) { diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index b21888514f1..5523baf54fd 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -1176,9 +1176,6 @@ namespace ts { const right = getMutableClone(node.right, emitOptions && clone(emitOptions)); return createPropertyAccess(left, right, /*location*/ node, emitOptions && clone(emitOptions)); } - else if (isIdentifier(node)) { - return getMutableClone(node, emitOptions && clone(emitOptions)); - } else { return getMutableClone(node, emitOptions && clone(emitOptions)); } diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index abc50d280a6..afc9e5b7570 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -228,9 +228,7 @@ namespace ts { if (hasModifier(node, ModifierFlags.Ambient) && isStatement(node)) { // TypeScript ambient declarations are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. - return isStatement(node) - ? createNotEmittedStatement(node) - : undefined; + return createNotEmittedStatement(node); } switch (node.kind) { @@ -430,16 +428,19 @@ namespace ts { const constructor = getFirstConstructorWithBody(node); if (constructor) { - for (const parameter of constructor.parameters) { - if (parameter.decorators && parameter.decorators.length > 0) { - return true; - } - } + return forEach(constructor.parameters, shouldEmitDecorateCallForParameter); } return false; } + /** + * Tests whether we should emit a __decorate call for a parameter declaration. + */ + function shouldEmitDecorateCallForParameter(parameter: ParameterDeclaration) { + return parameter.decorators !== undefined && parameter.decorators.length > 0; + } + /** * Transforms a class declaration with TypeScript syntax into compatible ES6. *