Merge pull request #8207 from Microsoft/transforms-fixVariousSourceMaps

[Transforms] Fix for a number of source map emit issues.
This commit is contained in:
Ron Buckton 2016-04-19 18:03:15 -07:00
commit c45471597d
35 changed files with 635 additions and 326 deletions

View File

@ -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;
@ -106,7 +108,7 @@ namespace ts {
* Gets a clone of a node with a unique node ID.
*/
export function getUniqueClone<T extends Node>(node: T): T {
const clone = getSynthesizedClone(node);
const clone = getMutableClone(node);
clone.id = undefined;
getNodeId(clone);
return clone;
@ -923,34 +925,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;
@ -959,17 +935,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"),
@ -978,12 +960,63 @@ 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) {
let options: PropertyDescriptorExtendedOption;
let location: TextRange;
let emitFlags: NodeEmitFlags;
if (descriptorExtendedOptions !== undefined) {
options = getProperty(descriptorExtendedOptions, name);
if (options !== undefined) {
location = options.location;
emitFlags = options.emitFlags;
if (options.newLine !== undefined) {
preferNewLine = options.newLine;
}
}
}
const property = createPropertyAssignment(
name,
typeof value === "boolean" ? createLiteral(value) : value,
location
);
if (emitFlags !== undefined) {
Debug.assert(context !== undefined, "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"),
@ -1240,8 +1273,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

View File

@ -284,6 +284,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.
@ -323,40 +343,67 @@ 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);
emitStart(node, shouldSkipLeadingSourceMapForNode, shouldSkipSourceMapForChildren);
emitWorker(node);
emitEnd(node, shouldSkipSourceMapForNode, shouldSkipSourceMapForChildren);
emitEnd(node, shouldSkipTrailingSourceMapForNode, shouldSkipSourceMapForChildren);
emitTrailingComments(node, trailingComments);
}
}
/**
* 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 source map emit for a node.
* Determines whether to skip trailing comment emit for a node.
*
* We do not emit source maps for NotEmittedStatement nodes or any node that
* has NodeEmitFlags.NoSourceMap.
* We do not emit comments for NotEmittedStatement nodes or any node that has
* NodeEmitFlags.NoTrailingComments.
*
* @param node A Node.
*/
function shouldSkipSourceMapForNode(node: Node) {
function shouldSkipTrailingCommentsForNode(node: Node) {
return isNotEmittedStatement(node)
|| (getNodeEmitFlags(node) & NodeEmitFlags.NoSourceMap) !== 0;
|| (getNodeEmitFlags(node) & NodeEmitFlags.NoTrailingComments) !== 0;
}
/**
* 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.NoLeadingSourceMap.
*
* @param node A Node.
*/
function shouldSkipLeadingSourceMapForNode(node: Node) {
return isNotEmittedStatement(node)
|| (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;
}
/**
@ -1181,7 +1228,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);
@ -1254,12 +1301,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);
}
}
@ -1288,13 +1337,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);
@ -1328,7 +1379,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);
@ -1339,20 +1392,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);
}
@ -1368,19 +1425,19 @@ 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(";");
}
function emitReturnStatement(node: ReturnStatement) {
write("return");
writeToken(SyntaxKind.ReturnKeyword, node.pos, node, shouldSkipSourceMapForToken);
emitExpressionWithPrefix(" ", node.expression);
write(";");
}
@ -1393,9 +1450,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);
}
@ -1449,7 +1509,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);
}
@ -1531,11 +1591,20 @@ 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();
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);
@ -1552,7 +1621,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);
}
@ -1565,7 +1634,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) {
@ -1664,9 +1733,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) {
@ -1882,9 +1951,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);
}
@ -2109,6 +2181,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);
}
@ -2333,14 +2415,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);
@ -2349,9 +2437,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);
}
}

View File

@ -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.

View File

@ -612,13 +612,12 @@ namespace ts {
enableSubstitutionsForBlockScopedBindings();
}
const closingBraceLocation = { pos: node.end - 1, end: node.end };
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
@ -635,14 +634,14 @@ 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(
createCall(
outer,
baseTypeNode
? [visitNode(baseTypeNode.expression, visitor, isExpression)]
extendsClauseElement
? [visitNode(extendsClauseElement.expression, visitor, isExpression)]
: []
)
);
@ -652,34 +651,34 @@ 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.
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;
setNodeEmitFlags(statement, NodeEmitFlags.NoComments | NodeEmitFlags.NoTokenSourceMaps);
statements.push(statement);
setNodeEmitFlags(statement, NodeEmitFlags.NoComments);
addRange(statements, endLexicalEnvironment());
const block = createBlock(createNodeArray(statements, /*location*/ node.members), /*location*/ undefined, /*multiLine*/ true);
setNodeEmitFlags(block, NodeEmitFlags.NoComments);
return block;
}
@ -688,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
)
);
}
@ -705,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
)
);
@ -747,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) {
@ -760,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);
@ -797,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
)
);
}
@ -988,7 +989,12 @@ namespace ts {
return;
}
const name = getSynthesizedClone(<Identifier>parameter.name);
// `declarationName` is the name of the local declaration for the parameter.
const declarationName = getUniqueClone(<Identifier>parameter.name);
setNodeEmitFlags(declarationName, NodeEmitFlags.NoSourceMap);
// `expressionName` is the name of the parameter used in expressions.
const expressionName = getSynthesizedClone(<Identifier>parameter.name);
const restIndex = node.parameters.length - 1;
const temp = createLoopVariable();
@ -998,10 +1004,11 @@ namespace ts {
/*modifiers*/ undefined,
createVariableDeclarationList([
createVariableDeclaration(
name,
declarationName,
createArrayLiteral([])
)
])
]),
/*location*/ parameter
)
);
@ -1012,22 +1019,24 @@ 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(
createAssignment(
createElementAccess(
name,
expressionName,
createSubtract(temp, createLiteral(restIndex))
),
createElementAccess(createIdentifier("arguments"), temp)
)
),
/*location*/ parameter
)
)
])
@ -1158,13 +1167,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 +1188,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
);
@ -1656,7 +1671,7 @@ namespace ts {
visitor
)
),
/*location*/ initializer
/*location*/ moveRangeEnd(initializer, -1)
)
);
}
@ -1671,8 +1686,8 @@ namespace ts {
firstDeclaration ? firstDeclaration.name : createTempVariable(/*recordTempVariable*/ undefined),
createElementAccess(rhsReference, counter)
)
]),
/*location*/ initializer
], /*location*/ moveRangePos(initializer, -1)),
/*location*/ moveRangeEnd(initializer, -1)
)
);
}
@ -1696,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)));
}
}
@ -1713,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
@ -1724,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
),
@ -2755,21 +2774,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;
}
@ -2777,7 +2828,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");
}

