PR Feedback

This commit is contained in:
Ron Buckton 2016-02-12 15:07:33 -08:00
parent 4577441636
commit 319ff614a0
2 changed files with 22 additions and 15 deletions

View file

@ -1962,16 +1962,20 @@ namespace ts {
transformFlags = TransformFlags.AssertTypeScript;
}
}
break;
case SyntaxKind.ExpressionStatement:
// if (node.flags & NodeFlags.Generated) {
// let expression = (<ExpressionStatement>node).expression;
// if (expression.kind === SyntaxKind.CallExpression
// && (<CallExpression>expression).expression.kind === SyntaxKind.SuperKeyword) {
// transformFlags |= TransformFlags.AssertES6;
// }
// }
if (nodeIsSynthesized(node)) {
const expression = (<ExpressionStatement>node).expression;
if (nodeIsSynthesized(expression)
&& isCallExpression(expression)
&& expression.expression.kind === SyntaxKind.SuperKeyword) {
// A synthesized call to `super` should be transformed to a cleaner emit
// when transpiling to ES5/3.
transformFlags |= TransformFlags.AssertES6;
}
}
break;
@ -2082,17 +2086,16 @@ namespace ts {
case SyntaxKind.VariableDeclarationList:
// If a VariableDeclarationList is `let` or `const`, then it is ES6 syntax.
if (node.flags & NodeFlags.Let
|| node.flags & NodeFlags.Const) {
if (node.flags & NodeFlags.BlockScoped) {
transformFlags |= TransformFlags.AssertES6;
}
break;
case SyntaxKind.VariableStatement:
// If a VariableStatement is exported, then it is ES6 syntax.
// If a VariableStatement is exported, then it is either ES6 or TypeScript syntax.
if (node.flags & NodeFlags.Export) {
transformFlags |= TransformFlags.AssertES6;
transformFlags |= TransformFlags.AssertES6 | TransformFlags.AssertTypeScript;
}
break;
@ -2114,13 +2117,13 @@ namespace ts {
break;
case SyntaxKind.HeritageClause:
// An `extends` HertiageClause is ES6 syntax.
if ((<HeritageClause>node).token === SyntaxKind.ExtendsKeyword) {
// An `extends` HeritageClause is ES6 syntax.
transformFlags |= TransformFlags.AssertES6;
}
// An `implements` HeritageClause is TypeScript syntax.
else if ((<HeritageClause>node).token === SyntaxKind.ImplementsKeyword) {
else {
// An `implements` HeritageClause is TypeScript syntax.
Debug.assert((<HeritageClause>node).token === SyntaxKind.ImplementsKeyword);
transformFlags |= TransformFlags.AssertTypeScript;
}

View file

@ -2640,6 +2640,10 @@ namespace ts {
return node.kind === SyntaxKind.BinaryExpression;
}
export function isCallExpression(node: Node): node is CallExpression {
return node.kind === SyntaxKind.CallExpression;
}
export function isTemplate(node: Node): node is Template {
const kind = node.kind;
return kind === SyntaxKind.TemplateExpression