From 719705faf66ed4eeee49abda50fbf4ed914c81d4 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 20 Apr 2016 18:36:05 -0700 Subject: [PATCH] Adds source maps for captured this, skips source map for synthetic return token in arrow. --- src/compiler/printer.ts | 4 ++-- src/compiler/transformers/es6.ts | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/compiler/printer.ts b/src/compiler/printer.ts index 89d7ef04140..62b73924da9 100644 --- a/src/compiler/printer.ts +++ b/src/compiler/printer.ts @@ -1546,7 +1546,7 @@ const _super = (function (geti, seti) { const savedTempFlags = tempFlags; tempFlags = 0; emitSignatureHead(node); - emitBlockFunctionBodyAndEndLexicalEnvironment(node, body); + emitBlockFunctionBody(node, body); if (indentedFlag) { decreaseIndent(); } @@ -1610,7 +1610,7 @@ const _super = (function (geti, seti) { return true; } - function emitBlockFunctionBodyAndEndLexicalEnvironment(parentNode: Node, body: Block) { + function emitBlockFunctionBody(parentNode: Node, body: Block) { // TODO(rbuckton): This should be removed once source maps are aligned with the old // emitter and new baselines are taken. This exists solely to // align with the old emitter. diff --git a/src/compiler/transformers/es6.ts b/src/compiler/transformers/es6.ts index fe48fed049a..ceff4d0db50 100644 --- a/src/compiler/transformers/es6.ts +++ b/src/compiler/transformers/es6.ts @@ -1063,7 +1063,8 @@ namespace ts { "_this", createThis() ) - ]) + ]), + /*location*/ node ) ); } @@ -1343,7 +1344,9 @@ namespace ts { const expression = visitNode(body, visitor, isExpression); if (expression) { - statements.push(createReturn(expression, /*location*/ statementsLocation)); + const returnStatement = createReturn(expression, /*location*/ statementsLocation); + setNodeEmitFlags(returnStatement, NodeEmitFlags.NoTokenSourceMaps); + statements.push(returnStatement); } }