View File

@ -648,12 +648,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
)
);

View File

@ -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;
/**
@ -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);
@ -480,7 +482,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));
@ -898,13 +900,17 @@ namespace ts {
function transformParameterWithPropertyAssignment(node: ParameterDeclaration) {
Debug.assert(isIdentifier(node.name));
const name = getSynthesizedClone(<Identifier>node.name);
return startOnNewLine(
createStatement(
createAssignment(
createPropertyAccess(createThis(), name),
name
)
createPropertyAccess(
createThis(),
getSynthesizedClone(<Identifier>node.name),
/*location*/ node.name
),
getUniqueClone(<Identifier>node.name)
),
/*location*/ node
)
);
}
@ -994,7 +1000,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
);
@ -1772,7 +1778,7 @@ namespace ts {
function getExpressionForPropertyName(member: ClassElement | EnumMember, generateNameForComputedPropertyName: boolean): Expression {
const name = member.name;
if (isComputedPropertyName(name)) {
return generateNameForComputedPropertyName
return generateNameForComputedPropertyName
? getGeneratedNameForNode(name)
: (<ComputedPropertyName>name).expression;
}
@ -2251,7 +2257,7 @@ namespace ts {
/*modifiers*/ undefined,
[createVariableDeclaration(
getDeclarationName(node),
getDeclarationNameExpression(node)
getExportName(node)
)],
/*location*/ node
)
@ -2322,15 +2328,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);
}
@ -2347,10 +2353,10 @@ namespace ts {
return createStatement(
createAssignment(
createElementAccess(
currentNamespaceLocalName,
currentNamespaceContainerName,
createAssignment(
createElementAccess(
currentNamespaceLocalName,
currentNamespaceContainerName,
name
),
transformEnumMemberDeclarationValue(member)
@ -2413,34 +2419,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);
}
/**
@ -2464,20 +2474,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) {
@ -2491,8 +2513,8 @@ namespace ts {
createFunctionExpression(
/*asteriskToken*/ undefined,
/*name*/ undefined,
[createParameter(localName)],
transformModuleBody(node, localName)
[createParameter(parameterName)],
transformModuleBody(node, containerName)
),
[moduleArg]
),
@ -2513,26 +2535,56 @@ 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((<ModuleBlock>body).statements, namespaceElementVisitor, isStatement));
statementsLocation = (<ModuleBlock>body).statements;
blockLocation = body;
}
else {
addNode(statements, visitModuleDeclaration(<ModuleDeclaration>body));
const moduleBlock = <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);
const block = createBlock(
createNodeArray(
statements,
/*location*/ statementsLocation
),
/*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 {
if (moduleDeclaration.body.kind === SyntaxKind.ModuleDeclaration) {
const recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(<ModuleDeclaration>moduleDeclaration.body);
return recursiveInnerModule || <ModuleDeclaration>moduleDeclaration.body;
}
}
/**
@ -2637,13 +2689,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
@ -2658,12 +2719,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 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.
*/
function getLocalName(node: DeclarationStatement | ClassExpression, noSourceMaps?: boolean, allowComments?: boolean) {
return getDeclarationName(node, allowComments, !noSourceMaps, 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 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.
*/
function getExportName(node: DeclarationStatement | ClassExpression, noSourceMaps?: boolean, allowComments?: boolean) {
if (isNamespaceExport(node)) {
return getNamespaceMemberName(getDeclarationName(node), allowComments, !noSourceMaps);
}
return getDeclarationName(node, allowComments, !noSourceMaps, 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) {

View File

@ -2930,12 +2930,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.
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).
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 << 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` */

View File

@ -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"}
{"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"}

View File

@ -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 >^^^^

View File

@ -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"}
{"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"}

View File

@ -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 >^^^^

View File

@ -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"}
{"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"}

View File

@ -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 >^^^^

View File

@ -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"}
{"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"}

View File

@ -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->^^^^

View File

@ -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"}
{"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"}

View File

@ -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 >^^^^

View File

@ -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"}
{"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"}

View File

@ -72,7 +72,6 @@ sourceFile:ES5For-of8.ts
15> ^^^^^^^^^^^^^^
16> ^^
17> ^^^^
18> ^
1->
>
2 >for
@ -91,7 +90,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 +107,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 >^^^^

View File

@ -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"}
{"version":3,"file":"computedPropertyNamesSourceMap1_ES6.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap1_ES6.ts"],"names":[],"mappings":"AAAA;IACI,CAAC,OAAO,CAAC;QACL,QAAQ,CAAC;IACb,CAAC;CACJ"}

View File

@ -52,17 +52,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)
---
>>>//# sourceMappingURL=computedPropertyNamesSourceMap1_ES6.js.map

View File

@ -49,4 +49,6 @@ var Foo;
}
return Helper;
}());
// Inner should not show up in intellisense
// Outer should show up in intellisense
})(Foo || (Foo = {}));

View File

@ -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"}
{"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"}

View File

@ -75,17 +75,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)
---
>>>//# sourceMappingURL=es6-sourcemap-amd.js.map

View File

@ -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"}
{"version":3,"file":"file1.js","sourceRoot":"","sources":["file1.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC"}

View File

@ -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

View File

@ -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 = {}));

View File

@ -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"}
{"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"}

View File

@ -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 >^^^^

View File

@ -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"}
{"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"}

View File

@ -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)
---

View File

@ -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);

View File

@ -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,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"}
{"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,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"}

View File

@ -439,38 +439,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 */

View File

@ -58,6 +58,8 @@ var M;
return Bar;
}());
S.Bar = Bar;
// Emit Foo
// Foo, <Foo />;
})(S = M.S || (M.S = {}));
})(M || (M = {}));
var M;