From 3c3e081f31578e0c8bb16b29c38ce331734bcc25 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 18 Apr 2016 13:23:53 -0700 Subject: [PATCH 1/5] Fix source maps for rest params, class properties, parameter properties, and accessors. --- src/compiler/factory.ts | 104 +++++++++++------- src/compiler/printer.ts | 16 ++- src/compiler/sourcemap.ts | 7 +- src/compiler/transformers/es6.ts | 37 ++++--- src/compiler/transformers/ts.ts | 16 ++- src/compiler/types.ts | 9 +- .../reference/sourceMapValidationClass.js.map | 2 +- .../sourceMapValidationClass.sourcemap.txt | 16 +-- 8 files changed, 130 insertions(+), 77 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 8721a03ad71..7935801ec2b 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -106,7 +106,7 @@ namespace ts { * Gets a clone of a node with a unique node ID. */ export function getUniqueClone(node: T): T { - const clone = getSynthesizedClone(node); + const clone = getMutableClone(node); clone.id = undefined; getNodeId(clone); return clone; @@ -926,34 +926,8 @@ namespace ts { ); } - function createPropertyDescriptor({ get, set, value, enumerable, configurable, writable }: PropertyDescriptorOptions, preferNewLine?: boolean, location?: TextRange, descriptorLocations?: PropertyDescriptorLocations) { - const properties: ObjectLiteralElement[] = []; - addPropertyAssignment(properties, "get", get, preferNewLine, descriptorLocations); - addPropertyAssignment(properties, "set", set, preferNewLine, descriptorLocations); - addPropertyAssignment(properties, "value", value, preferNewLine, descriptorLocations); - addPropertyAssignment(properties, "enumerable", enumerable, preferNewLine, descriptorLocations); - addPropertyAssignment(properties, "configurable", configurable, preferNewLine, descriptorLocations); - addPropertyAssignment(properties, "writable", writable, preferNewLine, descriptorLocations); - return createObjectLiteral(properties, location, preferNewLine); - } - - function addPropertyAssignment(properties: ObjectLiteralElement[], name: string, value: boolean | Expression, preferNewLine: boolean, descriptorLocations?: PropertyDescriptorLocations) { - if (value !== undefined) { - const property = createPropertyAssignment( - name, - typeof value === "boolean" ? createLiteral(value) : value, - descriptorLocations ? descriptorLocations[name] : undefined - ); - - if (preferNewLine) { - startOnNewLine(property); - } - - properties.push(property); - } - } - export interface PropertyDescriptorOptions { + [key: string]: boolean | Expression; get?: Expression; set?: Expression; value?: Expression; @@ -962,17 +936,23 @@ namespace ts { writable?: boolean | Expression; } - export interface PropertyDescriptorLocations { - [key: string]: TextRange; - get?: TextRange; - set?: TextRange; - value?: TextRange; - enumerable?: TextRange; - configurable?: TextRange; - writable?: TextRange; + export interface PropertyDescriptorExtendedOptions { + [key: string]: PropertyDescriptorExtendedOption; + get?: PropertyDescriptorExtendedOption; + set?: PropertyDescriptorExtendedOption; + value?: PropertyDescriptorExtendedOption; + enumerable?: PropertyDescriptorExtendedOption; + configurable?: PropertyDescriptorExtendedOption; + writable?: PropertyDescriptorExtendedOption; } - export function createObjectDefineProperty(target: Expression, memberName: Expression, descriptor: PropertyDescriptorOptions, preferNewLine?: boolean, location?: TextRange, descriptorLocations?: PropertyDescriptorLocations) { + export interface PropertyDescriptorExtendedOption { + location?: TextRange; + emitFlags?: NodeEmitFlags; + newLine?: boolean; + } + + export function createObjectDefineProperty(target: Expression, memberName: Expression, descriptor: PropertyDescriptorOptions, preferNewLine?: boolean, location?: TextRange, descriptorOptions?: PropertyDescriptorExtendedOptions, context?: TransformationContext) { return createCall( createPropertyAccess( createIdentifier("Object"), @@ -981,12 +961,60 @@ namespace ts { [ target, memberName, - createPropertyDescriptor(descriptor, preferNewLine, /*location*/ undefined, descriptorLocations) + createObjectLiteral( + createPropertyDescriptorProperties(descriptor, descriptorOptions, preferNewLine, context), + /*location*/ undefined, + /*multiLine*/ preferNewLine + ) ], location ); } + function createPropertyDescriptorProperties(descriptor: PropertyDescriptorOptions, descriptorExtendedOptions: PropertyDescriptorExtendedOptions, preferNewLine: boolean, context: TransformationContext) { + const properties: ObjectLiteralElement[] = []; + addPropertyDescriptorPropertyAssignmentIfNeeded(properties, "get", descriptor, descriptorExtendedOptions, preferNewLine, context); + addPropertyDescriptorPropertyAssignmentIfNeeded(properties, "set", descriptor, descriptorExtendedOptions, preferNewLine, context); + addPropertyDescriptorPropertyAssignmentIfNeeded(properties, "value", descriptor, descriptorExtendedOptions, preferNewLine, context); + addPropertyDescriptorPropertyAssignmentIfNeeded(properties, "enumerable", descriptor, descriptorExtendedOptions, preferNewLine, context); + addPropertyDescriptorPropertyAssignmentIfNeeded(properties, "configurable", descriptor, descriptorExtendedOptions, preferNewLine, context); + addPropertyDescriptorPropertyAssignmentIfNeeded(properties, "writable", descriptor, descriptorExtendedOptions, preferNewLine, context); + return properties; + } + + function addPropertyDescriptorPropertyAssignmentIfNeeded(properties: ObjectLiteralElement[], name: string, descriptor: PropertyDescriptorOptions, descriptorExtendedOptions: PropertyDescriptorExtendedOptions, preferNewLine: boolean, context: TransformationContext) { + const value = getProperty(descriptor, name); + if (value !== undefined) { + const options = getProperty(descriptorExtendedOptions, name); + let location: TextRange; + let emitFlags: NodeEmitFlags; + if (isDefined(options)) { + location = options.location; + emitFlags = options.emitFlags; + if (isDefined(options.newLine)) { + preferNewLine = options.newLine; + } + } + + const property = createPropertyAssignment( + name, + typeof value === "boolean" ? createLiteral(value) : value, + location + ); + + if (isDefined(emitFlags)) { + Debug.assert(isDefined(context), "TransformationContext must be supplied when emitFlags are provided."); + context.setNodeEmitFlags(property, emitFlags); + } + + if (preferNewLine) { + startOnNewLine(property); + } + + properties.push(property); + } + } + function createObjectCreate(prototype: Expression) { return createCall( createPropertyAccess(createIdentifier("Object"), "create"), diff --git a/src/compiler/printer.ts b/src/compiler/printer.ts index b5cc8206688..de8ee5a5d1c 100644 --- a/src/compiler/printer.ts +++ b/src/compiler/printer.ts @@ -1154,7 +1154,7 @@ const _super = (function (geti, seti) { emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator ? " " : undefined); - writeTokenNode(node.operatorToken); + writeTokenText(node.operatorToken.kind); increaseIndentIf(indentAfterOperator, " "); emitExpression(node.right); decreaseIndentIf(indentBeforeOperator, indentAfterOperator); @@ -1353,7 +1353,7 @@ const _super = (function (geti, seti) { } function emitReturnStatement(node: ReturnStatement) { - write("return"); + writeToken(SyntaxKind.ReturnKeyword, node.pos, node, shouldSkipSourceMapForToken); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -2301,14 +2301,20 @@ const _super = (function (geti, seti) { } } - function writeToken(token: SyntaxKind, tokenStartPos: number) { + function writeToken(token: SyntaxKind, tokenStartPos: number): number; + function writeToken(token: SyntaxKind, tokenStartPos: number, contextNode: Node, shouldIgnoreSourceMapForTokenCallback: (contextNode: Node) => boolean): number; + function writeToken(token: SyntaxKind, tokenStartPos: number, contextNode?: Node, shouldIgnoreSourceMapForTokenCallback?: (contextNode: Node) => boolean) { tokenStartPos = skipTrivia(currentText, tokenStartPos); - emitPos(tokenStartPos); + emitPos(tokenStartPos, contextNode, shouldIgnoreSourceMapForTokenCallback); const tokenEndPos = writeTokenText(token, tokenStartPos); - emitPos(tokenEndPos); + emitPos(tokenEndPos, contextNode, shouldIgnoreSourceMapForTokenCallback); return tokenEndPos; } + function shouldSkipSourceMapForToken(contextNode: Node) { + return (getNodeEmitFlags(contextNode) & NodeEmitFlags.NoTokenSourceMaps) !== 0; + } + function writeTokenText(token: SyntaxKind, pos?: number) { const tokenString = tokenToString(token); write(tokenString); diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index d292e7a7060..832a89a4c56 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -5,6 +5,7 @@ namespace ts { export interface SourceMapWriter { getSourceMapData(): SourceMapData; setSourceFile(sourceFile: SourceFile): void; + emitPos(pos: number, contextNode: Node, shouldIgnorePosCallback: (node: Node) => boolean): void; emitPos(pos: number): void; emitStart(node: Node, shouldIgnoreNodeCallback?: (node: Node) => boolean, shouldIgnoreChildrenCallback?: (node: Node) => boolean): void; emitStart(range: TextRange): void; @@ -271,11 +272,15 @@ namespace ts { sourceMapData.sourceMapDecodedMappings.push(lastEncodedSourceMapSpan); } - function emitPos(pos: number) { + function emitPos(pos: number, contextNode?: Node, shouldIgnorePosCallback?: (node: Node) => boolean) { if (positionIsSynthesized(pos) || disableDepth > 0) { return; } + if (shouldIgnorePosCallback && shouldIgnorePosCallback(contextNode)) { + return; + } + const sourceLinePos = getLineAndCharacterOfPosition(currentSourceFile, pos); // Convert the location to be one-based. diff --git a/src/compiler/transformers/es6.ts b/src/compiler/transformers/es6.ts index 8a001450c69..160e577b03e 100644 --- a/src/compiler/transformers/es6.ts +++ b/src/compiler/transformers/es6.ts @@ -674,7 +674,7 @@ namespace ts { const statement = createReturn(outer); statement.pos = closingBraceLocation.pos; statements.push(statement); - setNodeEmitFlags(statement, NodeEmitFlags.NoComments); + setNodeEmitFlags(statement, NodeEmitFlags.NoComments | NodeEmitFlags.NoTokenSourceMaps); addRange(statements, endLexicalEnvironment()); const block = createBlock(createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); @@ -1001,7 +1001,8 @@ namespace ts { name, createArrayLiteral([]) ) - ]) + ]), + /*location*/ parameter ) ); @@ -1012,12 +1013,13 @@ namespace ts { createFor( createVariableDeclarationList([ createVariableDeclaration(temp, createLiteral(restIndex)) - ]), + ], /*location*/ parameter), createLessThan( temp, - createPropertyAccess(createIdentifier("arguments"), "length") + createPropertyAccess(createIdentifier("arguments"), "length"), + /*location*/ parameter ), - createPostfixIncrement(temp), + createPostfixIncrement(temp, /*location*/ parameter), createBlock([ startOnNewLine( createStatement( @@ -1027,7 +1029,8 @@ namespace ts { createSubtract(temp, createLiteral(restIndex)) ), createElementAccess(createIdentifier("arguments"), temp) - ) + ), + /*location*/ parameter ) ) ]) @@ -1158,13 +1161,18 @@ namespace ts { * @param receiver The receiver for the member. */ function transformAccessorsToExpression(receiver: LeftHandSideExpression, { firstAccessor, getAccessor, setAccessor }: AllAccessorDeclarations): Expression { + // To align with source maps in the old emitter, the receiver and property name + // arguments are both mapped contiguously to the accessor name. + const target = getSynthesizedClone(receiver); + target.pos = firstAccessor.name.pos; + + const propertyName = createExpressionForPropertyName(visitNode(firstAccessor.name, visitor, isPropertyName)); + propertyName.end = firstAccessor.name.end; + return setNodeEmitFlags( createObjectDefineProperty( - receiver, - createExpressionForPropertyName( - visitNode(firstAccessor.name, visitor, isPropertyName), - /*location*/ firstAccessor.name - ), + target, + propertyName, /*descriptor*/ { get: getAccessor && transformFunctionLikeToExpression(getAccessor, /*location*/ getAccessor, /*name*/ undefined), set: setAccessor && transformFunctionLikeToExpression(setAccessor, /*location*/ setAccessor, /*name*/ undefined), @@ -1174,9 +1182,10 @@ namespace ts { /*preferNewLine*/ true, /*location*/ undefined, /*descriptorLocations*/ { - get: getAccessor, - set: setAccessor - } + get: { location: getAccessor, emitFlags: NodeEmitFlags.NoSourceMap }, + set: { location: setAccessor, emitFlags: NodeEmitFlags.NoSourceMap } + }, + context ), NodeEmitFlags.NoComments ); diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index c63c8fc8a76..288f5c85092 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -898,13 +898,17 @@ namespace ts { function transformParameterWithPropertyAssignment(node: ParameterDeclaration) { Debug.assert(isIdentifier(node.name)); - const name = getSynthesizedClone(node.name); return startOnNewLine( createStatement( createAssignment( - createPropertyAccess(createThis(), name), - name - ) + createPropertyAccess( + createThis(), + getSynthesizedClone(node.name), + /*location*/ node.name + ), + getUniqueClone(node.name) + ), + /*location*/ node ) ); } @@ -994,7 +998,7 @@ namespace ts { const propertyName = visitPropertyNameOfClassElement(property); const initializer = visitNode(property.initializer, visitor, isExpression); return createAssignment( - createMemberAccessForPropertyName(receiver, propertyName), + createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName), initializer, location ); @@ -1754,7 +1758,7 @@ namespace ts { function getExpressionForPropertyName(member: ClassElement | EnumMember, generateNameForComputedPropertyName: boolean): Expression { const name = member.name; if (isComputedPropertyName(name)) { - return generateNameForComputedPropertyName + return generateNameForComputedPropertyName ? getGeneratedNameForNode(name) : (name).expression; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 4c99417950d..0c13b134d1e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2875,10 +2875,11 @@ namespace ts { CapturesThis = 1 << 9, // The function captures a lexical `this` NoSourceMap = 1 << 10, // Do not emit a source map location for this node. NoNestedSourceMaps = 1 << 11, // Do not emit source map locations for children of this node. - NoComments = 1 << 12, // Do not emit comments for this node. - ExportName = 1 << 13, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal). - LocalName = 1 << 14, // Ensure an export prefix is not added for an identifier that points to an exported declaration. - Indented = 1 << 15, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter). + NoTokenSourceMaps = 1 << 12, // Do not emit source map locations for tokens of this node. + NoComments = 1 << 13, // Do not emit comments for this node. + ExportName = 1 << 14, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal). + LocalName = 1 << 15, // Ensure an export prefix is not added for an identifier that points to an exported declaration. + Indented = 1 << 16, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter). } /** Additional context provided to `visitEachChild` */ diff --git a/tests/baselines/reference/sourceMapValidationClass.js.map b/tests/baselines/reference/sourceMapValidationClass.js.map index 6176f13bc51..8baf4772a27 100644 --- a/tests/baselines/reference/sourceMapValidationClass.js.map +++ b/tests/baselines/reference/sourceMapValidationClass.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationClass.js.map] -{"version":3,"file":"sourceMapValidationClass.js","sourceRoot":"","sources":["sourceMapValidationClass.ts"],"names":[],"mappings":"AAAA;IACI,iBAAmB,QAAgB;QAAE,WAAc;aAAd,WAAc,CAAd,sBAAc,CAAd,IAAc;YAAd,0BAAc;;QAAhC,aAAQ,GAAR,QAAQ,CAAQ;QAM3B,OAAE,GAAW,EAAE,CAAC;IALxB,CAAC;IACD,uBAAK,GAAL;QACI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5C,CAAC;IAGO,oBAAE,GAAV;QACI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IACD,sBAAI,8BAAS;aAAb;YACI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;aACD,UAAc,SAAiB;YAC3B,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC9B,CAAC;;;OAHA;IAIL,cAAC;AAAD,CAAC,AAjBD,IAiBC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationClass.js","sourceRoot":"","sources":["sourceMapValidationClass.ts"],"names":[],"mappings":"AAAA;IACI,iBAAmB,QAAgB;QAAE,WAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,0BAAc;;QAAhC,aAAQ,GAAR,QAAQ,CAAQ;QAM3B,OAAE,GAAW,EAAE,CAAC;IALxB,CAAC;IACD,uBAAK,GAAL;QACI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5C,CAAC;IAGO,oBAAE,GAAV;QACI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IACD,sBAAI,8BAAS;aAAb;YACI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;aACD,UAAc,SAAiB;YAC3B,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC9B,CAAC;;;OAHA;IAIL,cAAC;AAAD,CAAC,AAjBD,IAiBC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationClass.sourcemap.txt b/tests/baselines/reference/sourceMapValidationClass.sourcemap.txt index 4173ae0ff0d..08fdfe2bfc6 100644 --- a/tests/baselines/reference/sourceMapValidationClass.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationClass.sourcemap.txt @@ -37,21 +37,21 @@ sourceFile:sourceMapValidationClass.ts --- >>> for (var _i = 1; _i < arguments.length; _i++) { 1->^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^^^ -5 > ^ +2 > ^^^^^^^^^^ +3 > ^^ +4 > ^^^^^^^^^^^^^^^^^^^^^ +5 > ^^ 6 > ^^^^ 1-> 2 > ...b: string[] -3 > +3 > 4 > ...b: string[] -5 > +5 > 6 > ...b: string[] 1->Emitted(4, 14) Source(2, 42) + SourceIndex(0) -2 >Emitted(4, 25) Source(2, 56) + SourceIndex(0) +2 >Emitted(4, 24) Source(2, 56) + SourceIndex(0) 3 >Emitted(4, 26) Source(2, 42) + SourceIndex(0) -4 >Emitted(4, 48) Source(2, 56) + SourceIndex(0) +4 >Emitted(4, 47) Source(2, 56) + SourceIndex(0) 5 >Emitted(4, 49) Source(2, 42) + SourceIndex(0) 6 >Emitted(4, 53) Source(2, 56) + SourceIndex(0) --- From feeaa7a9edc1e424ef939ec5aca6b83668861241 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 18 Apr 2016 15:46:18 -0700 Subject: [PATCH 2/5] Fixes source map emit for namespaces --- src/compiler/factory.ts | 25 +- src/compiler/printer.ts | 41 +++- src/compiler/transformers/es6.ts | 13 +- src/compiler/transformers/ts.ts | 222 ++++++++++++++---- src/compiler/types.ts | 10 +- .../reference/sourceMapValidationClasses.js | 2 +- .../sourceMapValidationClasses.js.map | 2 +- .../sourceMapValidationClasses.sourcemap.txt | 87 ++++--- 8 files changed, 277 insertions(+), 125 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 7935801ec2b..347db745266 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -3,6 +3,8 @@ /* @internal */ namespace ts { + const synthesizedLocation: TextRange = { pos: -1, end: -1 }; + let NodeConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node; let SourceFileConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node; @@ -985,14 +987,17 @@ namespace ts { function addPropertyDescriptorPropertyAssignmentIfNeeded(properties: ObjectLiteralElement[], name: string, descriptor: PropertyDescriptorOptions, descriptorExtendedOptions: PropertyDescriptorExtendedOptions, preferNewLine: boolean, context: TransformationContext) { const value = getProperty(descriptor, name); if (value !== undefined) { - const options = getProperty(descriptorExtendedOptions, name); + let options: PropertyDescriptorExtendedOption; let location: TextRange; let emitFlags: NodeEmitFlags; - if (isDefined(options)) { - location = options.location; - emitFlags = options.emitFlags; - if (isDefined(options.newLine)) { - preferNewLine = options.newLine; + if (descriptorExtendedOptions !== undefined) { + options = getProperty(descriptorExtendedOptions, name); + if (options !== undefined) { + location = options.location; + emitFlags = options.emitFlags; + if (options.newLine !== undefined) { + preferNewLine = options.newLine; + } } } @@ -1002,8 +1007,8 @@ namespace ts { location ); - if (isDefined(emitFlags)) { - Debug.assert(isDefined(context), "TransformationContext must be supplied when emitFlags are provided."); + if (emitFlags !== undefined) { + Debug.assert(context !== undefined, "TransformationContext must be supplied when emitFlags are provided."); context.setNodeEmitFlags(property, emitFlags); } @@ -1271,8 +1276,8 @@ namespace ts { export function createExpressionForPropertyName(memberName: PropertyName, location?: TextRange): Expression { return isIdentifier(memberName) ? createLiteral(memberName.text, location) - : isComputedPropertyName(memberName) ? getRelocatedClone(memberName.expression, location) - : getRelocatedClone(memberName, location); + : isComputedPropertyName(memberName) ? getRelocatedClone(memberName.expression, location || synthesizedLocation) + : getRelocatedClone(memberName, location || synthesizedLocation); } // Utilities diff --git a/src/compiler/printer.ts b/src/compiler/printer.ts index de8ee5a5d1c..0bb3388bfe1 100644 --- a/src/compiler/printer.ts +++ b/src/compiler/printer.ts @@ -296,8 +296,8 @@ const _super = (function (geti, seti) { function emitNodeWithWorker(node: Node, emitWorker: (node: Node) => void) { if (node) { - const leadingComments = getLeadingComments(node, shouldSkipCommentsForNode); - const trailingComments = getTrailingComments(node, shouldSkipCommentsForNode); + const leadingComments = getLeadingComments(node, shouldSkipLeadingCommentsForNode); + const trailingComments = getTrailingComments(node, shouldSkipTrailingCommentsForNode); emitLeadingComments(node, leadingComments); emitStart(node, shouldSkipSourceMapForNode, shouldSkipSourceMapForChildren); emitWorker(node); @@ -307,16 +307,29 @@ const _super = (function (geti, seti) { } /** - * Determines whether to skip comment emit for a node. + * Determines whether to skip leading comment emit for a node. * * We do not emit comments for NotEmittedStatement nodes or any node that has - * NodeEmitFlags.NoComments. + * NodeEmitFlags.NoLeadingComments. * * @param node A Node. */ - function shouldSkipCommentsForNode(node: Node) { + function shouldSkipLeadingCommentsForNode(node: Node) { return isNotEmittedStatement(node) - || (getNodeEmitFlags(node) & NodeEmitFlags.NoComments) !== 0; + || (getNodeEmitFlags(node) & NodeEmitFlags.NoLeadingComments) !== 0; + } + + /** + * Determines whether to skip trailing comment emit for a node. + * + * We do not emit comments for NotEmittedStatement nodes or any node that has + * NodeEmitFlags.NoTrailingComments. + * + * @param node A Node. + */ + function shouldSkipTrailingCommentsForNode(node: Node) { + return isNotEmittedStatement(node) + || (getNodeEmitFlags(node) & NodeEmitFlags.NoTrailingComments) !== 0; } /** @@ -1227,12 +1240,14 @@ const _super = (function (geti, seti) { function emitBlock(node: Block, format?: ListFormat) { if (isSingleLineEmptyBlock(node)) { - write("{ }"); + writeToken(SyntaxKind.OpenBraceToken, node.pos); + write(" "); + writeToken(SyntaxKind.CloseBraceToken, node.statements.end); } else { - write("{"); + writeToken(SyntaxKind.OpenBraceToken, node.pos); emitBlockStatements(node); - write("}"); + writeToken(SyntaxKind.CloseBraceToken, node.statements.end); } } @@ -1301,7 +1316,9 @@ const _super = (function (geti, seti) { } function emitForStatement(node: ForStatement) { - write("for ("); + const openParenPos = writeToken(SyntaxKind.ForKeyword, node.pos); + write(" "); + writeToken(SyntaxKind.OpenParenToken, openParenPos); emitForBinding(node.initializer); write(";"); emitExpressionWithPrefix(" ", node.condition); @@ -1508,7 +1525,7 @@ const _super = (function (geti, seti) { const startingLine = writer.getLine(); increaseIndent(); - emitLeadingDetachedComments(body.statements, body, shouldSkipCommentsForNode); + emitLeadingDetachedComments(body.statements, body, shouldSkipLeadingCommentsForNode); // Emit all the prologue directives (like "use strict"). const statementOffset = emitPrologueDirectives(body.statements, /*startWithNewLine*/ true); @@ -1525,7 +1542,7 @@ const _super = (function (geti, seti) { const endingLine = writer.getLine(); emitLexicalEnvironment(endLexicalEnvironment(), /*newLine*/ startingLine !== endingLine); - emitTrailingDetachedComments(body.statements, body, shouldSkipCommentsForNode); + emitTrailingDetachedComments(body.statements, body, shouldSkipTrailingCommentsForNode); decreaseIndent(); writeToken(SyntaxKind.CloseBraceToken, body.statements.end); } diff --git a/src/compiler/transformers/es6.ts b/src/compiler/transformers/es6.ts index 160e577b03e..d7e38611b93 100644 --- a/src/compiler/transformers/es6.ts +++ b/src/compiler/transformers/es6.ts @@ -635,7 +635,7 @@ namespace ts { setNodeEmitFlags(inner, NodeEmitFlags.NoComments); const outer = createPartiallyEmittedExpression(inner); - outer.end = node.pos; + outer.end = skipTrivia(currentText, node.pos); setNodeEmitFlags(outer, NodeEmitFlags.NoComments); return createParen( @@ -988,7 +988,12 @@ namespace ts { return; } - const name = getSynthesizedClone(parameter.name); + // `declarationName` is the name of the local declaration for the parameter. + const declarationName = getUniqueClone(parameter.name); + setNodeEmitFlags(declarationName, NodeEmitFlags.NoSourceMap); + + // `expressionName` is the name of the parameter used in expressions. + const expressionName = getSynthesizedClone(parameter.name); const restIndex = node.parameters.length - 1; const temp = createLoopVariable(); @@ -998,7 +1003,7 @@ namespace ts { /*modifiers*/ undefined, createVariableDeclarationList([ createVariableDeclaration( - name, + declarationName, createArrayLiteral([]) ) ]), @@ -1025,7 +1030,7 @@ namespace ts { createStatement( createAssignment( createElementAccess( - name, + expressionName, createSubtract(temp, createLiteral(restIndex)) ), createElementAccess(createIdentifier("arguments"), temp) diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 288f5c85092..c34ead8dd63 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -47,7 +47,7 @@ namespace ts { // These variables contain state that changes as we descend into the tree. let currentSourceFile: SourceFile; let currentNamespace: ModuleDeclaration; - let currentNamespaceLocalName: Identifier; + let currentNamespaceContainerName: Identifier; let currentScope: SourceFile | Block | ModuleBlock | CaseBlock; /** @@ -2237,7 +2237,7 @@ namespace ts { /*modifiers*/ undefined, [createVariableDeclaration( getDeclarationName(node), - getDeclarationNameExpression(node) + getExportName(node) )], /*location*/ node ) @@ -2308,15 +2308,15 @@ namespace ts { * @param node The enum declaration node. */ function transformEnumBody(node: EnumDeclaration, localName: Identifier): Block { - const savedCurrentNamespaceLocalName = currentNamespaceLocalName; - currentNamespaceLocalName = localName; + const savedCurrentNamespaceLocalName = currentNamespaceContainerName; + currentNamespaceContainerName = localName; const statements: Statement[] = []; startLexicalEnvironment(); addNodes(statements, map(node.members, transformEnumMember)); addNodes(statements, endLexicalEnvironment()); - currentNamespaceLocalName = savedCurrentNamespaceLocalName; + currentNamespaceContainerName = savedCurrentNamespaceLocalName; return createBlock(statements, /*location*/ undefined, /*multiLine*/ true); } @@ -2333,10 +2333,10 @@ namespace ts { return createStatement( createAssignment( createElementAccess( - currentNamespaceLocalName, + currentNamespaceContainerName, createAssignment( createElementAccess( - currentNamespaceLocalName, + currentNamespaceContainerName, name ), transformEnumMemberDeclarationValue(member) @@ -2399,34 +2399,38 @@ namespace ts { */ function addVarForEnumOrModuleDeclaration(statements: Statement[], node: ModuleDeclaration | EnumDeclaration) { // Emit a variable statement for the module. - statements.push( - setOriginalNode( - createVariableStatement( - isES6ExportedDeclaration(node) - ? visitNodes(node.modifiers, visitor, isModifier) - : undefined, - [createVariableDeclaration( - getDeclarationName(node) - )], - // Trailing comments for module declaration should be emitted with function closure instead of variable statement - // So do not set the end position for the variable statement node - // /** Module comment*/ - // module m1 { - // function foo4Export() { - // } - // } // trailing comment module - // Should emit - // /** Module comment*/ - // var m1; - // (function (m1) { - // function foo4Export() { - // } - // })(m1 || (m1 = {})); // trailing comment module - /*location*/ { pos: node.pos, end: -1 } - ), - node - ) + const statement = createVariableStatement( + isES6ExportedDeclaration(node) + ? visitNodes(node.modifiers, visitor, isModifier) + : undefined, + [createVariableDeclaration( + getDeclarationName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) + )], + /*location*/ node ); + + // Trailing comments for module declaration should be emitted after the function closure + // instead of the variable statement: + // + // /** Module comment*/ + // module m1 { + // function foo4Export() { + // } + // } // trailing comment module + // + // Should emit: + // + // /** Module comment*/ + // var m1; + // (function (m1) { + // function foo4Export() { + // } + // })(m1 || (m1 = {})); // trailing comment module + // + setNodeEmitFlags(statement, NodeEmitFlags.NoTrailingComments); + + setOriginalNode(statement, /*original*/ node); + statements.push(statement); } /** @@ -2450,20 +2454,32 @@ namespace ts { addVarForEnumOrModuleDeclaration(statements, node); } - const localName = getGeneratedNameForNode(node); - const name = getDeclarationNameExpression(node); + // `parameterName` is the declaration name used inside of the namespace. + const parameterName = getNamespaceParameterName(node); + // `containerName` is the expression used inside of the namespace for exports. + const containerName = getNamespaceContainerName(node); + + // `exportName` is the expression used within this node's container for any exported references. + const exportName = getExportName(node); + + // x || (x = {}) + // exports.x || (exports.x = {}) let moduleArg = createLogicalOr( - name, + exportName, createAssignment( - name, + exportName, createObjectLiteral() ) ); if (hasModifier(node, ModifierFlags.Export) && !isES6ExportedDeclaration(node)) { - moduleArg = createAssignment(getDeclarationName(node), moduleArg); + // `localName` is the expression used within this node's containing scope for any local references. + const localName = getLocalName(node); + + // x = (exports.x || (exports.x = {})) + moduleArg = createAssignment(localName, moduleArg); } // (function (x_1) { @@ -2477,8 +2493,8 @@ namespace ts { createFunctionExpression( /*asteriskToken*/ undefined, /*name*/ undefined, - [createParameter(localName)], - transformModuleBody(node, localName) + [createParameter(parameterName)], + transformModuleBody(node, containerName) ), [moduleArg] ), @@ -2499,26 +2515,47 @@ namespace ts { * @param node The module declaration node. */ function transformModuleBody(node: ModuleDeclaration, namespaceLocalName: Identifier): Block { - const savedCurrentNamespaceLocalName = currentNamespaceLocalName; + const savedCurrentNamespaceContainerName = currentNamespaceContainerName; const savedCurrentNamespace = currentNamespace; - currentNamespaceLocalName = namespaceLocalName; + currentNamespaceContainerName = namespaceLocalName; currentNamespace = node; const statements: Statement[] = []; startLexicalEnvironment(); + + let statementsLocation: TextRange; + let blockLocation: TextRange; const body = node.body; if (body.kind === SyntaxKind.ModuleBlock) { addNodes(statements, visitNodes((body).statements, namespaceElementVisitor, isStatement)); + statementsLocation = (body).statements; + blockLocation = body; } else { addNode(statements, visitModuleDeclaration(body)); + const moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; + statementsLocation = moveRangePos(moduleBlock.statements, -1); } addNodes(statements, endLexicalEnvironment()); - currentNamespaceLocalName = savedCurrentNamespaceLocalName; + currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; - return createBlock(statements, /*location*/ undefined, /*multiLine*/ true); + return createBlock( + createNodeArray( + statements, + /*location*/ statementsLocation + ), + /*location*/ blockLocation, + /*multiLine*/ true + ); + } + + function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration: ModuleDeclaration): ModuleDeclaration { + if (moduleDeclaration.body.kind === SyntaxKind.ModuleDeclaration) { + const recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); + return recursiveInnerModule || moduleDeclaration.body; + } } /** @@ -2644,12 +2681,99 @@ namespace ts { ); } - function getNamespaceMemberName(name: Identifier): Expression { - return createPropertyAccess(currentNamespaceLocalName, getSynthesizedClone(name)); + function getNamespaceMemberName(name: Identifier, allowComments?: boolean, allowSourceMaps?: boolean): Expression { + const qualifiedName = createPropertyAccess(currentNamespaceContainerName, getSynthesizedClone(name), /*location*/ name); + let emitFlags: NodeEmitFlags; + if (!allowComments) { + emitFlags |= NodeEmitFlags.NoComments; + } + if (!allowSourceMaps) { + emitFlags |= NodeEmitFlags.NoSourceMap; + } + if (emitFlags) { + setNodeEmitFlags(qualifiedName, emitFlags); + } + return qualifiedName; } - function getDeclarationName(node: DeclarationStatement | ClassExpression) { - return node.name ? getSynthesizedClone(node.name) : getGeneratedNameForNode(node); + /** + * Gets the declaration name used inside of a namespace or enum. + */ + function getNamespaceParameterName(node: ModuleDeclaration | EnumDeclaration) { + const name = getGeneratedNameForNode(node, node.name); + setNodeEmitFlags(name, NodeEmitFlags.NoComments); + return name; + } + + /** + * Gets the expression used to refer to a namespace or enum within the body + * of its declaration. + */ + function getNamespaceContainerName(node: ModuleDeclaration | EnumDeclaration) { + return getGeneratedNameForNode(node); + } + + /** + * Gets the local name for a declaration for use in expressions. + * + * A local name will *never* be prefixed with an module or namespace export modifier like + * "exports.". + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getLocalName(node: ClassDeclaration | FunctionDeclaration | ModuleDeclaration | EnumDeclaration, allowComments?: boolean) { + return getDeclarationName(node, allowComments, /*allowSourceMaps*/ true, NodeEmitFlags.LocalName); + } + + /** + * Gets the export name for a declaration for use in expressions. + * + * An export name will *always* be prefixed with an module or namespace export modifier + * like "exports." if one is required. + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getExportName(node: ClassDeclaration | FunctionDeclaration | ModuleDeclaration | EnumDeclaration, allowComments?: boolean) { + if (isNamespaceExport(node)) { + return getNamespaceMemberName(getDeclarationName(node), allowComments, /*allowSourceMaps*/ true); + } + + return getDeclarationName(node, allowComments, /*allowSourceMaps*/ true, NodeEmitFlags.ExportName); + } + + /** + * Gets the name for a declaration for use in declarations. + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + * @param emitFlags Additional NodeEmitFlags to specify for the name. + */ + function getDeclarationName(node: DeclarationStatement | ClassExpression, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags?: NodeEmitFlags) { + if (node.name) { + const name = getUniqueClone(node.name); + emitFlags |= getNodeEmitFlags(node.name); + if (!allowSourceMaps) { + emitFlags |= NodeEmitFlags.NoSourceMap; + } + + if (!allowComments) { + emitFlags |= NodeEmitFlags.NoComments; + } + + if (emitFlags) { + setNodeEmitFlags(name, emitFlags); + } + + return name; + } + else { + return getGeneratedNameForNode(node); + } } function getDeclarationNameExpression(node: DeclarationStatement) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0c13b134d1e..bbbe92df036 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2876,10 +2876,12 @@ namespace ts { NoSourceMap = 1 << 10, // Do not emit a source map location for this node. NoNestedSourceMaps = 1 << 11, // Do not emit source map locations for children of this node. NoTokenSourceMaps = 1 << 12, // Do not emit source map locations for tokens of this node. - NoComments = 1 << 13, // Do not emit comments for this node. - ExportName = 1 << 14, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal). - LocalName = 1 << 15, // Ensure an export prefix is not added for an identifier that points to an exported declaration. - Indented = 1 << 16, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter). + NoLeadingComments = 1 << 13, // Do not emit leading comments for this node. + NoTrailingComments = 1 << 14, // Do not emit trailing comments for this node. + NoComments = NoLeadingComments | NoTrailingComments, // Do not emit comments for this node. + ExportName = 1 << 15, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal). + LocalName = 1 << 16, // Ensure an export prefix is not added for an identifier that points to an exported declaration. + Indented = 1 << 17, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter). } /** Additional context provided to `visitEachChild` */ diff --git a/tests/baselines/reference/sourceMapValidationClasses.js b/tests/baselines/reference/sourceMapValidationClasses.js index 661892bc748..64517690f26 100644 --- a/tests/baselines/reference/sourceMapValidationClasses.js +++ b/tests/baselines/reference/sourceMapValidationClasses.js @@ -59,7 +59,7 @@ var Foo; function foo2(greeting) { var restGreetings /* more greeting */ = []; for (var _i = 1; _i < arguments.length; _i++) { - restGreetings /* more greeting */[_i - 1] = arguments[_i]; + restGreetings[_i - 1] = arguments[_i]; } var greeters = []; /* inline block comment */ greeters[0] = new Greeter(greeting); diff --git a/tests/baselines/reference/sourceMapValidationClasses.js.map b/tests/baselines/reference/sourceMapValidationClasses.js.map index bddc7694f10..205d5d55b78 100644 --- a/tests/baselines/reference/sourceMapValidationClasses.js.map +++ b/tests/baselines/reference/sourceMapValidationClasses.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationClasses.js.map] -{"version":3,"file":"sourceMapValidationClasses.js","sourceRoot":"","sources":["sourceMapValidationClasses.ts"],"names":[],"mappings":"AAAA,IAAO,GAAG,CAmCT;AAnCD,WAAO,GAAG;IAAC,IAAA,GAAG,CAmCb;IAnCU,WAAA,GAAG,EAAC,CAAC;QACZ,YAAY,CAAC;QAEb;YACI,iBAAmB,QAAgB;gBAAhB,aAAQ,GAAR,QAAQ,CAAQ;YACnC,CAAC;YAED,uBAAK,GAAL;gBACI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;YAC5C,CAAC;YACL,cAAC;QAAD,CAAC,AAPD,IAOC;QAGD,aAAa,QAAgB;YACzB,MAAM,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;QAED,IAAI,OAAO,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;QAC3C,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;QAE1B,cAAc,QAAgB;YAAE,kBAAiB,mBAAmB,MAAU;iBAA9C,WAA8C,CAA9C,sBAA8C,CAA9C,IAA8C;gBAA9C,cAAiB,mBAAmB,yBAAU;;YAC1E,IAAI,QAAQ,GAAc,EAAE,CAAC,CAAC,0BAA0B;YACxD,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;YACpC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,a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BAAmB,MAAU;iBAA9C,UAA8C,EAA9C,qBAA8C,EAA9C,IAA8C;gBAA9C,sCAA8C;;YAC1E,IAAI,QAAQ,GAAc,EAAE,CAAC,CAAC,0BAA0B;YACxD,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;YACpC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC5C,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACjD,CAAC;YAED,MAAM,CAAC,QAAQ,CAAC;QACpB,CAAC;QAED,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QACpC,qCAAqC;QACrC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;IACL,CAAC,EAnCU,GAAG,GAAH,OAAG,KAAH,OAAG,QAmCb;AAAD,CAAC,EAnCM,GAAG,KAAH,GAAG,QAmCT"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationClasses.sourcemap.txt b/tests/baselines/reference/sourceMapValidationClasses.sourcemap.txt index 29ad93cf74d..4120aa91b12 100644 --- a/tests/baselines/reference/sourceMapValidationClasses.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationClasses.sourcemap.txt @@ -123,26 +123,20 @@ sourceFile:sourceMapValidationClasses.ts 1->^^^^ 2 > ^^^^^^^^^^^ 3 > ^^^ -4 > ^^ -5 > ^ -6 > ^-> +4 > ^^^^-> 1-> 2 > 3 > Bar -4 > -5 > { 1->Emitted(4, 5) Source(1, 12) + SourceIndex(0) 2 >Emitted(4, 16) Source(1, 12) + SourceIndex(0) 3 >Emitted(4, 19) Source(1, 15) + SourceIndex(0) -4 >Emitted(4, 21) Source(1, 16) + SourceIndex(0) -5 >Emitted(4, 22) Source(1, 17) + SourceIndex(0) --- >>> "use strict"; 1->^^^^^^^^ 2 > ^^^^^^^^^^^^ 3 > ^ 4 > ^^^^^^^^^^^^^^^^-> -1-> +1-> { > 2 > "use strict" 3 > ; @@ -291,18 +285,24 @@ sourceFile:sourceMapValidationClasses.ts --- >>> function foo(greeting) { 1->^^^^^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^^^^^^^^^^^^^-> +2 > ^^^^^^^^^ +3 > ^^^ +4 > ^ +5 > ^^^^^^^^ +6 > ^^^^^^^^^^^^^-> 1-> > > > -2 > function foo( -3 > greeting: string +2 > function +3 > foo +4 > ( +5 > greeting: string 1->Emitted(15, 9) Source(14, 5) + SourceIndex(0) -2 >Emitted(15, 22) Source(14, 18) + SourceIndex(0) -3 >Emitted(15, 30) Source(14, 34) + SourceIndex(0) +2 >Emitted(15, 18) Source(14, 14) + SourceIndex(0) +3 >Emitted(15, 21) Source(14, 17) + SourceIndex(0) +4 >Emitted(15, 22) Source(14, 18) + SourceIndex(0) +5 >Emitted(15, 30) Source(14, 34) + SourceIndex(0) --- >>> return new Greeter(greeting); 1->^^^^^^^^^^^^ @@ -410,17 +410,23 @@ sourceFile:sourceMapValidationClasses.ts --- >>> function foo2(greeting) { 1 >^^^^^^^^ -2 > ^^^^^^^^^^^^^^ -3 > ^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +2 > ^^^^^^^^^ +3 > ^^^^ +4 > ^ +5 > ^^^^^^^^ +6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > > -2 > function foo2( -3 > greeting: string +2 > function +3 > foo2 +4 > ( +5 > greeting: string 1 >Emitted(20, 9) Source(21, 5) + SourceIndex(0) -2 >Emitted(20, 23) Source(21, 19) + SourceIndex(0) -3 >Emitted(20, 31) Source(21, 35) + SourceIndex(0) +2 >Emitted(20, 18) Source(21, 14) + SourceIndex(0) +3 >Emitted(20, 22) Source(21, 18) + SourceIndex(0) +4 >Emitted(20, 23) Source(21, 19) + SourceIndex(0) +5 >Emitted(20, 31) Source(21, 35) + SourceIndex(0) --- >>> var restGreetings /* more greeting */ = []; 1->^^^^^^^^^^^^ @@ -439,38 +445,31 @@ sourceFile:sourceMapValidationClasses.ts --- >>> for (var _i = 1; _i < arguments.length; _i++) { 1->^^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^^^ -5 > ^ +2 > ^^^^^^^^^^ +3 > ^^ +4 > ^^^^^^^^^^^^^^^^^^^^^ +5 > ^^ 6 > ^^^^ -7 > ^^^^^^^^^^^^^^^^^^^-> 1-> 2 > ...restGreetings /* more greeting */: string[] -3 > +3 > 4 > ...restGreetings /* more greeting */: string[] -5 > +5 > 6 > ...restGreetings /* more greeting */: string[] 1->Emitted(22, 18) Source(21, 37) + SourceIndex(0) -2 >Emitted(22, 29) Source(21, 83) + SourceIndex(0) +2 >Emitted(22, 28) Source(21, 83) + SourceIndex(0) 3 >Emitted(22, 30) Source(21, 37) + SourceIndex(0) -4 >Emitted(22, 52) Source(21, 83) + SourceIndex(0) +4 >Emitted(22, 51) Source(21, 83) + SourceIndex(0) 5 >Emitted(22, 53) Source(21, 37) + SourceIndex(0) 6 >Emitted(22, 57) Source(21, 83) + SourceIndex(0) --- ->>> restGreetings /* more greeting */[_i - 1] = arguments[_i]; -1->^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^ -1-> -2 > ...restGreetings -3 > /* more greeting */ -4 > : string[] -1->Emitted(23, 17) Source(21, 37) + SourceIndex(0) -2 >Emitted(23, 31) Source(21, 54) + SourceIndex(0) -3 >Emitted(23, 50) Source(21, 73) + SourceIndex(0) -4 >Emitted(23, 75) Source(21, 83) + SourceIndex(0) +>>> restGreetings[_i - 1] = arguments[_i]; +1 >^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +1 > +2 > ...restGreetings /* more greeting */: string[] +1 >Emitted(23, 17) Source(21, 37) + SourceIndex(0) +2 >Emitted(23, 55) Source(21, 83) + SourceIndex(0) --- >>> } >>> var greeters = []; /* inline block comment */ From ef0d4f3f8c1a3b0bf13b79cc73b7f1e18b1cfe79 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 18 Apr 2016 16:52:17 -0700 Subject: [PATCH 3/5] Cleanup and accepting some baselines. --- src/compiler/transformers/es6.ts | 59 ++++++++++++++----- src/compiler/transformers/module/module.ts | 15 +++-- src/compiler/transformers/ts.ts | 2 +- .../reference/duplicateAnonymousInners1.js | 2 + tests/baselines/reference/privacyGloImport.js | 3 + tests/baselines/reference/tsxEmit3.js | 2 + 6 files changed, 62 insertions(+), 21 deletions(-) diff --git a/src/compiler/transformers/es6.ts b/src/compiler/transformers/es6.ts index d7e38611b93..620eebc5888 100644 --- a/src/compiler/transformers/es6.ts +++ b/src/compiler/transformers/es6.ts @@ -612,7 +612,6 @@ namespace ts { enableSubstitutionsForBlockScopedBindings(); } - const closingBraceLocation = { pos: node.end - 1, end: node.end }; const baseTypeNode = getClassExtendsHeritageClauseElement(node); const classFunction = createFunctionExpression( /*asteriskToken*/ undefined, @@ -663,23 +662,23 @@ namespace ts { // Create a synthetic text range for the return statement. const closingBraceLocation = createTokenRange(skipTrivia(currentText, node.members.end), SyntaxKind.CloseBraceToken); - const name = getDeclarationName(node); + const localName = getLocalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. - const outer = createPartiallyEmittedExpression(name); + const outer = createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; setNodeEmitFlags(outer, NodeEmitFlags.NoComments); const statement = createReturn(outer); statement.pos = closingBraceLocation.pos; - statements.push(statement); setNodeEmitFlags(statement, NodeEmitFlags.NoComments | NodeEmitFlags.NoTokenSourceMaps); + statements.push(statement); addRange(statements, endLexicalEnvironment()); + const block = createBlock(createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true); setNodeEmitFlags(block, NodeEmitFlags.NoComments); - return block; } @@ -2769,21 +2768,53 @@ namespace ts { return node; } + /** + * Gets the local name for a declaration for use in expressions. + * + * A local name will *never* be prefixed with an module or namespace export modifier like + * "exports.". + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getLocalName(node: ClassDeclaration | ClassExpression | FunctionDeclaration, allowComments?: boolean, allowSourceMaps?: boolean) { + return getDeclarationName(node, allowComments, allowSourceMaps, NodeEmitFlags.LocalName); + } + + /** + * Gets the export name for a declaration for use in expressions. + * + * An export name will *always* be prefixed with an module or namespace export modifier + * like "exports." if one is required. + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getExportName(node: ClassDeclaration | ClassExpression | FunctionDeclaration, allowComments?: boolean, allowSourceMaps?: boolean) { + return getDeclarationName(node, allowComments, allowSourceMaps, NodeEmitFlags.ExportName); + } + /** * Gets the name of a declaration, without source map or comments. * * @param node The declaration. * @param allowComments Allow comments for the name. */ - function getDeclarationName(node: DeclarationStatement | ClassExpression, allowComments?: boolean) { - if (node.name) { - const name = getMutableClone(node.name); - let flags = NodeEmitFlags.NoSourceMap; - if (!allowComments) { - flags |= NodeEmitFlags.NoComments; + function getDeclarationName(node: DeclarationStatement | ClassExpression, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags?: NodeEmitFlags) { + if (node.name && !isGeneratedIdentifier(node.name)) { + const name = getUniqueClone(node.name); + emitFlags |= getNodeEmitFlags(node.name); + if (!allowSourceMaps) { + emitFlags |= NodeEmitFlags.NoSourceMap; + } + if (!allowComments) { + emitFlags |= NodeEmitFlags.NoComments; + } + if (emitFlags) { + setNodeEmitFlags(name, emitFlags); } - - setNodeEmitFlags(name, flags | getNodeEmitFlags(name)); return name; } @@ -2791,7 +2822,7 @@ namespace ts { } function getClassMemberPrefix(node: ClassExpression | ClassDeclaration, member: ClassElement) { - const expression = getDeclarationName(node); + const expression = getLocalName(node); return hasModifier(member, ModifierFlags.Static) ? expression : createPropertyAccess(expression, "prototype"); } diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 83604946102..ca5534c2bdd 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -647,12 +647,15 @@ namespace ts { setNodeEmitFlags(name, NodeEmitFlags.NoSubstitution); if (hasModifier(node, ModifierFlags.Export)) { statements.push( - createClassDeclaration( - /*modifiers*/ undefined, - name, - node.heritageClauses, - node.members, - /*location*/ node + setOriginalNode( + createClassDeclaration( + /*modifiers*/ undefined, + name, + node.heritageClauses, + node.members, + /*location*/ node + ), + /*original*/ node ) ); diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index c34ead8dd63..efc7aeddf2c 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -480,7 +480,7 @@ namespace ts { } else if (node.decorators) { if (isDefaultExternalModuleExport(node)) { - statements.push(createExportDefault(name || getGeneratedNameForNode(node))); + statements.push(createExportDefault(getLocalName(node))); } else if (isNamedExternalModuleExport(node)) { statements.push(createExternalModuleExport(name)); diff --git a/tests/baselines/reference/duplicateAnonymousInners1.js b/tests/baselines/reference/duplicateAnonymousInners1.js index 5bb73bf68ed..24f79566d56 100644 --- a/tests/baselines/reference/duplicateAnonymousInners1.js +++ b/tests/baselines/reference/duplicateAnonymousInners1.js @@ -49,4 +49,6 @@ var Foo; } return Helper; }()); + // Inner should not show up in intellisense + // Outer should show up in intellisense })(Foo || (Foo = {})); diff --git a/tests/baselines/reference/privacyGloImport.js b/tests/baselines/reference/privacyGloImport.js index 407ac5bb8d5..ecafec9d639 100644 --- a/tests/baselines/reference/privacyGloImport.js +++ b/tests/baselines/reference/privacyGloImport.js @@ -235,6 +235,8 @@ var m1; //var m1_im4_private_v4_private = m1_im4_private.f1(); m1.m1_im1_public = m1_M1_public; m1.m1_im2_public = m1_M2_private; + //export import m1_im3_public = require("m1_M3_public"); + //export import m1_im4_public = require("m1_M4_private"); })(m1 || (m1 = {})); var glo_M1_public; (function (glo_M1_public) { @@ -256,5 +258,6 @@ var m2; var m4; (function (m4) { var a = 10; + //import m2 = require("use_glo_M1_public"); })(m4 || (m4 = {})); })(m2 || (m2 = {})); diff --git a/tests/baselines/reference/tsxEmit3.js b/tests/baselines/reference/tsxEmit3.js index 9501df4e237..33e1975cdbc 100644 --- a/tests/baselines/reference/tsxEmit3.js +++ b/tests/baselines/reference/tsxEmit3.js @@ -58,6 +58,8 @@ var M; return Bar; }()); S.Bar = Bar; + // Emit Foo + // Foo, ; })(S = M.S || (M.S = {})); })(M || (M = {})); var M; From 3933be08f9a150c895ac48200e703dcb88a2aecd Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 19 Apr 2016 12:01:38 -0700 Subject: [PATCH 4/5] Adjusts some source map locations. Updates baselines. --- src/compiler/printer.ts | 38 +++++++---- src/compiler/transformers/es6.ts | 68 ++++++++++--------- src/compiler/transformers/ts.ts | 27 +++++--- tests/baselines/reference/ES5For-of1.js.map | 2 +- .../reference/ES5For-of1.sourcemap.txt | 3 - tests/baselines/reference/ES5For-of13.js.map | 2 +- .../reference/ES5For-of13.sourcemap.txt | 3 - tests/baselines/reference/ES5For-of25.js.map | 2 +- .../reference/ES5For-of25.sourcemap.txt | 3 - tests/baselines/reference/ES5For-of26.js.map | 2 +- .../reference/ES5For-of26.sourcemap.txt | 5 +- tests/baselines/reference/ES5For-of3.js.map | 2 +- .../reference/ES5For-of3.sourcemap.txt | 3 - tests/baselines/reference/ES5For-of8.js.map | 2 +- .../reference/ES5For-of8.sourcemap.txt | 13 ++-- ...computedPropertyNamesSourceMap1_ES6.js.map | 2 +- ...dPropertyNamesSourceMap1_ES6.sourcemap.txt | 27 ++++---- .../reference/es6-sourcemap-amd.js.map | 2 +- .../reference/es6-sourcemap-amd.sourcemap.txt | 27 ++++---- .../reference/isolatedModulesSourceMap.js.map | 2 +- .../isolatedModulesSourceMap.sourcemap.txt | 41 +++++------ .../recursiveClassReferenceTest.js.map | 2 +- .../recursiveClassReferenceTest.sourcemap.txt | 30 ++------ 23 files changed, 153 insertions(+), 155 deletions(-) diff --git a/src/compiler/printer.ts b/src/compiler/printer.ts index 0bb3388bfe1..d39955e6968 100644 --- a/src/compiler/printer.ts +++ b/src/compiler/printer.ts @@ -1276,13 +1276,15 @@ const _super = (function (geti, seti) { } function emitIfStatement(node: IfStatement) { - write("if ("); + const openParenPos = writeToken(SyntaxKind.IfKeyword, node.pos); + write(" "); + writeToken(SyntaxKind.OpenParenToken, openParenPos); emitExpression(node.expression); - write(")"); + writeToken(SyntaxKind.CloseParenToken, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - write("else"); + writeToken(SyntaxKind.ElseKeyword, node.thenStatement.end); if (node.elseStatement.kind === SyntaxKind.IfStatement) { write(" "); emit(node.elseStatement); @@ -1329,20 +1331,24 @@ const _super = (function (geti, seti) { } function emitForInStatement(node: ForInStatement) { - write("for ("); + const openParenPos = writeToken(SyntaxKind.ForKeyword, node.pos); + write(" "); + writeToken(SyntaxKind.OpenParenToken, openParenPos); emitForBinding(node.initializer); write(" in "); emitExpression(node.expression); - write(")"); + writeToken(SyntaxKind.CloseParenToken, node.expression.end); emitEmbeddedStatement(node.statement); } function emitForOfStatement(node: ForOfStatement) { - write("for ("); + const openParenPos = writeToken(SyntaxKind.ForKeyword, node.pos); + write(" "); + writeToken(SyntaxKind.OpenParenToken, openParenPos); emitForBinding(node.initializer); write(" of "); emitExpression(node.expression); - write(")"); + writeToken(SyntaxKind.CloseParenToken, node.expression.end); emitEmbeddedStatement(node.statement); } @@ -1358,13 +1364,13 @@ const _super = (function (geti, seti) { } function emitContinueStatement(node: ContinueStatement) { - write("continue"); + writeToken(SyntaxKind.ContinueKeyword, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitBreakStatement(node: BreakStatement) { - write("break"); + writeToken(SyntaxKind.BreakKeyword, node.pos); emitWithPrefix(" ", node.label); write(";"); } @@ -1383,9 +1389,12 @@ const _super = (function (geti, seti) { } function emitSwitchStatement(node: SwitchStatement) { - write("switch ("); + const openParenPos = writeToken(SyntaxKind.SwitchKeyword, node.pos); + write(" "); + writeToken(SyntaxKind.OpenParenToken, openParenPos); emitExpression(node.expression); - write(") "); + writeToken(SyntaxKind.CloseParenToken, node.expression.end); + write(" "); emit(node.caseBlock); } @@ -1872,9 +1881,12 @@ const _super = (function (geti, seti) { function emitCatchClause(node: CatchClause) { writeLine(); - write("catch ("); + const openParenPos = writeToken(SyntaxKind.CatchKeyword, node.pos); + write(" "); + writeToken(SyntaxKind.OpenParenToken, openParenPos); emit(node.variableDeclaration); - write(") "); + writeToken(SyntaxKind.CloseParenToken, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); + write(" "); emit(node.block); } diff --git a/src/compiler/transformers/es6.ts b/src/compiler/transformers/es6.ts index 620eebc5888..9a5dafabe37 100644 --- a/src/compiler/transformers/es6.ts +++ b/src/compiler/transformers/es6.ts @@ -612,12 +612,12 @@ namespace ts { enableSubstitutionsForBlockScopedBindings(); } - const baseTypeNode = getClassExtendsHeritageClauseElement(node); + const extendsClauseElement = getClassExtendsHeritageClauseElement(node); const classFunction = createFunctionExpression( /*asteriskToken*/ undefined, /*name*/ undefined, - baseTypeNode ? [createParameter("_super")] : [], - transformClassBody(node, baseTypeNode !== undefined) + extendsClauseElement ? [createParameter("_super")] : [], + transformClassBody(node, extendsClauseElement) ); // To preserve the behavior of the old emitter, we explicitly indent @@ -640,8 +640,8 @@ namespace ts { return createParen( createCall( outer, - baseTypeNode - ? [visitNode(baseTypeNode.expression, visitor, isExpression)] + extendsClauseElement + ? [visitNode(extendsClauseElement.expression, visitor, isExpression)] : [] ) ); @@ -651,13 +651,13 @@ namespace ts { * Transforms a ClassExpression or ClassDeclaration into a function body. * * @param node A ClassExpression or ClassDeclaration node. - * @param hasExtendsClause A value indicating whether the class has an `extends` clause. + * @param extendsClauseElement The expression for the class `extends` clause. */ - function transformClassBody(node: ClassExpression | ClassDeclaration, hasExtendsClause: boolean): Block { + function transformClassBody(node: ClassExpression | ClassDeclaration, extendsClauseElement: ExpressionWithTypeArguments): Block { const statements: Statement[] = []; startLexicalEnvironment(); - addExtendsHelperIfNeeded(statements, node, hasExtendsClause); - addConstructor(statements, node, hasExtendsClause); + addExtendsHelperIfNeeded(statements, node, extendsClauseElement); + addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. @@ -687,13 +687,14 @@ namespace ts { * * @param statements The statements of the class body function. * @param node The ClassExpression or ClassDeclaration node. - * @param hasExtendsClause A value indicating whether the class has an `extends` clause. + * @param extendsClauseElement The expression for the class `extends` clause. */ - function addExtendsHelperIfNeeded(statements: Statement[], node: ClassExpression | ClassDeclaration, hasExtendsClause: boolean): void { - if (hasExtendsClause) { + function addExtendsHelperIfNeeded(statements: Statement[], node: ClassExpression | ClassDeclaration, extendsClauseElement: ExpressionWithTypeArguments): void { + if (extendsClauseElement) { statements.push( createStatement( - createExtendsHelper(getDeclarationName(node)) + createExtendsHelper(getDeclarationName(node)), + /*location*/ extendsClauseElement ) ); } @@ -704,18 +705,18 @@ namespace ts { * * @param statements The statements of the class body function. * @param node The ClassExpression or ClassDeclaration node. - * @param hasExtendsClause A value indicating whether the class has an `extends` clause. + * @param extendsClauseElement The expression for the class `extends` clause. */ - function addConstructor(statements: Statement[], node: ClassExpression | ClassDeclaration, hasExtendsClause: boolean): void { + function addConstructor(statements: Statement[], node: ClassExpression | ClassDeclaration, extendsClauseElement: ExpressionWithTypeArguments): void { const constructor = getFirstConstructorWithBody(node); - const hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause); + const hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); statements.push( createFunctionDeclaration( /*modifiers*/ undefined, /*asteriskToken*/ undefined, getDeclarationName(node), transformConstructorParameters(constructor, hasSynthesizedSuper), - transformConstructorBody(constructor, node, hasExtendsClause, hasSynthesizedSuper), + transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper), /*location*/ constructor || node ) ); @@ -746,11 +747,11 @@ namespace ts { * * @param constructor The constructor for the class. * @param node The node which contains the constructor. - * @param hasExtendsClause A value indicating whether the class has an `extends` clause. + * @param extendsClauseElement The expression for the class `extends` clause. * @param hasSynthesizedSuper A value indicating whether the constructor starts with a * synthesized `super` call. */ - function transformConstructorBody(constructor: ConstructorDeclaration, node: ClassDeclaration | ClassExpression, hasExtendsClause: boolean, hasSynthesizedSuper: boolean) { + function transformConstructorBody(constructor: ConstructorDeclaration, node: ClassDeclaration | ClassExpression, extendsClauseElement: ExpressionWithTypeArguments, hasSynthesizedSuper: boolean) { const statements: Statement[] = []; startLexicalEnvironment(); if (constructor) { @@ -759,7 +760,7 @@ namespace ts { addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); } - addDefaultSuperCallIfNeeded(statements, constructor, hasExtendsClause, hasSynthesizedSuper); + addDefaultSuperCallIfNeeded(statements, constructor, extendsClauseElement, hasSynthesizedSuper); if (constructor) { const body = saveStateAndInvoke(constructor, hasSynthesizedSuper ? transformConstructorBodyWithSynthesizedSuper : transformConstructorBodyWithoutSynthesizedSuper); @@ -796,24 +797,25 @@ namespace ts { * * @param statements The statements for the new constructor body. * @param constructor The constructor for the class. - * @param hasExtendsClause A value indicating whether the class has an `extends` clause. + * @param extendsClauseElement The expression for the class `extends` clause. * @param hasSynthesizedSuper A value indicating whether the constructor starts with a * synthesized `super` call. */ - function addDefaultSuperCallIfNeeded(statements: Statement[], constructor: ConstructorDeclaration, hasExtendsClause: boolean, hasSynthesizedSuper: boolean) { + function addDefaultSuperCallIfNeeded(statements: Statement[], constructor: ConstructorDeclaration, extendsClauseElement: ExpressionWithTypeArguments, hasSynthesizedSuper: boolean) { // If the TypeScript transformer needed to synthesize a constructor for property // initializers, it would have also added a synthetic `...args` parameter and // `super` call. // If this is the case, or if the class has an `extends` clause but no // constructor, we emit a synthesized call to `_super`. - if (constructor ? hasSynthesizedSuper : hasExtendsClause) { + if (constructor ? hasSynthesizedSuper : extendsClauseElement) { statements.push( createStatement( createFunctionApply( createIdentifier("_super"), createThis(), createIdentifier("arguments") - ) + ), + /*location*/ extendsClauseElement ) ); } @@ -1669,7 +1671,7 @@ namespace ts { visitor ) ), - /*location*/ initializer + /*location*/ moveRangeEnd(initializer, -1) ) ); } @@ -1684,8 +1686,8 @@ namespace ts { firstDeclaration ? firstDeclaration.name : createTempVariable(/*recordTempVariable*/ undefined), createElementAccess(rhsReference, counter) ) - ]), - /*location*/ initializer + ], /*location*/ moveRangePos(initializer, -1)), + /*location*/ moveRangeEnd(initializer, -1) ) ); } @@ -1709,7 +1711,8 @@ namespace ts { ); } else { - statements.push(createStatement(assignment, /*location*/ node.initializer)); + assignment.end = initializer.end; + statements.push(createStatement(assignment, /*location*/ moveRangeEnd(initializer, -1))); } } @@ -1726,10 +1729,13 @@ namespace ts { } } + // The old emitter does not emit source maps for the expression + setNodeEmitFlags(expression, NodeEmitFlags.NoSourceMap | getNodeEmitFlags(expression)); + return createFor( createVariableDeclarationList( [ - createVariableDeclaration(counter, createLiteral(0), /*location*/ node.expression), + createVariableDeclaration(counter, createLiteral(0), /*location*/ moveRangePos(node.expression, -1)), createVariableDeclaration(rhsReference, expression, /*location*/ node.expression) ], /*location*/ node.expression @@ -1737,9 +1743,9 @@ namespace ts { createLessThan( counter, createPropertyAccess(rhsReference, "length"), - /*location*/ initializer + /*location*/ node.expression ), - createPostfixIncrement(counter, /*location*/ initializer), + createPostfixIncrement(counter, /*location*/ node.expression), createBlock( statements ), diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index efc7aeddf2c..80f07a4782b 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -2660,13 +2660,22 @@ namespace ts { } function addExportMemberAssignment(statements: Statement[], node: DeclarationStatement) { - statements.push(createNamespaceExport(getDeclarationName(node), getDeclarationName(node))); + statements.push( + createStatement( + createAssignment( + getExportName(node), + getLocalName(node, /*noSourceMaps*/ true), + /*location*/ node + ), + /*location*/ moveRangePos(node, -1) + ) + ); } function createNamespaceExport(exportName: Identifier, exportValue: Expression, location?: TextRange) { return createStatement( createAssignment( - getNamespaceMemberName(exportName), + getNamespaceMemberName(exportName, /*allowComments*/ false, /*allowSourceMaps*/ true), exportValue ), location @@ -2720,11 +2729,11 @@ namespace ts { * "exports.". * * @param node The declaration. + * @param noSourceMaps A value indicating whether source maps may not be emitted for the name. * @param allowComments A value indicating whether comments may be emitted for the name. - * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ - function getLocalName(node: ClassDeclaration | FunctionDeclaration | ModuleDeclaration | EnumDeclaration, allowComments?: boolean) { - return getDeclarationName(node, allowComments, /*allowSourceMaps*/ true, NodeEmitFlags.LocalName); + function getLocalName(node: DeclarationStatement | ClassExpression, noSourceMaps?: boolean, allowComments?: boolean) { + return getDeclarationName(node, allowComments, !noSourceMaps, NodeEmitFlags.LocalName); } /** @@ -2734,15 +2743,15 @@ namespace ts { * like "exports." if one is required. * * @param node The declaration. + * @param noSourceMaps A value indicating whether source maps may not be emitted for the name. * @param allowComments A value indicating whether comments may be emitted for the name. - * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ - function getExportName(node: ClassDeclaration | FunctionDeclaration | ModuleDeclaration | EnumDeclaration, allowComments?: boolean) { + function getExportName(node: DeclarationStatement | ClassExpression, noSourceMaps?: boolean, allowComments?: boolean) { if (isNamespaceExport(node)) { - return getNamespaceMemberName(getDeclarationName(node), allowComments, /*allowSourceMaps*/ true); + return getNamespaceMemberName(getDeclarationName(node), allowComments, !noSourceMaps); } - return getDeclarationName(node, allowComments, /*allowSourceMaps*/ true, NodeEmitFlags.ExportName); + return getDeclarationName(node, allowComments, !noSourceMaps, NodeEmitFlags.ExportName); } /** diff --git a/tests/baselines/reference/ES5For-of1.js.map b/tests/baselines/reference/ES5For-of1.js.map index bd729517462..6415b662186 100644 --- a/tests/baselines/reference/ES5For-of1.js.map +++ b/tests/baselines/reference/ES5For-of1.js.map @@ -1,2 +1,2 @@ //// [ES5For-of1.js.map] -{"version":3,"file":"ES5For-of1.js","sourceRoot":"","sources":["ES5For-of1.ts"],"names":[],"mappings":"AAAA,GAAG,CAAC,CAAU,UAAe,EAAf,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAf,cAAe,EAAf,IAAe,CAAC;IAAzB,IAAI,CAAC,SAAA;IACN,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAClB"} \ No newline at end of file +{"version":3,"file":"ES5For-of1.js","sourceRoot":"","sources":["ES5For-of1.ts"],"names":[],"mappings":"AAAA,GAAG,CAAC,CAAU,UAAe,EAAf,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAf,cAAe,EAAf,IAAe;IAAxB,IAAI,CAAC,SAAA;IACN,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAClB"} \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of1.sourcemap.txt b/tests/baselines/reference/ES5For-of1.sourcemap.txt index 5ae1084df25..f6a89d058fe 100644 --- a/tests/baselines/reference/ES5For-of1.sourcemap.txt +++ b/tests/baselines/reference/ES5For-of1.sourcemap.txt @@ -26,7 +26,6 @@ sourceFile:ES5For-of1.ts 15> ^^^^^^^^^^^^^^ 16> ^^ 17> ^^^^ -18> ^ 1 > 2 >for 3 > @@ -44,7 +43,6 @@ sourceFile:ES5For-of1.ts 15> ['a', 'b', 'c'] 16> 17> ['a', 'b', 'c'] -18> ) 1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) 2 >Emitted(1, 4) Source(1, 4) + SourceIndex(0) 3 >Emitted(1, 5) Source(1, 5) + SourceIndex(0) @@ -62,7 +60,6 @@ sourceFile:ES5For-of1.ts 15>Emitted(1, 54) Source(1, 30) + SourceIndex(0) 16>Emitted(1, 56) Source(1, 15) + SourceIndex(0) 17>Emitted(1, 60) Source(1, 30) + SourceIndex(0) -18>Emitted(1, 61) Source(1, 31) + SourceIndex(0) --- >>> var v = _a[_i]; 1 >^^^^ diff --git a/tests/baselines/reference/ES5For-of13.js.map b/tests/baselines/reference/ES5For-of13.js.map index 3fa2bd27348..1cb5d6039d3 100644 --- a/tests/baselines/reference/ES5For-of13.js.map +++ b/tests/baselines/reference/ES5For-of13.js.map @@ -1,2 +1,2 @@ //// [ES5For-of13.js.map] -{"version":3,"file":"ES5For-of13.js","sourceRoot":"","sources":["ES5For-of13.ts"],"names":[],"mappings":"AAAA,GAAG,CAAC,CAAU,UAAe,EAAf,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAf,cAAe,EAAf,IAAe,CAAC;IAAzB,IAAI,CAAC,SAAA;IACN,IAAI,CAAC,GAAG,CAAC,CAAC;CACb"} \ No newline at end of file +{"version":3,"file":"ES5For-of13.js","sourceRoot":"","sources":["ES5For-of13.ts"],"names":[],"mappings":"AAAA,GAAG,CAAC,CAAU,UAAe,EAAf,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAf,cAAe,EAAf,IAAe;IAAxB,IAAI,CAAC,SAAA;IACN,IAAI,CAAC,GAAG,CAAC,CAAC;CACb"} \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of13.sourcemap.txt b/tests/baselines/reference/ES5For-of13.sourcemap.txt index 410560ac78e..a7386dddc50 100644 --- a/tests/baselines/reference/ES5For-of13.sourcemap.txt +++ b/tests/baselines/reference/ES5For-of13.sourcemap.txt @@ -26,7 +26,6 @@ sourceFile:ES5For-of13.ts 15> ^^^^^^^^^^^^^^ 16> ^^ 17> ^^^^ -18> ^ 1 > 2 >for 3 > @@ -44,7 +43,6 @@ sourceFile:ES5For-of13.ts 15> ['a', 'b', 'c'] 16> 17> ['a', 'b', 'c'] -18> ) 1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) 2 >Emitted(1, 4) Source(1, 4) + SourceIndex(0) 3 >Emitted(1, 5) Source(1, 5) + SourceIndex(0) @@ -62,7 +60,6 @@ sourceFile:ES5For-of13.ts 15>Emitted(1, 54) Source(1, 30) + SourceIndex(0) 16>Emitted(1, 56) Source(1, 15) + SourceIndex(0) 17>Emitted(1, 60) Source(1, 30) + SourceIndex(0) -18>Emitted(1, 61) Source(1, 31) + SourceIndex(0) --- >>> var v = _a[_i]; 1 >^^^^ diff --git a/tests/baselines/reference/ES5For-of25.js.map b/tests/baselines/reference/ES5For-of25.js.map index 5ccc838a488..f1c97506f2d 100644 --- a/tests/baselines/reference/ES5For-of25.js.map +++ b/tests/baselines/reference/ES5For-of25.js.map @@ -1,2 +1,2 @@ //// [ES5For-of25.js.map] -{"version":3,"file":"ES5For-of25.js","sourceRoot":"","sources":["ES5For-of25.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,GAAG,CAAC,CAAU,UAAC,EAAD,OAAC,EAAD,eAAC,EAAD,IAAC,CAAC;IAAX,IAAI,CAAC,UAAA;IACN,CAAC,CAAC;IACF,CAAC,CAAC;CACL"} \ No newline at end of file +{"version":3,"file":"ES5For-of25.js","sourceRoot":"","sources":["ES5For-of25.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAClB,GAAG,CAAC,CAAU,UAAC,EAAD,OAAC,EAAD,eAAC,EAAD,IAAC;IAAV,IAAI,CAAC,UAAA;IACN,CAAC,CAAC;IACF,CAAC,CAAC;CACL"} \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of25.sourcemap.txt b/tests/baselines/reference/ES5For-of25.sourcemap.txt index 765aa707701..31b10538fa6 100644 --- a/tests/baselines/reference/ES5For-of25.sourcemap.txt +++ b/tests/baselines/reference/ES5For-of25.sourcemap.txt @@ -59,7 +59,6 @@ sourceFile:ES5For-of25.ts 9 > ^^^^^^^^^^^^^^^ 10> ^^ 11> ^^^^ -12> ^ 1-> > 2 >for @@ -72,7 +71,6 @@ sourceFile:ES5For-of25.ts 9 > a 10> 11> a -12> ) 1->Emitted(2, 1) Source(2, 1) + SourceIndex(0) 2 >Emitted(2, 4) Source(2, 4) + SourceIndex(0) 3 >Emitted(2, 5) Source(2, 5) + SourceIndex(0) @@ -84,7 +82,6 @@ sourceFile:ES5For-of25.ts 9 >Emitted(2, 42) Source(2, 16) + SourceIndex(0) 10>Emitted(2, 44) Source(2, 15) + SourceIndex(0) 11>Emitted(2, 48) Source(2, 16) + SourceIndex(0) -12>Emitted(2, 49) Source(2, 17) + SourceIndex(0) --- >>> var v = a_1[_i]; 1 >^^^^ diff --git a/tests/baselines/reference/ES5For-of26.js.map b/tests/baselines/reference/ES5For-of26.js.map index 9dcebf97134..0e8145e4a35 100644 --- a/tests/baselines/reference/ES5For-of26.js.map +++ b/tests/baselines/reference/ES5For-of26.js.map @@ -1,2 +1,2 @@ //// [ES5For-of26.js.map] -{"version":3,"file":"ES5For-of26.js","sourceRoot":"","sources":["ES5For-of26.ts"],"names":[],"mappings":"AAAA,GAAG,CAAC,CAAuB,UAAM,EAAN,MAAC,CAAC,EAAE,CAAC,CAAC,EAAN,cAAM,EAAN,IAAM,CAAC;IAA7B,eAAkB,EAAb,UAAK,EAAL,0BAAK,EAAE,UAAK,EAAL,0BAAK;IAClB,CAAC,CAAC;IACF,CAAC,CAAC;CACL"} \ No newline at end of file +{"version":3,"file":"ES5For-of26.js","sourceRoot":"","sources":["ES5For-of26.ts"],"names":[],"mappings":"AAAA,GAAG,CAAC,CAAuB,UAAM,EAAN,MAAC,CAAC,EAAE,CAAC,CAAC,EAAN,cAAM,EAAN,IAAM;IAA5B,eAAkB,EAAb,UAAK,EAAL,0BAAK,EAAE,UAAK,EAAL,0BAAK;IAClB,CAAC,CAAC;IACF,CAAC,CAAC;CACL"} \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of26.sourcemap.txt b/tests/baselines/reference/ES5For-of26.sourcemap.txt index 00a1cc55f37..50966d5a9df 100644 --- a/tests/baselines/reference/ES5For-of26.sourcemap.txt +++ b/tests/baselines/reference/ES5For-of26.sourcemap.txt @@ -24,8 +24,7 @@ sourceFile:ES5For-of26.ts 13> ^^^^^^^^^^^^^^ 14> ^^ 15> ^^^^ -16> ^ -17> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +16> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > 2 >for 3 > @@ -41,7 +40,6 @@ sourceFile:ES5For-of26.ts 13> [2, 3] 14> 15> [2, 3] -16> ) 1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) 2 >Emitted(1, 4) Source(1, 4) + SourceIndex(0) 3 >Emitted(1, 5) Source(1, 5) + SourceIndex(0) @@ -57,7 +55,6 @@ sourceFile:ES5For-of26.ts 13>Emitted(1, 45) Source(1, 34) + SourceIndex(0) 14>Emitted(1, 47) Source(1, 28) + SourceIndex(0) 15>Emitted(1, 51) Source(1, 34) + SourceIndex(0) -16>Emitted(1, 52) Source(1, 35) + SourceIndex(0) --- >>> var _b = _a[_i], _c = _b[0], a = _c === void 0 ? 0 : _c, _d = _b[1], b = _d === void 0 ? 1 : _d; 1->^^^^ diff --git a/tests/baselines/reference/ES5For-of3.js.map b/tests/baselines/reference/ES5For-of3.js.map index 5a91ff28e9c..ffcee0b3a52 100644 --- a/tests/baselines/reference/ES5For-of3.js.map +++ b/tests/baselines/reference/ES5For-of3.js.map @@ -1,2 +1,2 @@ //// [ES5For-of3.js.map] -{"version":3,"file":"ES5For-of3.js","sourceRoot":"","sources":["ES5For-of3.ts"],"names":[],"mappings":"AAAA,GAAG,CAAC,CAAU,UAAe,EAAf,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAf,cAAe,EAAf,IAAe,CAAC;IAAzB,IAAI,CAAC,SAAA;IACN,IAAI,CAAC,GAAG,CAAC,CAAC;CAAA"} \ No newline at end of file +{"version":3,"file":"ES5For-of3.js","sourceRoot":"","sources":["ES5For-of3.ts"],"names":[],"mappings":"AAAA,GAAG,CAAC,CAAU,UAAe,EAAf,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAf,cAAe,EAAf,IAAe;IAAxB,IAAI,CAAC,SAAA;IACN,IAAI,CAAC,GAAG,CAAC,CAAC;CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of3.sourcemap.txt b/tests/baselines/reference/ES5For-of3.sourcemap.txt index 1c728f5df67..4eea9dfaed4 100644 --- a/tests/baselines/reference/ES5For-of3.sourcemap.txt +++ b/tests/baselines/reference/ES5For-of3.sourcemap.txt @@ -26,7 +26,6 @@ sourceFile:ES5For-of3.ts 15> ^^^^^^^^^^^^^^ 16> ^^ 17> ^^^^ -18> ^ 1 > 2 >for 3 > @@ -44,7 +43,6 @@ sourceFile:ES5For-of3.ts 15> ['a', 'b', 'c'] 16> 17> ['a', 'b', 'c'] -18> ) 1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) 2 >Emitted(1, 4) Source(1, 4) + SourceIndex(0) 3 >Emitted(1, 5) Source(1, 5) + SourceIndex(0) @@ -62,7 +60,6 @@ sourceFile:ES5For-of3.ts 15>Emitted(1, 54) Source(1, 30) + SourceIndex(0) 16>Emitted(1, 56) Source(1, 15) + SourceIndex(0) 17>Emitted(1, 60) Source(1, 30) + SourceIndex(0) -18>Emitted(1, 61) Source(1, 31) + SourceIndex(0) --- >>> var v = _a[_i]; 1 >^^^^ diff --git a/tests/baselines/reference/ES5For-of8.js.map b/tests/baselines/reference/ES5For-of8.js.map index 3a1497eadcd..575c8f47680 100644 --- a/tests/baselines/reference/ES5For-of8.js.map +++ b/tests/baselines/reference/ES5For-of8.js.map @@ -1,2 +1,2 @@ //// [ES5For-of8.js.map] -{"version":3,"file":"ES5For-of8.js","sourceRoot":"","sources":["ES5For-of8.ts"],"names":[],"mappings":"AAAA;IACI,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACpB,CAAC;AACD,GAAG,CAAC,CAAY,UAAe,EAAf,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAf,cAAe,EAAf,IAAe,CAAC;IAA3B,GAAG,EAAE,CAAC,CAAC,SAAA;IACR,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;CACnB"} \ No newline at end of file +{"version":3,"file":"ES5For-of8.js","sourceRoot":"","sources":["ES5For-of8.ts"],"names":[],"mappings":"AAAA,SAAS,GAAG;IACR,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACpB,CAAC;AACD,GAAG,CAAC,CAAY,UAAe,EAAf,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAf,cAAe,EAAf,IAAe;IAA1B,GAAG,EAAE,CAAC,CAAC,SAAA;IACR,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;CACnB"} \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of8.sourcemap.txt b/tests/baselines/reference/ES5For-of8.sourcemap.txt index dbfce707ca6..5ba96a867dd 100644 --- a/tests/baselines/reference/ES5For-of8.sourcemap.txt +++ b/tests/baselines/reference/ES5For-of8.sourcemap.txt @@ -10,9 +10,15 @@ sourceFile:ES5For-of8.ts ------------------------------------------------------------------- >>>function foo() { 1 > -2 >^^^^^^^^^^^^^^^^^^^^^-> +2 >^^^^^^^^^ +3 > ^^^ +4 > ^^^^^^^^^-> 1 > +2 >function +3 > foo 1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 10) Source(1, 10) + SourceIndex(0) +3 >Emitted(1, 13) Source(1, 13) + SourceIndex(0) --- >>> return { x: 0 }; 1->^^^^ @@ -24,7 +30,7 @@ sourceFile:ES5For-of8.ts 7 > ^ 8 > ^^ 9 > ^ -1->function foo() { +1->() { > 2 > return 3 > @@ -72,7 +78,6 @@ sourceFile:ES5For-of8.ts 15> ^^^^^^^^^^^^^^ 16> ^^ 17> ^^^^ -18> ^ 1-> > 2 >for @@ -91,7 +96,6 @@ sourceFile:ES5For-of8.ts 15> ['a', 'b', 'c'] 16> 17> ['a', 'b', 'c'] -18> ) 1->Emitted(4, 1) Source(4, 1) + SourceIndex(0) 2 >Emitted(4, 4) Source(4, 4) + SourceIndex(0) 3 >Emitted(4, 5) Source(4, 5) + SourceIndex(0) @@ -109,7 +113,6 @@ sourceFile:ES5For-of8.ts 15>Emitted(4, 54) Source(4, 32) + SourceIndex(0) 16>Emitted(4, 56) Source(4, 17) + SourceIndex(0) 17>Emitted(4, 60) Source(4, 32) + SourceIndex(0) -18>Emitted(4, 61) Source(4, 33) + SourceIndex(0) --- >>> foo().x = _a[_i]; 1 >^^^^ diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js.map b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js.map index 9ec6d18cc72..875fe1622ba 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js.map +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js.map @@ -1,2 +1,2 @@ //// [computedPropertyNamesSourceMap1_ES6.js.map] -{"version":3,"file":"computedPropertyNamesSourceMap1_ES6.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap1_ES6.ts"],"names":[],"mappings":"AAAA;IACI,CAAC,OAAO,CAAC;QACL,QAAQ,CAAC;IACb,CAAC;AACL,CAAC;AAAA"} \ No newline at end of file +{"version":3,"file":"computedPropertyNamesSourceMap1_ES6.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap1_ES6.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC;IACH,CAAC,OAAO,CAAC;QACL,QAAQ,CAAC;IACb,CAAC;CACJ"} \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt index b589b7ad8ee..afcafcb91a3 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt @@ -10,9 +10,15 @@ sourceFile:computedPropertyNamesSourceMap1_ES6.ts ------------------------------------------------------------------- >>>class C { 1 > -2 >^^^^^^^^^^^^^^^^^^-> +2 >^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^-> 1 > +2 >class +3 > C 1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) +2 >Emitted(1, 7) Source(1, 7) + SourceIndex(0) +3 >Emitted(1, 8) Source(1, 8) + SourceIndex(0) --- >>> ["hello"]() { 1->^^^^ @@ -20,7 +26,7 @@ sourceFile:computedPropertyNamesSourceMap1_ES6.ts 3 > ^^^^^^^ 4 > ^ 5 > ^^^^^-> -1->class C { +1-> { > 2 > [ 3 > "hello" @@ -52,17 +58,10 @@ sourceFile:computedPropertyNamesSourceMap1_ES6.ts 2 >Emitted(4, 6) Source(4, 6) + SourceIndex(0) --- >>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 >^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > - > -2 >} -1 >Emitted(5, 1) Source(5, 1) + SourceIndex(0) -2 >Emitted(5, 2) Source(5, 2) + SourceIndex(0) + >} +1 >Emitted(5, 2) Source(5, 2) + SourceIndex(0) --- ->>>//# sourceMappingURL=computedPropertyNamesSourceMap1_ES6.js.map1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -1->Emitted(6, 1) Source(5, 2) + SourceIndex(0) ---- \ No newline at end of file +>>>//# sourceMappingURL=computedPropertyNamesSourceMap1_ES6.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es6-sourcemap-amd.js.map b/tests/baselines/reference/es6-sourcemap-amd.js.map index 5c62572f0a6..ef4319fadf6 100644 --- a/tests/baselines/reference/es6-sourcemap-amd.js.map +++ b/tests/baselines/reference/es6-sourcemap-amd.js.map @@ -1,2 +1,2 @@ //// [es6-sourcemap-amd.js.map] -{"version":3,"file":"es6-sourcemap-amd.js","sourceRoot":"","sources":["es6-sourcemap-amd.ts"],"names":[],"mappings":"AACA;IAEI;IAGA,CAAC;IAEM,CAAC;QAEJ,MAAM,CAAC,EAAE,CAAC;IACd,CAAC;AACL,CAAC;AAAA"} \ No newline at end of file +{"version":3,"file":"es6-sourcemap-amd.js","sourceRoot":"","sources":["es6-sourcemap-amd.ts"],"names":[],"mappings":"AACA,MAAM,CAAC;IAEH;IAGA,CAAC;IAEM,CAAC;QAEJ,MAAM,CAAC,EAAE,CAAC;IACd,CAAC;CACJ"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt b/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt index db329263ffa..b99b41b4e97 100644 --- a/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt +++ b/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt @@ -10,15 +10,21 @@ sourceFile:es6-sourcemap-amd.ts ------------------------------------------------------------------- >>>class A { 1 > -2 >^^^^^^^^^^^^^^^^^^^^-> +2 >^^^^^^ +3 > ^ +4 > ^^^^^^^^^^^^^-> 1 > > +2 >class +3 > A 1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) +2 >Emitted(1, 7) Source(2, 7) + SourceIndex(0) +3 >Emitted(1, 8) Source(2, 8) + SourceIndex(0) --- >>> constructor() { 1->^^^^ 2 > ^^-> -1->class A +1-> >{ > 1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) @@ -75,17 +81,10 @@ sourceFile:es6-sourcemap-amd.ts 2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) --- >>>} -1 > -2 >^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 >^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > - > -2 >} -1 >Emitted(7, 1) Source(13, 1) + SourceIndex(0) -2 >Emitted(7, 2) Source(13, 2) + SourceIndex(0) + >} +1 >Emitted(7, 2) Source(13, 2) + SourceIndex(0) --- ->>>//# sourceMappingURL=es6-sourcemap-amd.js.map1-> -2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> -1->Emitted(8, 1) Source(13, 2) + SourceIndex(0) ---- \ No newline at end of file +>>>//# sourceMappingURL=es6-sourcemap-amd.js.map \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesSourceMap.js.map b/tests/baselines/reference/isolatedModulesSourceMap.js.map index a6778476dda..6c99c273797 100644 --- a/tests/baselines/reference/isolatedModulesSourceMap.js.map +++ b/tests/baselines/reference/isolatedModulesSourceMap.js.map @@ -1,2 +1,2 @@ //// [file1.js.map] -{"version":3,"file":"file1.js","sourceRoot":"","sources":["file1.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"file1.js","sourceRoot":"","sources":["file1.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/isolatedModulesSourceMap.sourcemap.txt b/tests/baselines/reference/isolatedModulesSourceMap.sourcemap.txt index 57f604125d3..a9b2d98d967 100644 --- a/tests/baselines/reference/isolatedModulesSourceMap.sourcemap.txt +++ b/tests/baselines/reference/isolatedModulesSourceMap.sourcemap.txt @@ -10,27 +10,30 @@ sourceFile:file1.ts ------------------------------------------------------------------- >>>export var x = 1; 1 > -2 >^^^^^^^ -3 > ^^^^ -4 > ^ -5 > ^^^ -6 > ^ -7 > ^ -8 > ^^^^^^^^^^^^^^^-> +2 >^^^^^^ +3 > ^ +4 > ^^^^ +5 > ^ +6 > ^^^ +7 > ^ +8 > ^ +9 > ^^^^^^^^^^^^^^^-> 1 > > -2 >export -3 > var -4 > x -5 > = -6 > 1 -7 > ; +2 >export +3 > +4 > var +5 > x +6 > = +7 > 1 +8 > ; 1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 8) Source(2, 8) + SourceIndex(0) -3 >Emitted(1, 12) Source(2, 12) + SourceIndex(0) -4 >Emitted(1, 13) Source(2, 13) + SourceIndex(0) -5 >Emitted(1, 16) Source(2, 16) + SourceIndex(0) -6 >Emitted(1, 17) Source(2, 17) + SourceIndex(0) -7 >Emitted(1, 18) Source(2, 18) + SourceIndex(0) +2 >Emitted(1, 7) Source(2, 7) + SourceIndex(0) +3 >Emitted(1, 8) Source(2, 8) + SourceIndex(0) +4 >Emitted(1, 12) Source(2, 12) + SourceIndex(0) +5 >Emitted(1, 13) Source(2, 13) + SourceIndex(0) +6 >Emitted(1, 16) Source(2, 16) + SourceIndex(0) +7 >Emitted(1, 17) Source(2, 17) + SourceIndex(0) +8 >Emitted(1, 18) Source(2, 18) + SourceIndex(0) --- >>>//# sourceMappingURL=file1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/recursiveClassReferenceTest.js.map b/tests/baselines/reference/recursiveClassReferenceTest.js.map index 40f720effce..7e0b27b82b4 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.js.map +++ b/tests/baselines/reference/recursiveClassReferenceTest.js.map @@ -1,2 +1,2 @@ //// [recursiveClassReferenceTest.js.map] -{"version":3,"file":"recursiveClassReferenceTest.js","sourceRoot":"","sources":["recursiveClassReferenceTest.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,0EAA0E;;;;;;AA8B1E,IAAO,MAAM,CAUZ;AAVD,WAAO,MAAM;IAAC,IAAA,OAAO,CAUpB;IAVa,WAAA,OAAO;QAAC,IAAA,KAAK,CAU1B;QAVqB,WAAA,OAAK;YAAC,IAAA,IAAI,CAU/B;YAV2B,WAAA,IAAI,EAAC,CAAC;gBACjC;oBAAA;oBAQA,CAAC;oBANO,+BAAK,GAAZ,cAAiB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;oBAExB,6BAAG,GAAV,UAAW,KAA6B;wBAEvC,MAAM,CAAC,IAAI,CAAC;oBACb,CAAC;oBACF,sBAAC;gBAAD,CAAC,AARD,IAQC;gBARY,oBAAe,kBAQ3B,CAAA;YACF,CAAC,EAV2B,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAU/B;QAAD,CAAC,EAVqB,KAAK,GAAL,aAAK,KAAL,aAAK,QAU1B;IAAD,CAAC,EAVa,OAAO,GAAP,cAAO,KAAP,cAAO,QAUpB;AAAD,CAAC,EAVM,MAAM,KAAN,MAAM,QAUZ;AAED,IAAO,MAAM,CAoBZ;AApBD,WAAO,MAAM;IAAC,IAAA,KAAK,CAoBlB;IApBa,WAAA,KAAK;QAAC,IAAA,OAAO,CAoB1B;QApBmB,WAAA,OAAO,EAAC,CAAC;YAC5B;gBAKC,oBAAoB,SAAkC;oBAAlC,cAAS,GAAT,SAAS,CAAyB;oBAD9C,YAAO,GAAO,IAAI,CAAC;oBAEvB,aAAa;oBACb,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,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M,CAAC,IAAI,KAAK,KAAK,CAAC;oBACvB,CAAC;oBAEM,uBAAO,GAAd,cAA0B,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;oBACzC,YAAC;gBAAD,CAAC,AAXD,IAWC;gBAXY,eAAK,QAWjB,CAAA;gBAED;oBAA0B,wBAAY;oBAAtC;wBAA0B,8BAAY;oBAQtC,CAAC;oBANA,aAAa;oBACN,8BAAe,GAAtB;wBACC,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;oBACxB,CAAC;oBAGF,WAAC;gBAAD,CAAC,AARD,CAA0B,YAAY,GAQrC;gBARY,cAAI,OAQhB,CAAA;YACF,CAAC,EAxB6B,SAAS,GAAT,mBAAS,KAAT,mBAAS,QAwBtC;QAAD,CAAC,EAxBmB,SAAS,GAAT,eAAS,KAAT,eAAS,QAwB5B;IAAD,CAAC,EAxBa,KAAK,GAAL,YAAK,KAAL,YAAK,QAwBlB;AAAD,CAAC,EAxBM,MAAM,KAAN,MAAM,QAwBZ"} \ No newline at end of file diff --git a/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt b/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt index 25dc6a1900d..7e9da7dddf3 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt +++ b/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt @@ -198,24 +198,18 @@ sourceFile:recursiveClassReferenceTest.ts 1->^^^^^^^^^^^^ 2 > ^^^^^^^^^^^ 3 > ^^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^^^^^^^^^^^^-> +4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> 2 > 3 > Find -4 > -5 > { 1->Emitted(15, 13) Source(32, 29) + SourceIndex(0) 2 >Emitted(15, 24) Source(32, 29) + SourceIndex(0) 3 >Emitted(15, 28) Source(32, 33) + SourceIndex(0) -4 >Emitted(15, 30) Source(32, 34) + SourceIndex(0) -5 >Emitted(15, 31) Source(32, 35) + SourceIndex(0) --- >>> var StartFindAction = (function () { 1->^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> +1-> { > 1->Emitted(16, 17) Source(33, 2) + SourceIndex(0) --- @@ -663,24 +657,18 @@ sourceFile:recursiveClassReferenceTest.ts 1->^^^^^^^^ 2 > ^^^^^^^^^^^ 3 > ^^^^^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^^^^-> +4 > ^^^^^^^^^^^^^^^^^^-> 1-> 2 > 3 > Widgets -4 > -5 > { 1->Emitted(35, 9) Source(44, 21) + SourceIndex(0) 2 >Emitted(35, 20) Source(44, 21) + SourceIndex(0) 3 >Emitted(35, 27) Source(44, 28) + SourceIndex(0) -4 >Emitted(35, 29) Source(44, 29) + SourceIndex(0) -5 >Emitted(35, 30) Source(44, 30) + SourceIndex(0) --- >>> var FindWidget = (function () { 1->^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> +1-> { > 1->Emitted(36, 13) Source(45, 2) + SourceIndex(0) --- @@ -1443,24 +1431,18 @@ sourceFile:recursiveClassReferenceTest.ts 1->^^^^^^^^^^^^ 2 > ^^^^^^^^^^^ 3 > ^^^^^^^^^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^-> +4 > ^^^^^^^^^^^-> 1-> 2 > 3 > PlainText -4 > -5 > { 1->Emitted(70, 13) Source(76, 31) + SourceIndex(0) 2 >Emitted(70, 24) Source(76, 31) + SourceIndex(0) 3 >Emitted(70, 33) Source(76, 40) + SourceIndex(0) -4 >Emitted(70, 35) Source(76, 41) + SourceIndex(0) -5 >Emitted(70, 36) Source(76, 42) + SourceIndex(0) --- >>> var State = (function () { 1->^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> +1-> { > > 1->Emitted(71, 17) Source(78, 2) + SourceIndex(0) From 53d3e92351303b6c82c7291db59fbb3b38d3d923 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 19 Apr 2016 17:45:22 -0700 Subject: [PATCH 5/5] Fixes various source map emit issues --- src/compiler/printer.ts | 79 ++++++++++++++++--- src/compiler/transformers/ts.ts | 15 +++- src/compiler/types.ts | 24 ++++-- tests/baselines/reference/ES5For-of8.js.map | 2 +- .../reference/ES5For-of8.sourcemap.txt | 10 +-- ...computedPropertyNamesSourceMap1_ES6.js.map | 2 +- ...dPropertyNamesSourceMap1_ES6.sourcemap.txt | 10 +-- .../reference/es6-sourcemap-amd.js.map | 2 +- .../reference/es6-sourcemap-amd.sourcemap.txt | 10 +-- .../recursiveClassReferenceTest.js.map | 2 +- .../recursiveClassReferenceTest.sourcemap.txt | 30 +++++-- .../sourceMap-FileWithComments.js.map | 2 +- .../sourceMap-FileWithComments.sourcemap.txt | 5 +- .../sourceMapValidationClasses.js.map | 2 +- .../sourceMapValidationClasses.sourcemap.txt | 50 ++++++------ 15 files changed, 155 insertions(+), 90 deletions(-) diff --git a/src/compiler/printer.ts b/src/compiler/printer.ts index d39955e6968..2f80d2ffceb 100644 --- a/src/compiler/printer.ts +++ b/src/compiler/printer.ts @@ -257,6 +257,26 @@ const _super = (function (geti, seti) { emitNodeWithNotificationOption(node, emitWithoutNotificationOption); } + /** + * Emits a node with specialized emit flags. + */ + // 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. + function emitSpecialized(node: Node, flags: NodeEmitFlags) { + if (node) { + const flagsToAdd = flags & ~getNodeEmitFlags(node); + if (flagsToAdd) { + setNodeEmitFlags(node, flagsToAdd); + emit(node); + setNodeEmitFlags(node, getNodeEmitFlags(node) & ~flagsToAdd); + return; + } + + emit(node); + } + } + /** * Emits a node without calling onEmitNode. * NOTE: Do not call this method directly. @@ -299,9 +319,9 @@ const _super = (function (geti, seti) { const leadingComments = getLeadingComments(node, shouldSkipLeadingCommentsForNode); const trailingComments = getTrailingComments(node, shouldSkipTrailingCommentsForNode); emitLeadingComments(node, leadingComments); - emitStart(node, shouldSkipSourceMapForNode, shouldSkipSourceMapForChildren); + emitStart(node, shouldSkipLeadingSourceMapForNode, shouldSkipSourceMapForChildren); emitWorker(node); - emitEnd(node, shouldSkipSourceMapForNode, shouldSkipSourceMapForChildren); + emitEnd(node, shouldSkipTrailingSourceMapForNode, shouldSkipSourceMapForChildren); emitTrailingComments(node, trailingComments); } } @@ -333,16 +353,30 @@ const _super = (function (geti, seti) { } /** - * Determines whether to skip source map emit for a node. + * Determines whether to skip source map emit for the start position of a node. * * We do not emit source maps for NotEmittedStatement nodes or any node that - * has NodeEmitFlags.NoSourceMap. + * has NodeEmitFlags.NoLeadingSourceMap. * * @param node A Node. */ - function shouldSkipSourceMapForNode(node: Node) { + function shouldSkipLeadingSourceMapForNode(node: Node) { return isNotEmittedStatement(node) - || (getNodeEmitFlags(node) & NodeEmitFlags.NoSourceMap) !== 0; + || (getNodeEmitFlags(node) & NodeEmitFlags.NoLeadingSourceMap) !== 0; + } + + + /** + * Determines whether to skip source map emit for the end position of a node. + * + * We do not emit source maps for NotEmittedStatement nodes or any node that + * has NodeEmitFlags.NoTrailingSourceMap. + * + * @param node A Node. + */ + function shouldSkipTrailingSourceMapForNode(node: Node) { + return isNotEmittedStatement(node) + || (getNodeEmitFlags(node) & NodeEmitFlags.NoTrailingSourceMap) !== 0; } /** @@ -1448,7 +1482,7 @@ const _super = (function (geti, seti) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); write(node.asteriskToken ? "function* " : "function "); - emit(node.name); + emitSpecialized(node.name, NodeEmitFlags.NoSourceMap); emitSignatureAndBody(node, emitSignatureHead); } @@ -1530,7 +1564,16 @@ const _super = (function (geti, seti) { } function emitBlockFunctionBodyAndEndLexicalEnvironment(parentNode: Node, body: Block) { - write(" {"); + // 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. + if (getNodeEmitFlags(body) & NodeEmitFlags.SourceMapEmitOpenBraceAsToken) { + write(" "); + writeToken(SyntaxKind.OpenBraceToken, body.pos); + } + else { + write(" {"); + } const startingLine = writer.getLine(); increaseIndent(); @@ -1564,7 +1607,7 @@ const _super = (function (geti, seti) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); write("class"); - emitWithPrefix(" ", node.name); + emitSpecializedWithPrefix(" ", node.name, NodeEmitFlags.NoSourceMap); const indentedFlag = getNodeEmitFlags(node) & NodeEmitFlags.Indented; if (indentedFlag) { @@ -1663,9 +1706,9 @@ const _super = (function (geti, seti) { } function emitCaseBlock(node: CaseBlock) { - write("{"); + writeToken(SyntaxKind.OpenBraceToken, node.pos); emitList(node, node.clauses, ListFormat.CaseBlockClauses); - write("}"); + writeToken(SyntaxKind.CloseBraceToken, node.clauses.end); } function emitImportEqualsDeclaration(node: ImportEqualsDeclaration) { @@ -2106,6 +2149,16 @@ const _super = (function (geti, seti) { emitNodeWithPrefix(prefix, node, emit); } + // 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. + function emitSpecializedWithPrefix(prefix: string, node: Node, flags: NodeEmitFlags) { + if (node) { + write(prefix); + emitSpecialized(node, flags); + } + } + function emitExpressionWithPrefix(prefix: string, node: Node) { emitNodeWithPrefix(prefix, node, emitExpression); } @@ -2352,9 +2405,9 @@ const _super = (function (geti, seti) { function writeTokenNode(node: Node) { if (node) { - emitStart(node, shouldSkipSourceMapForNode, shouldSkipSourceMapForChildren); + emitStart(node, shouldSkipLeadingSourceMapForNode, shouldSkipSourceMapForChildren); writeTokenText(node.kind); - emitEnd(node, shouldSkipSourceMapForNode, shouldSkipSourceMapForChildren); + emitEnd(node, shouldSkipTrailingSourceMapForNode, shouldSkipSourceMapForChildren); } } diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 80f07a4782b..913d0ed8436 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -465,7 +465,9 @@ namespace ts { // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - addInitializedPropertyStatements(statements, node, staticProperties, name); + if (staticProperties.length) { + addInitializedPropertyStatements(statements, node, staticProperties, getLocalName(node, /*noSourceMaps*/ true)); + } // Write any decorators of the node. addClassElementDecorationStatements(statements, node, /*isStatic*/ false); @@ -2541,7 +2543,7 @@ namespace ts { currentNamespaceContainerName = savedCurrentNamespaceContainerName; currentNamespace = savedCurrentNamespace; - return createBlock( + const block = createBlock( createNodeArray( statements, /*location*/ statementsLocation @@ -2549,6 +2551,15 @@ namespace ts { /*location*/ blockLocation, /*multiLine*/ true ); + + // 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. + if (body.kind === SyntaxKind.ModuleBlock) { + setNodeEmitFlags(block, NodeEmitFlags.SourceMapEmitOpenBraceAsToken); + } + + return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration: ModuleDeclaration): ModuleDeclaration { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index bbbe92df036..8852b49379c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2873,15 +2873,23 @@ namespace ts { AdviseOnEmitNode = 1 << 7, // The printer should invoke the onEmitNode callback when printing this node. NoSubstitution = 1 << 8, // Disables further substitution of an expression. CapturesThis = 1 << 9, // The function captures a lexical `this` - NoSourceMap = 1 << 10, // Do not emit a source map location for this node. - NoNestedSourceMaps = 1 << 11, // Do not emit source map locations for children of this node. - NoTokenSourceMaps = 1 << 12, // Do not emit source map locations for tokens of this node. - NoLeadingComments = 1 << 13, // Do not emit leading comments for this node. - NoTrailingComments = 1 << 14, // Do not emit trailing comments for this node. + NoLeadingSourceMap = 1 << 10, // Do not emit a leading source map location for this node. + NoTrailingSourceMap = 1 << 11, // Do not emit a trailing source map location for this node. + NoSourceMap = NoLeadingSourceMap | NoTrailingSourceMap, // Do not emit a source map location for this node. + NoNestedSourceMaps = 1 << 12, // Do not emit source map locations for children of this node. + NoTokenSourceMaps = 1 << 13, // Do not emit source map locations for tokens of this node. + NoLeadingComments = 1 << 14, // Do not emit leading comments for this node. + NoTrailingComments = 1 << 15, // Do not emit trailing comments for this node. NoComments = NoLeadingComments | NoTrailingComments, // Do not emit comments for this node. - ExportName = 1 << 15, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal). - LocalName = 1 << 16, // Ensure an export prefix is not added for an identifier that points to an exported declaration. - Indented = 1 << 17, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter). + ExportName = 1 << 16, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal). + LocalName = 1 << 17, // Ensure an export prefix is not added for an identifier that points to an exported declaration. + Indented = 1 << 18, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter). + + // SourceMap Specialization. + // 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. + SourceMapEmitOpenBraceAsToken = 1 << 19, } /** Additional context provided to `visitEachChild` */ diff --git a/tests/baselines/reference/ES5For-of8.js.map b/tests/baselines/reference/ES5For-of8.js.map index 575c8f47680..1f6cf096412 100644 --- a/tests/baselines/reference/ES5For-of8.js.map +++ b/tests/baselines/reference/ES5For-of8.js.map @@ -1,2 +1,2 @@ //// [ES5For-of8.js.map] -{"version":3,"file":"ES5For-of8.js","sourceRoot":"","sources":["ES5For-of8.ts"],"names":[],"mappings":"AAAA,SAAS,GAAG;IACR,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACpB,CAAC;AACD,GAAG,CAAC,CAAY,UAAe,EAAf,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAf,cAAe,EAAf,IAAe;IAA1B,GAAG,EAAE,CAAC,CAAC,SAAA;IACR,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;CACnB"} \ No newline at end of file +{"version":3,"file":"ES5For-of8.js","sourceRoot":"","sources":["ES5For-of8.ts"],"names":[],"mappings":"AAAA;IACI,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACpB,CAAC;AACD,GAAG,CAAC,CAAY,UAAe,EAAf,MAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAf,cAAe,EAAf,IAAe;IAA1B,GAAG,EAAE,CAAC,CAAC,SAAA;IACR,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;CACnB"} \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of8.sourcemap.txt b/tests/baselines/reference/ES5For-of8.sourcemap.txt index 5ba96a867dd..1a58d5f107b 100644 --- a/tests/baselines/reference/ES5For-of8.sourcemap.txt +++ b/tests/baselines/reference/ES5For-of8.sourcemap.txt @@ -10,15 +10,9 @@ sourceFile:ES5For-of8.ts ------------------------------------------------------------------- >>>function foo() { 1 > -2 >^^^^^^^^^ -3 > ^^^ -4 > ^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^^^^^-> 1 > -2 >function -3 > foo 1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 10) Source(1, 10) + SourceIndex(0) -3 >Emitted(1, 13) Source(1, 13) + SourceIndex(0) --- >>> return { x: 0 }; 1->^^^^ @@ -30,7 +24,7 @@ sourceFile:ES5For-of8.ts 7 > ^ 8 > ^^ 9 > ^ -1->() { +1->function foo() { > 2 > return 3 > diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js.map b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js.map index 875fe1622ba..8f7eed4fa9b 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js.map +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js.map @@ -1,2 +1,2 @@ //// [computedPropertyNamesSourceMap1_ES6.js.map] -{"version":3,"file":"computedPropertyNamesSourceMap1_ES6.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap1_ES6.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC;IACH,CAAC,OAAO,CAAC;QACL,QAAQ,CAAC;IACb,CAAC;CACJ"} \ No newline at end of file +{"version":3,"file":"computedPropertyNamesSourceMap1_ES6.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap1_ES6.ts"],"names":[],"mappings":"AAAA;IACI,CAAC,OAAO,CAAC;QACL,QAAQ,CAAC;IACb,CAAC;CACJ"} \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt index afcafcb91a3..56fa39ceaac 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt @@ -10,15 +10,9 @@ sourceFile:computedPropertyNamesSourceMap1_ES6.ts ------------------------------------------------------------------- >>>class C { 1 > -2 >^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^^-> 1 > -2 >class -3 > C 1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) -2 >Emitted(1, 7) Source(1, 7) + SourceIndex(0) -3 >Emitted(1, 8) Source(1, 8) + SourceIndex(0) --- >>> ["hello"]() { 1->^^^^ @@ -26,7 +20,7 @@ sourceFile:computedPropertyNamesSourceMap1_ES6.ts 3 > ^^^^^^^ 4 > ^ 5 > ^^^^^-> -1-> { +1->class C { > 2 > [ 3 > "hello" diff --git a/tests/baselines/reference/es6-sourcemap-amd.js.map b/tests/baselines/reference/es6-sourcemap-amd.js.map index ef4319fadf6..d5229e3a28c 100644 --- a/tests/baselines/reference/es6-sourcemap-amd.js.map +++ b/tests/baselines/reference/es6-sourcemap-amd.js.map @@ -1,2 +1,2 @@ //// [es6-sourcemap-amd.js.map] -{"version":3,"file":"es6-sourcemap-amd.js","sourceRoot":"","sources":["es6-sourcemap-amd.ts"],"names":[],"mappings":"AACA,MAAM,CAAC;IAEH;IAGA,CAAC;IAEM,CAAC;QAEJ,MAAM,CAAC,EAAE,CAAC;IACd,CAAC;CACJ"} \ No newline at end of file +{"version":3,"file":"es6-sourcemap-amd.js","sourceRoot":"","sources":["es6-sourcemap-amd.ts"],"names":[],"mappings":"AACA;IAEI;IAGA,CAAC;IAEM,CAAC;QAEJ,MAAM,CAAC,EAAE,CAAC;IACd,CAAC;CACJ"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt b/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt index b99b41b4e97..a01507e964b 100644 --- a/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt +++ b/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt @@ -10,21 +10,15 @@ sourceFile:es6-sourcemap-amd.ts ------------------------------------------------------------------- >>>class A { 1 > -2 >^^^^^^ -3 > ^ -4 > ^^^^^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^^^^-> 1 > > -2 >class -3 > A 1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) -2 >Emitted(1, 7) Source(2, 7) + SourceIndex(0) -3 >Emitted(1, 8) Source(2, 8) + SourceIndex(0) --- >>> constructor() { 1->^^^^ 2 > ^^-> -1-> +1->class A >{ > 1->Emitted(2, 5) Source(4, 5) + SourceIndex(0) diff --git a/tests/baselines/reference/recursiveClassReferenceTest.js.map b/tests/baselines/reference/recursiveClassReferenceTest.js.map index 7e0b27b82b4..40f720effce 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.js.map +++ b/tests/baselines/reference/recursiveClassReferenceTest.js.map @@ -1,2 +1,2 @@ //// [recursiveClassReferenceTest.js.map] -{"version":3,"file":"recursiveClassReferenceTest.js","sourceRoot":"","sources":["recursiveClassReferenceTest.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,0E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C,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;oBACxB,CAAC;oBAGF,WAAC;gBAAD,CAAC,AARD,CAA0B,YAAY,GAQrC;gBARY,cAAI,OAQhB,CAAA;YACF,CAAC,EAxB6B,SAAS,GAAT,mBAAS,KAAT,mBAAS,QAwBtC;QAAD,CAAC,EAxBmB,SAAS,GAAT,eAAS,KAAT,eAAS,QAwB5B;IAAD,CAAC,EAxBa,KAAK,GAAL,YAAK,KAAL,YAAK,QAwBlB;AAAD,CAAC,EAxBM,MAAM,KAAN,MAAM,QAwBZ"} \ No newline at end of file diff --git a/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt b/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt index 7e9da7dddf3..25dc6a1900d 100644 --- a/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt +++ b/tests/baselines/reference/recursiveClassReferenceTest.sourcemap.txt @@ -198,18 +198,24 @@ sourceFile:recursiveClassReferenceTest.ts 1->^^^^^^^^^^^^ 2 > ^^^^^^^^^^^ 3 > ^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +4 > ^^ +5 > ^ +6 > ^^^^^^^^^^^^^^^^^^^^^^^-> 1-> 2 > 3 > Find +4 > +5 > { 1->Emitted(15, 13) Source(32, 29) + SourceIndex(0) 2 >Emitted(15, 24) Source(32, 29) + SourceIndex(0) 3 >Emitted(15, 28) Source(32, 33) + SourceIndex(0) +4 >Emitted(15, 30) Source(32, 34) + SourceIndex(0) +5 >Emitted(15, 31) Source(32, 35) + SourceIndex(0) --- >>> var StartFindAction = (function () { 1->^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> { +1-> > 1->Emitted(16, 17) Source(33, 2) + SourceIndex(0) --- @@ -657,18 +663,24 @@ sourceFile:recursiveClassReferenceTest.ts 1->^^^^^^^^ 2 > ^^^^^^^^^^^ 3 > ^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^-> +4 > ^^ +5 > ^ +6 > ^^^^^^^^^^^^^^^-> 1-> 2 > 3 > Widgets +4 > +5 > { 1->Emitted(35, 9) Source(44, 21) + SourceIndex(0) 2 >Emitted(35, 20) Source(44, 21) + SourceIndex(0) 3 >Emitted(35, 27) Source(44, 28) + SourceIndex(0) +4 >Emitted(35, 29) Source(44, 29) + SourceIndex(0) +5 >Emitted(35, 30) Source(44, 30) + SourceIndex(0) --- >>> var FindWidget = (function () { 1->^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> { +1-> > 1->Emitted(36, 13) Source(45, 2) + SourceIndex(0) --- @@ -1431,18 +1443,24 @@ sourceFile:recursiveClassReferenceTest.ts 1->^^^^^^^^^^^^ 2 > ^^^^^^^^^^^ 3 > ^^^^^^^^^ -4 > ^^^^^^^^^^^-> +4 > ^^ +5 > ^ +6 > ^^^^^^^^-> 1-> 2 > 3 > PlainText +4 > +5 > { 1->Emitted(70, 13) Source(76, 31) + SourceIndex(0) 2 >Emitted(70, 24) Source(76, 31) + SourceIndex(0) 3 >Emitted(70, 33) Source(76, 40) + SourceIndex(0) +4 >Emitted(70, 35) Source(76, 41) + SourceIndex(0) +5 >Emitted(70, 36) Source(76, 42) + SourceIndex(0) --- >>> var State = (function () { 1->^^^^^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1-> { +1-> > > 1->Emitted(71, 17) Source(78, 2) + SourceIndex(0) diff --git a/tests/baselines/reference/sourceMap-FileWithComments.js.map b/tests/baselines/reference/sourceMap-FileWithComments.js.map index 80437501d33..0cffa405b40 100644 --- a/tests/baselines/reference/sourceMap-FileWithComments.js.map +++ b/tests/baselines/reference/sourceMap-FileWithComments.js.map @@ -1,2 +1,2 @@ //// [sourceMap-FileWithComments.js.map] -{"version":3,"file":"sourceMap-FileWithComments.js","sourceRoot":"","sources":["sourceMap-FileWithComments.ts"],"names":[],"mappings":"AAMA,SAAS;AACT,IAAO,MAAM,CAwBZ;AAxBD,WAAO,MAAM,EAAC,CAAC;IAEX,QAAQ;IACR;QACI,cAAc;QACd,eAAmB,CAAS,EAAS,CAAS;YAA3B,MAAC,GAAD,CAAC,CAAQ;YAAS,MAAC,GAAD,CAAC,CAAQ;QAAI,CAAC;QAEnD,kBAAkB;QAClB,uBAAO,GAAP,cAAY,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAItE,YAAC;IAAD,CAAC,AATD;IAOI,gBAAgB;IACT,YAAM,GAAG,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAClC;IATY,YAAK,QASjB,CAAA;IAED,+BAA+B;IAC/B,IAAI,CAAC,GAAG,EAAE,CAAC;IAEX;IACA,CAAC;IADe,UAAG,MAClB,CAAA;IAED;;MAEE;IACF,IAAI,CAAC,GAAG,EAAE,CAAC;AACf,CAAC,EAxBM,MAAM,KAAN,MAAM,QAwBZ;AAED,qBAAqB;AACrB,IAAI,CAAC,GAAW,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvC,IAAI,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMap-FileWithComments.js","sourceRoot":"","sources":["sourceMap-FileWithComments.ts"],"names":[],"mappings":"AAMA,SAAS;AACT,IAAO,MAAM,CAwBZ;AAxBD,WAAO,MAAM,EAAC,CAAC;IAEX,QAAQ;IACR;QACI,cAAc;QACd,eAAmB,CAAS,EAAS,CAAS;YAA3B,MAAC,GAAD,CAAC,CAAQ;YAAS,MAAC,GAAD,CAAC,CAAQ;QAAI,CAAC;QAEnD,kBAAkB;QAClB,uBAAO,GAAP,cAAY,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAItE,YAAC;IAAD,CAAC,AATD;IAOI,gBAAgB;IACT,YAAM,GAAG,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IARvB,YAAK,QASjB,CAAA;IAED,+BAA+B;IAC/B,IAAI,CAAC,GAAG,EAAE,CAAC;IAEX;IACA,CAAC;IADe,UAAG,MAClB,CAAA;IAED;;MAEE;IACF,IAAI,CAAC,GAAG,EAAE,CAAC;AACf,CAAC,EAxBM,MAAM,KAAN,MAAM,QAwBZ;AAED,qBAAqB;AACrB,IAAI,CAAC,GAAW,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACvC,IAAI,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt b/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt index 2abfabff566..922e8ae1b83 100644 --- a/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt +++ b/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt @@ -334,8 +334,7 @@ sourceFile:sourceMap-FileWithComments.ts 8 > , 9 > 0 10> ) -11> ; - > } +11> ; 1->Emitted(16, 5) Source(19, 16) + SourceIndex(0) 2 >Emitted(16, 17) Source(19, 22) + SourceIndex(0) 3 >Emitted(16, 20) Source(19, 25) + SourceIndex(0) @@ -346,7 +345,7 @@ sourceFile:sourceMap-FileWithComments.ts 8 >Emitted(16, 33) Source(19, 38) + SourceIndex(0) 9 >Emitted(16, 34) Source(19, 39) + SourceIndex(0) 10>Emitted(16, 35) Source(19, 40) + SourceIndex(0) -11>Emitted(16, 36) Source(20, 6) + SourceIndex(0) +11>Emitted(16, 36) Source(19, 41) + SourceIndex(0) --- >>> Shapes.Point = Point; 1 >^^^^ diff --git a/tests/baselines/reference/sourceMapValidationClasses.js.map b/tests/baselines/reference/sourceMapValidationClasses.js.map index 205d5d55b78..7492caee701 100644 --- a/tests/baselines/reference/sourceMapValidationClasses.js.map +++ b/tests/baselines/reference/sourceMapValidationClasses.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationClasses.js.map] -{"version":3,"file":"sourceMapValidationClasses.js","sourceRoot":"","sources":["sourceMapValidationClasses.ts"],"names":[],"mappings":"AAAA,IAAO,GAAG,CAmCT;AAnCD,WAAO,GAAG;IAAC,IAAA,GAAG,CAmCb;IAnCU,WAAA,GAAG;QACV,YAAY,CAAC;QAEb;YACI,iBAAmB,QAAgB;gBAAhB,aAAQ,GAAR,QAAQ,CAAQ;YACnC,CAAC;YAED,uBAAK,GAAL;gBACI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;YAC5C,CAAC;YACL,cAAC;QAAD,CAAC,AAPD,IAOC;QAGD,SAAS,GAAG,CAAC,QAAgB;YACzB,MAAM,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;QAED,IAAI,OAAO,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;QAC3C,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;QAE1B,SAAS,IAAI,CAAC,QAAgB;YAAE,kBAAiB,mBAAmB,MAAU;iBAA9C,UAA8C,EAA9C,qBAA8C,EAA9C,IAA8C;gBAA9C,sCAA8C;;YAC1E,IAAI,QAAQ,GAAc,EAAE,CAAC,CAAC,0BAA0B;YACxD,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;YACpC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC5C,QAAQ,CAAC,IAAI,CAAC,IAAI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,GAAc,EAAE,CAAC,CAAC,0BAA0B;YACxD,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;YACpC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC5C,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACjD,CAAC;YAED,MAAM,CAAC,QAAQ,CAAC;QACpB,CAAC;QAED,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QACpC,qCAAqC;QACrC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;IACL,CAAC,EAnCU,GAAG,GAAH,OAAG,KAAH,OAAG,QAmCb;AAAD,CAAC,EAnCM,GAAG,KAAH,GAAG,QAmCT"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationClasses.sourcemap.txt b/tests/baselines/reference/sourceMapValidationClasses.sourcemap.txt index 4120aa91b12..b3412736762 100644 --- a/tests/baselines/reference/sourceMapValidationClasses.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationClasses.sourcemap.txt @@ -123,20 +123,26 @@ sourceFile:sourceMapValidationClasses.ts 1->^^^^ 2 > ^^^^^^^^^^^ 3 > ^^^ -4 > ^^^^-> +4 > ^^ +5 > ^ +6 > ^-> 1-> 2 > 3 > Bar +4 > +5 > { 1->Emitted(4, 5) Source(1, 12) + SourceIndex(0) 2 >Emitted(4, 16) Source(1, 12) + SourceIndex(0) 3 >Emitted(4, 19) Source(1, 15) + SourceIndex(0) +4 >Emitted(4, 21) Source(1, 16) + SourceIndex(0) +5 >Emitted(4, 22) Source(1, 17) + SourceIndex(0) --- >>> "use strict"; 1->^^^^^^^^ 2 > ^^^^^^^^^^^^ 3 > ^ 4 > ^^^^^^^^^^^^^^^^-> -1-> { +1-> > 2 > "use strict" 3 > ; @@ -285,24 +291,18 @@ sourceFile:sourceMapValidationClasses.ts --- >>> function foo(greeting) { 1->^^^^^^^^ -2 > ^^^^^^^^^ -3 > ^^^ -4 > ^ -5 > ^^^^^^^^ -6 > ^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^^^^^^^^^^^^^-> 1-> > > > -2 > function -3 > foo -4 > ( -5 > greeting: string +2 > function foo( +3 > greeting: string 1->Emitted(15, 9) Source(14, 5) + SourceIndex(0) -2 >Emitted(15, 18) Source(14, 14) + SourceIndex(0) -3 >Emitted(15, 21) Source(14, 17) + SourceIndex(0) -4 >Emitted(15, 22) Source(14, 18) + SourceIndex(0) -5 >Emitted(15, 30) Source(14, 34) + SourceIndex(0) +2 >Emitted(15, 22) Source(14, 18) + SourceIndex(0) +3 >Emitted(15, 30) Source(14, 34) + SourceIndex(0) --- >>> return new Greeter(greeting); 1->^^^^^^^^^^^^ @@ -410,23 +410,17 @@ sourceFile:sourceMapValidationClasses.ts --- >>> function foo2(greeting) { 1 >^^^^^^^^ -2 > ^^^^^^^^^ -3 > ^^^^ -4 > ^ -5 > ^^^^^^^^ -6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^^ +3 > ^^^^^^^^ +4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > > -2 > function -3 > foo2 -4 > ( -5 > greeting: string +2 > function foo2( +3 > greeting: string 1 >Emitted(20, 9) Source(21, 5) + SourceIndex(0) -2 >Emitted(20, 18) Source(21, 14) + SourceIndex(0) -3 >Emitted(20, 22) Source(21, 18) + SourceIndex(0) -4 >Emitted(20, 23) Source(21, 19) + SourceIndex(0) -5 >Emitted(20, 31) Source(21, 35) + SourceIndex(0) +2 >Emitted(20, 23) Source(21, 19) + SourceIndex(0) +3 >Emitted(20, 31) Source(21, 35) + SourceIndex(0) --- >>> var restGreetings /* more greeting */ = []; 1->^^^^^^^^^^^^