From cd2cf7d3c6ac93a5c14ff83c75387f149bdbe1a5 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 29 Feb 2016 13:28:16 -0800 Subject: [PATCH 1/7] PR Feedback and defer makeUniqueName/getGeneratedNameForNode to printer. --- src/compiler/factory.ts | 34 +++++--- src/compiler/printer.ts | 162 +++++++++++++++++++++++++++--------- src/compiler/transformer.ts | 118 -------------------------- src/compiler/types.ts | 17 ++-- src/compiler/utilities.ts | 12 +-- 5 files changed, 161 insertions(+), 182 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 8f388a01520..eae769fd562 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -185,24 +185,38 @@ namespace ts { // Identifiers - export function createIdentifier(text: string): Identifier { - const node = createNode(SyntaxKind.Identifier); + export function createIdentifier(text: string, location?: TextRange): Identifier { + const node = createNode(SyntaxKind.Identifier, location); node.text = text; return node; } - export function createTempVariable(): Identifier { - const name = createNode(SyntaxKind.Identifier); - name.text = undefined; - name.tempKind = TempVariableKind.Auto; + export function createTempVariable(location?: TextRange): Identifier { + const name = createNode(SyntaxKind.Identifier, location); + name.autoGenerateKind = GeneratedIdentifierKind.Auto; getNodeId(name); return name; } - export function createLoopVariable(): Identifier { - const name = createNode(SyntaxKind.Identifier); - name.text = undefined; - name.tempKind = TempVariableKind.Loop; + export function createLoopVariable(location?: TextRange): Identifier { + const name = createNode(SyntaxKind.Identifier, location); + name.autoGenerateKind = GeneratedIdentifierKind.Loop; + getNodeId(name); + return name; + } + + export function createUniqueName(text: string, location?: TextRange): Identifier { + const name = createNode(SyntaxKind.Identifier, location); + name.text = text; + name.autoGenerateKind = GeneratedIdentifierKind.Unique; + getNodeId(name); + return name; + } + + export function createGeneratedNameForNode(node: Node, location?: TextRange): Identifier { + const name = createNode(SyntaxKind.Identifier, location); + name.autoGenerateKind = GeneratedIdentifierKind.Node; + name.original = node; getNodeId(name); return name; } diff --git a/src/compiler/printer.ts b/src/compiler/printer.ts index a1d284dd42b..e44e88b4612 100644 --- a/src/compiler/printer.ts +++ b/src/compiler/printer.ts @@ -121,7 +121,6 @@ const _super = (function (geti, seti) { const writer = createTextWriter(newLine); const { write, - writeTextOfNode, writeLine, increaseIndent, decreaseIndent @@ -154,11 +153,12 @@ const _super = (function (geti, seti) { let identifierSubstitution: (node: Identifier) => Identifier; let onBeforeEmitNode: (node: Node) => void; let onAfterEmitNode: (node: Node) => void; - let isUniqueName: (name: string) => boolean; - let temporaryVariables: string[] = []; + let nodeToGeneratedName: string[]; + let generatedNameSet: Map; let tempFlags: TempFlags; let currentSourceFile: SourceFile; let currentText: string; + let currentFileIdentifiers: Map; let extendsEmitted: boolean; let decorateEmitted: boolean; let paramEmitted: boolean; @@ -169,6 +169,8 @@ const _super = (function (geti, seti) { function doPrint(jsFilePath: string, sourceMapFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) { sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); + nodeToGeneratedName = []; + generatedNameSet = {}; isOwnFileEmit = !isBundledEmit; // Emit helpers from all the files @@ -213,8 +215,6 @@ const _super = (function (geti, seti) { identifierSubstitution = undefined; onBeforeEmitNode = undefined; onAfterEmitNode = undefined; - isUniqueName = undefined; - temporaryVariables = undefined; tempFlags = TempFlags.Auto; currentSourceFile = undefined; currentText = undefined; @@ -236,13 +236,13 @@ const _super = (function (geti, seti) { identifierSubstitution = context.identifierSubstitution; onBeforeEmitNode = context.onBeforeEmitNode; onAfterEmitNode = context.onAfterEmitNode; - isUniqueName = context.isUniqueName; return printSourceFile; } function printSourceFile(node: SourceFile) { currentSourceFile = node; currentText = node.text; + currentFileIdentifiers = node.identifiers; sourceMap.setSourceFile(node); comments.setSourceFile(node); emitWorker(node); @@ -659,22 +659,11 @@ const _super = (function (geti, seti) { // function emitIdentifier(node: Identifier) { - if (node.text === undefined) { - // Emit a temporary variable name for this node. - const nodeId = getOriginalNodeId(node); - const text = temporaryVariables[nodeId] || (temporaryVariables[nodeId] = makeTempVariableName(tempKindToFlags(node.tempKind))); - write(text); - } - else if (nodeIsSynthesized(node) || !node.parent) { - if (getNodeEmitFlags(node) & NodeEmitFlags.UMDDefine) { - writeLines(umdHelper); - } - else { - write(node.text); - } + if (getNodeEmitFlags(node) && NodeEmitFlags.UMDDefine) { + writeLines(umdHelper); } else { - writeTextOfNode(currentText, node); + write(getTextOfNode(node, /*includeTrivia*/ false)); } } @@ -1720,7 +1709,6 @@ const _super = (function (geti, seti) { emitExpression(node.expression); write(":"); - debugger; emitCaseOrDefaultClauseStatements(node, node.statements); } @@ -1763,14 +1751,14 @@ const _super = (function (geti, seti) { function emitPropertyAssignment(node: PropertyAssignment) { emit(node.name); write(": "); - // // This is to ensure that we emit comment in the following case: - // // For example: - // // obj = { - // // id: /*comment1*/ ()=>void - // // } - // // "comment1" is not considered to be leading comment for node.initializer - // // but rather a trailing comment on the previous node. - // emitTrailingCommentsOfPosition(node.initializer.pos); + // This is to ensure that we emit comment in the following case: + // For example: + // obj = { + // id: /*comment1*/ ()=>void + // } + // "comment1" is not considered to be leading comment for node.initializer + // but rather a trailing comment on the previous node. + emitLeadingComments(node.initializer, getTrailingComments(collapseTextRange(node.initializer, TextRangeCollapse.CollapseToStart))); emitExpression(node.initializer); } @@ -1951,11 +1939,8 @@ const _super = (function (geti, seti) { } function emitModifiers(node: Node, modifiers: ModifiersArray) { - const startingPos = writer.getTextPos(); - emitList(node, modifiers, ListFormat.SingleLine); - - const endingPos = writer.getTextPos(); - if (startingPos !== endingPos) { + if (modifiers && modifiers.length) { + emitList(node, modifiers, ListFormat.SingleLine); write(" "); } } @@ -2345,7 +2330,15 @@ const _super = (function (geti, seti) { } function getTextOfNode(node: Node, includeTrivia?: boolean) { - if (nodeIsSynthesized(node) && (isLiteralExpression(node) || isIdentifier(node))) { + if (isIdentifier(node)) { + if (node.autoGenerateKind) { + return getGeneratedIdentifier(node); + } + else if (nodeIsSynthesized(node) || !node.parent) { + return node.text; + } + } + else if (isLiteralExpression(node) && (nodeIsSynthesized(node) || !node.parent)) { return node.text; } @@ -2368,10 +2361,22 @@ const _super = (function (geti, seti) { && rangeEndIsOnSameLineAsRangeStart(block, block); } - function tempKindToFlags(kind: TempVariableKind) { - return kind === TempVariableKind.Loop - ? TempFlags._i - : TempFlags.Auto; + function isUniqueName(name: string): boolean { + return !resolver.hasGlobalName(name) && + !hasProperty(currentFileIdentifiers, name) && + !hasProperty(generatedNameSet, name); + } + + function isUniqueLocalName(name: string, container: Node): boolean { + for (let node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + if (node.locals && hasProperty(node.locals, name)) { + // We conservatively include alias symbols to cover cases where they're emitted as locals + if (node.locals[name].flags & (SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias)) { + return false; + } + } + } + return true; } /** @@ -2401,6 +2406,85 @@ const _super = (function (geti, seti) { } } } + + // Generate a name that is unique within the current file and doesn't conflict with any names + // in global scope. The name is formed by adding an '_n' suffix to the specified base name, + // where n is a positive integer. Note that names generated by makeTempVariableName and + // makeUniqueName are guaranteed to never conflict. + function makeUniqueName(baseName: string): string { + // Find the first unique 'name_n', where n is a positive number + if (baseName.charCodeAt(baseName.length - 1) !== CharacterCodes._) { + baseName += "_"; + } + let i = 1; + while (true) { + const generatedName = baseName + i; + if (isUniqueName(generatedName)) { + return generatedNameSet[generatedName] = generatedName; + } + i++; + } + } + + function generateNameForModuleOrEnum(node: ModuleDeclaration | EnumDeclaration) { + const name = node.name.text; + // Use module/enum name itself if it is unique, otherwise make a unique variation + return isUniqueLocalName(name, node) ? name : makeUniqueName(name); + } + + function generateNameForImportOrExportDeclaration(node: ImportDeclaration | ExportDeclaration) { + const expr = getExternalModuleName(node); + const baseName = expr.kind === SyntaxKind.StringLiteral ? + escapeIdentifier(makeIdentifierFromModuleName((expr).text)) : "module"; + return makeUniqueName(baseName); + } + + function generateNameForExportDefault() { + return makeUniqueName("default"); + } + + function generateNameForClassExpression() { + return makeUniqueName("class"); + } + + function generateNameForNode(node: Node) { + switch (node.kind) { + case SyntaxKind.Identifier: + return makeUniqueName((node).text); + case SyntaxKind.ModuleDeclaration: + case SyntaxKind.EnumDeclaration: + return generateNameForModuleOrEnum(node); + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ExportDeclaration: + return generateNameForImportOrExportDeclaration(node); + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.ClassDeclaration: + case SyntaxKind.ExportAssignment: + return generateNameForExportDefault(); + case SyntaxKind.ClassExpression: + return generateNameForClassExpression(); + default: + return makeTempVariableName(TempFlags.Auto); + } + } + + function generateIdentifier(node: Identifier) { + switch (node.autoGenerateKind) { + case GeneratedIdentifierKind.Auto: + return makeTempVariableName(TempFlags.Auto); + case GeneratedIdentifierKind.Loop: + return makeTempVariableName(TempFlags._i); + case GeneratedIdentifierKind.Unique: + return makeUniqueName(node.text); + case GeneratedIdentifierKind.Node: + return generateNameForNode(getOriginalNode(node)); + } + } + + function getGeneratedIdentifier(node: Identifier) { + const id = getOriginalNodeId(node); + return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = unescapeIdentifier(generateIdentifier(node))); + } } } diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 65d61c044c2..98b71f0c16e 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -22,8 +22,6 @@ namespace ts { * @param transforms An array of Transformers. */ export function transformFiles(resolver: EmitResolver, host: EmitHost, sourceFiles: SourceFile[], transformers: Transformer[]) { - const nodeToGeneratedName: Identifier[] = []; - const generatedNameSet: Map = {}; const nodeEmitFlags: NodeEmitFlags[] = []; const lexicalEnvironmentVariableDeclarationsStack: VariableDeclaration[][] = []; const lexicalEnvironmentFunctionDeclarationsStack: FunctionDeclaration[][] = []; @@ -40,10 +38,6 @@ namespace ts { getEmitResolver: () => resolver, getNodeEmitFlags, setNodeEmitFlags, - isUniqueName, - getGeneratedNameForNode, - nodeHasGeneratedName, - makeUniqueName, hoistVariableDeclaration, hoistFunctionDeclaration, startLexicalEnvironment, @@ -119,118 +113,6 @@ namespace ts { return node; } - /** - * Generate a name that is unique within the current file and doesn't conflict with any names - * in global scope. The name is formed by adding an '_n' suffix to the specified base name, - * where n is a positive integer. Note that names generated by makeTempVariableName and - * makeUniqueName are guaranteed to never conflict. - */ - function makeUniqueName(baseName: string): Identifier { - // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== CharacterCodes._) { - baseName += "_"; - } - - let i = 1; - while (true) { - const generatedName = baseName + i; - if (isUniqueName(generatedName)) { - return createIdentifier(generatedNameSet[generatedName] = generatedName); - } - - i++; - } - } - - /** - * Gets the generated name for a node. - */ - function getGeneratedNameForNode(node: Node) { - const id = getNodeId(node); - return nodeToGeneratedName[id] || (nodeToGeneratedName[id] = generateNameForNode(node)); - } - - /** - * Gets a value indicating whether a node has a generated name. - */ - function nodeHasGeneratedName(node: Node) { - const id = getNodeId(node); - return nodeToGeneratedName[id] !== undefined; - } - - /** - * Tests whether the provided name is unique. - */ - function isUniqueName(name: string): boolean { - return !resolver.hasGlobalName(name) - && !hasProperty(currentSourceFile.identifiers, name) - && !hasProperty(generatedNameSet, name); - } - - /** - * Tests whether the provided name is unique within a container. - */ - function isUniqueLocalName(name: string, container: Node): boolean { - container = getOriginalNode(container); - for (let node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && hasProperty(node.locals, name)) { - // We conservatively include alias symbols to cover cases where they're emitted as locals - if (node.locals[name].flags & (SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias)) { - return false; - } - } - } - return true; - } - - /** - * Generates a name for a node. - */ - function generateNameForNode(node: Node): Identifier { - switch (node.kind) { - case SyntaxKind.Identifier: - return makeUniqueName((node).text); - case SyntaxKind.ModuleDeclaration: - case SyntaxKind.EnumDeclaration: - return generateNameForModuleOrEnum(node); - case SyntaxKind.ImportDeclaration: - case SyntaxKind.ExportDeclaration: - return generateNameForImportOrExportDeclaration(node); - case SyntaxKind.FunctionDeclaration: - case SyntaxKind.ClassDeclaration: - Debug.assert((node.flags & NodeFlags.Default) !== 0, "Can only generate a name for a default export."); - return generateNameForExportDefault(); - case SyntaxKind.ExportAssignment: - return generateNameForExportDefault(); - case SyntaxKind.ClassExpression: - return generateNameForClassExpression(); - default: - return createTempVariable(); - } - } - - function generateNameForModuleOrEnum(node: ModuleDeclaration | EnumDeclaration) { - const name = node.name; - // Use module/enum name itself if it is unique, otherwise make a unique variation - return isUniqueLocalName(name.text, node) ? name : makeUniqueName(name.text); - } - - function generateNameForImportOrExportDeclaration(node: ImportDeclaration | ExportDeclaration) { - const expr = getExternalModuleName(node); - const baseName = expr.kind === SyntaxKind.StringLiteral - ? escapeIdentifier(makeIdentifierFromModuleName((expr).text)) - : "module"; - return makeUniqueName(baseName); - } - - function generateNameForExportDefault() { - return makeUniqueName("default"); - } - - function generateNameForClassExpression() { - return makeUniqueName("class"); - } - /** * Records a hoisted variable declaration for the provided name within a lexical environment. */ diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6a55153f631..fb5ab0c3609 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -497,16 +497,19 @@ namespace ts { // @kind(SyntaxKind.StaticKeyword) export interface Modifier extends Node { } - export const enum TempVariableKind { - Auto, // Automatically generated identifier - Loop, // Automatically generated identifier with a preference for '_i' + export const enum GeneratedIdentifierKind { + None, // Not automatically generated. + Auto, // Automatically generated identifier. + Loop, // Automatically generated identifier with a preference for '_i'. + Unique, // Unique name based on the 'text' property. + Node, // Unique name based on the node in the 'original' property. } // @kind(SyntaxKind.Identifier) export interface Identifier extends PrimaryExpression { text: string; // Text of identifier (with escapes converted to characters) - tempKind?: TempVariableKind; // Specifies whether to auto-generate the text for an identifier. originalKeywordKind?: SyntaxKind; // Original syntaxKind which get set so that we can report an error later + autoGenerateKind?: GeneratedIdentifierKind; // Specifies whether to auto-generate the text for an identifier. } // @kind(SyntaxKind.QualifiedName) @@ -2805,7 +2808,7 @@ namespace ts { SingleLine = 1 << 6, // The contents of this node should be emit on a single line. AdviseOnEmitNode = 1 << 7, // The node printer should invoke the onBeforeEmitNode and onAfterEmitNode callbacks when printing this node. IsNotEmittedNode = 1 << 8, // Is a node that is not emitted but whose comments should be preserved if possible. - EmitCommentsOfNotEmittedParent = 1 << 8, // Emits comments of missing parent nodes. + EmitCommentsOfNotEmittedParent = 1 << 9, // Emits comments of missing parent nodes. } /** Additional context provided to `visitEachChild` */ @@ -2825,10 +2828,6 @@ namespace ts { setNodeEmitFlags(node: T, flags: NodeEmitFlags): T; hoistFunctionDeclaration(node: FunctionDeclaration): void; hoistVariableDeclaration(node: Identifier): void; - isUniqueName(name: string): boolean; - getGeneratedNameForNode(node: Node): Identifier; - nodeHasGeneratedName(node: Node): boolean; - makeUniqueName(baseName: string): Identifier; /** * Hook used by transformers to substitute non-expression identifiers diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 10b5b467158..514ee5f258d 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2297,11 +2297,11 @@ namespace ts { writer.write(" "); } - let emitInterveningSeperator = false; + let emitInterveningSeparator = false; for (const comment of comments) { - if (emitInterveningSeperator) { + if (emitInterveningSeparator) { writer.write(" "); - emitInterveningSeperator = false; + emitInterveningSeparator = false; } writeComment(text, lineMap, writer, comment, newLine); @@ -2309,11 +2309,11 @@ namespace ts { writer.writeLine(); } else { - emitInterveningSeperator = true; + emitInterveningSeparator = true; } } - if (emitInterveningSeperator && trailingSeparator) { + if (emitInterveningSeparator && trailingSeparator) { writer.write(" "); } } @@ -2723,7 +2723,7 @@ namespace ts { } return collapse === TextRangeCollapse.CollapseToStart - ? { pos: range.pos, end: range.end } + ? { pos: range.pos, end: range.pos } : { pos: range.end, end: range.end }; } From b1d88282ce4d56a79ae0f2aa5d53e392cb01e556 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 29 Feb 2016 13:29:03 -0800 Subject: [PATCH 2/7] Remove transformCompatibleEmit flag and make it the default. --- Jakefile.js | 8 - src/compiler/commandLineParser.ts | 7 - src/compiler/emitter.ts | 27 +- src/compiler/types.ts | 1 - ...ticVariableAndExportedVarThatShareAName.js | 4 +- ...VariableAndNonExportedVarThatShareAName.js | 4 +- ...onWithInvalidConstOnPropertyDeclaration.js | 2 +- .../baselines/reference/ES5SymbolProperty1.js | 3 +- .../amdImportNotAsPrimaryExpression.js | 2 +- tests/baselines/reference/autolift4.js | 2 +- .../blockScopedVariablesUseBeforeDef.js | 30 +- tests/baselines/reference/class2.js | 2 +- .../classExpressionWithDecorator1.js | 8 +- .../classExpressionWithStaticProperties1.js | 16 +- .../classExpressionWithStaticProperties2.js | 14 +- .../classMemberInitializerScoping.js | 2 +- .../classMemberInitializerWithLamdaScoping.js | 14 +- .../reference/classWithPrivateProperty.js | 2 +- .../reference/classWithProtectedProperty.js | 2 +- .../reference/classWithPublicProperty.js | 2 +- .../reference/cloduleStaticMembers.js | 4 +- .../reference/commentsOnStaticMembers.js | 16 +- .../commonJSImportAsPrimaryExpression.js | 2 +- .../commonJSImportNotAsPrimaryExpression.js | 2 +- .../reference/computedPropertyNames10_ES5.js | 3 +- .../reference/computedPropertyNames11_ES5.js | 3 +- .../reference/computedPropertyNames12_ES5.js | 2 +- .../reference/computedPropertyNames18_ES5.js | 3 +- .../reference/computedPropertyNames19_ES5.js | 3 +- .../reference/computedPropertyNames1_ES5.js | 3 +- .../reference/computedPropertyNames20_ES5.js | 3 +- .../reference/computedPropertyNames22_ES5.js | 3 +- .../reference/computedPropertyNames25_ES5.js | 3 +- .../reference/computedPropertyNames28_ES5.js | 3 +- .../reference/computedPropertyNames29_ES5.js | 3 +- .../reference/computedPropertyNames30_ES5.js | 3 +- .../reference/computedPropertyNames31_ES5.js | 3 +- .../reference/computedPropertyNames33_ES5.js | 3 +- .../reference/computedPropertyNames34_ES5.js | 3 +- .../reference/computedPropertyNames46_ES5.js | 3 +- .../reference/computedPropertyNames47_ES5.js | 3 +- .../reference/computedPropertyNames48_ES5.js | 9 +- .../reference/computedPropertyNames49_ES5.js | 3 +- .../reference/computedPropertyNames4_ES5.js | 3 +- .../reference/computedPropertyNames50_ES5.js | 3 +- .../reference/computedPropertyNames5_ES5.js | 3 +- .../reference/computedPropertyNames6_ES5.js | 3 +- .../reference/computedPropertyNames7_ES5.js | 3 +- .../reference/computedPropertyNames8_ES5.js | 3 +- .../reference/computedPropertyNames9_ES5.js | 3 +- ...mputedPropertyNamesContextualType10_ES5.js | 3 +- ...omputedPropertyNamesContextualType1_ES5.js | 3 +- ...omputedPropertyNamesContextualType2_ES5.js | 3 +- ...omputedPropertyNamesContextualType3_ES5.js | 3 +- ...omputedPropertyNamesContextualType4_ES5.js | 3 +- ...omputedPropertyNamesContextualType5_ES5.js | 3 +- ...omputedPropertyNamesContextualType6_ES5.js | 3 +- ...omputedPropertyNamesContextualType7_ES5.js | 3 +- ...omputedPropertyNamesContextualType8_ES5.js | 3 +- ...omputedPropertyNamesContextualType9_ES5.js | 3 +- ...mputedPropertyNamesDeclarationEmit5_ES5.js | 3 +- .../computedPropertyNamesSourceMap2_ES5.js | 3 +- ...computedPropertyNamesSourceMap2_ES5.js.map | 2 +- ...dPropertyNamesSourceMap2_ES5.sourcemap.txt | 16 +- ...TypedClassExpressionMethodDeclaration01.js | 40 +- .../reference/declFilePrivateStatic.js | 4 +- .../reference/decoratorCallGeneric.js | 6 +- .../decoratorChecksFunctionBodies.js | 14 +- ...ratorInstantiateModulesInFunctionBodies.js | 6 +- .../baselines/reference/decoratorMetadata.js | 20 +- ...taForMethodWithNoReturnTypeAnnotation01.js | 12 +- .../decoratorMetadataOnInferredType.js | 8 +- .../decoratorMetadataWithConstructorType.js | 8 +- ...adataWithImportDeclarationNameCollision.js | 8 +- ...dataWithImportDeclarationNameCollision2.js | 8 +- ...dataWithImportDeclarationNameCollision3.js | 8 +- ...dataWithImportDeclarationNameCollision4.js | 8 +- ...dataWithImportDeclarationNameCollision5.js | 8 +- ...dataWithImportDeclarationNameCollision6.js | 8 +- ...dataWithImportDeclarationNameCollision7.js | 8 +- ...dataWithImportDeclarationNameCollision8.js | 8 +- .../baselines/reference/decoratorOnClass1.js | 6 +- .../baselines/reference/decoratorOnClass2.js | 6 +- .../baselines/reference/decoratorOnClass3.js | 6 +- .../baselines/reference/decoratorOnClass4.js | 6 +- .../baselines/reference/decoratorOnClass5.js | 6 +- .../baselines/reference/decoratorOnClass8.js | 6 +- .../reference/decoratorOnClassAccessor1.js | 6 +- .../reference/decoratorOnClassAccessor2.js | 6 +- .../reference/decoratorOnClassAccessor3.js | 6 +- .../reference/decoratorOnClassAccessor4.js | 6 +- .../reference/decoratorOnClassAccessor5.js | 6 +- .../reference/decoratorOnClassAccessor6.js | 6 +- .../decoratorOnClassConstructorParameter1.js | 6 +- .../decoratorOnClassConstructorParameter4.js | 6 +- .../reference/decoratorOnClassMethod1.js | 6 +- .../reference/decoratorOnClassMethod10.js | 6 +- .../reference/decoratorOnClassMethod11.js | 6 +- .../reference/decoratorOnClassMethod12.js | 6 +- .../reference/decoratorOnClassMethod2.js | 6 +- .../reference/decoratorOnClassMethod3.js | 6 +- .../reference/decoratorOnClassMethod8.js | 6 +- .../decoratorOnClassMethodOverload2.js | 6 +- .../decoratorOnClassMethodParameter1.js | 6 +- .../reference/decoratorOnClassProperty1.js | 6 +- .../reference/decoratorOnClassProperty10.js | 6 +- .../reference/decoratorOnClassProperty11.js | 6 +- .../reference/decoratorOnClassProperty2.js | 6 +- .../reference/decoratorOnClassProperty3.js | 6 +- .../reference/decoratorOnClassProperty6.js | 6 +- .../reference/decoratorOnClassProperty7.js | 6 +- ...dClassSuperCallsInNonConstructorMembers.js | 2 +- tests/baselines/reference/errorSuperCalls.js | 4 +- .../reference/errorSuperPropertyAccess.js | 4 +- .../reference/es3defaultAliasIsQuoted.js | 2 +- tests/baselines/reference/es6ClassTest.js | 2 +- tests/baselines/reference/es6ClassTest2.js | 2 +- .../reference/generatedContextualTyping.js | 72 +- ...nericClassWithStaticsUsingTypeArguments.js | 8 +- .../baselines/reference/gettersAndSetters.js | 2 +- .../reference/importImportOnlyModule.js | 2 +- .../instanceAndStaticDeclarations1.js | 2 +- .../baselines/reference/invalidStaticField.js | 2 +- .../literalsInComputedProperties1.js | 3 +- .../reference/missingDecoratorType.js | 6 +- ...difierOnClassExpressionMemberInFunction.js | 18 +- tests/baselines/reference/noEmitHelpers2.js | 10 +- .../parserAccessibilityAfterStatic3.js | 2 +- ...ErrorRecovery_IncompleteMemberVariable1.js | 4 +- ...ErrorRecovery_IncompleteMemberVariable2.js | 4 +- tests/baselines/reference/parserharness.js | 6 +- .../privacyCannotNameVarTypeDeclFile.js | 24 +- tests/baselines/reference/privateIndexer2.js | 3 +- .../privateStaticMemberAccessibility.js | 2 +- .../reference/propertyAccessibility2.js | 2 +- .../reference/quotedPropertyName2.js | 2 +- .../baselines/reference/reassignStaticProp.js | 2 +- .../reference/sourceMap-FileWithComments.js | 4 +- .../sourceMap-FileWithComments.js.map | 2 +- .../sourceMap-FileWithComments.sourcemap.txt | 133 ++-- .../sourceMapValidationDecorators.js | 62 +- .../sourceMapValidationDecorators.js.map | 2 +- ...ourceMapValidationDecorators.sourcemap.txt | 650 +++++++++--------- tests/baselines/reference/staticClassProps.js | 2 +- .../staticMemberAccessOffDerivedType1.js | 2 +- .../reference/staticMemberInitialization.js | 2 +- .../staticMemberWithStringAndNumberNames.js | 10 +- .../reference/staticModifierAlreadySeen.js | 2 +- tests/baselines/reference/staticPropSuper.js | 2 +- tests/baselines/reference/statics.js | 6 +- .../reference/staticsInConstructorBodies.js | 2 +- .../reference/staticsNotInScopeInClodule.js | 2 +- .../reference/strictModeInConstructor.js | 6 +- tests/baselines/reference/superAccess.js | 2 +- tests/baselines/reference/superAccess2.js | 2 +- ...thisInArrowFunctionInStaticInitializer1.js | 8 +- .../reference/thisInConstructorParameter2.js | 2 +- .../reference/thisInInvalidContexts.js | 2 +- .../thisInInvalidContextsExternalModule.js | 2 +- .../reference/thisInOuterClassBody.js | 2 +- .../thisInPropertyBoundDeclarations.js | 10 +- .../reference/thisInStaticMethod1.js | 2 +- tests/baselines/reference/thisTypeErrors.js | 2 +- ...peArgumentInferenceWithClassExpression1.js | 14 +- ...peArgumentInferenceWithClassExpression2.js | 14 +- tests/baselines/reference/typeOfPrototype.js | 2 +- .../reference/typeOfThisInStaticMembers2.js | 4 +- tests/baselines/reference/typeQueryOnClass.js | 4 +- .../unqualifiedCallToClassStatic1.js | 8 +- tests/baselines/reference/witness.js | 2 +- tests/cases/unittests/transpile.ts | 126 ++-- 171 files changed, 947 insertions(+), 1017 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index d1821b5b5e0..7b9c4806e0a 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -223,7 +223,6 @@ function concatenateFiles(destinationFile, sourceFiles) { var useDebugMode = true; var useTransforms = process.env.USE_TRANSFORMS || false; -var useTransformCompat = false; var host = (process.env.host || process.env.TYPESCRIPT_HOST || "node"); var compilerFilename = "tsc.js"; var LKGCompiler = path.join(LKGDirectory, compilerFilename); @@ -286,9 +285,6 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu if (useBuiltCompiler && useTransforms) { options += " --experimentalTransforms" } - else if (useBuiltCompiler && useTransformCompat) { - options += " --transformCompatibleEmit" - } var cmd = host + " " + compilerPath + " " + options + " "; cmd = cmd + sources.join(" "); @@ -417,10 +413,6 @@ task("setTransforms", function() { useTransforms = true; }); -task("setTransformCompat", function() { - useTransformCompat = true; -}); - task("configure-nightly", [configureNightlyJs], function() { var cmd = host + " " + configureNightlyJs + " " + packageJson + " " + programTs; console.log(cmd); diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 307bb5d5403..cc2806f93c1 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -327,13 +327,6 @@ namespace ts { name: "experimentalTransforms", type: "boolean", experimental: true - }, - { - // this option will be removed when this is merged with master and exists solely - // to enable the tree transforming emitter side-by-side with the existing emitter. - name: "transformCompatibleEmit", - type: "boolean", - experimental: true } ]; diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 357fec7f0fd..a3c27d8d817 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1915,9 +1915,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge if (multiLine) { decreaseIndent(); - if (!compilerOptions.transformCompatibleEmit) { - writeLine(); - } } write(")"); @@ -2237,7 +2234,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge return forEach(elements, e => e.kind === SyntaxKind.SpreadElementExpression); } - function skipParentheses(node: Expression): Expression { + function skipParenthesesAndAssertions(node: Expression): Expression { while (node.kind === SyntaxKind.ParenthesizedExpression || node.kind === SyntaxKind.TypeAssertionExpression || node.kind === SyntaxKind.AsExpression) { node = (node).expression; } @@ -2268,7 +2265,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge function emitCallWithSpread(node: CallExpression) { let target: Expression; - const expr = skipParentheses(node.expression); + const expr = skipParenthesesAndAssertions(node.expression); if (expr.kind === SyntaxKind.PropertyAccessExpression) { // Target will be emitted as "this" argument target = emitCallTarget((expr).expression); @@ -4334,9 +4331,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge writeLine(); emitStart(restParam); emitNodeWithCommentsAndWithoutSourcemap(restParam.name); - write(restIndex > 0 || !compilerOptions.transformCompatibleEmit - ? `[${tempName} - ${restIndex}] = arguments[${tempName}];` - : `[${tempName}] = arguments[${tempName}];`); + write(`[${tempName} - ${restIndex}] = arguments[${tempName}];`); emitEnd(restParam); decreaseIndent(); writeLine(); @@ -5356,7 +5351,7 @@ const _super = (function (geti, seti) { const isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === SyntaxKind.ClassExpression; let tempVariable: Identifier; - if (isClassExpressionWithStaticProperties && compilerOptions.transformCompatibleEmit) { + if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(TempFlags.Auto); write("("); increaseIndent(); @@ -5393,11 +5388,6 @@ const _super = (function (geti, seti) { writeLine(); emitConstructor(node, baseTypeNode); emitMemberFunctionsForES5AndLower(node); - if (!compilerOptions.transformCompatibleEmit) { - emitPropertyDeclarations(node, staticProperties); - writeLine(); - emitDecoratorsOfClass(node, /*decoratedClassAlias*/ undefined); - } writeLine(); emitToken(SyntaxKind.CloseBraceToken, node.members.end, () => { write("return "); @@ -5424,13 +5414,10 @@ const _super = (function (geti, seti) { write("))"); if (node.kind === SyntaxKind.ClassDeclaration) { write(";"); - if (compilerOptions.transformCompatibleEmit) { - emitPropertyDeclarations(node, staticProperties); - writeLine(); - emitDecoratorsOfClass(node, /*decoratedClassAlias*/ undefined); - } + emitPropertyDeclarations(node, staticProperties); + emitDecoratorsOfClass(node, /*decoratedClassAlias*/ undefined); } - else if (isClassExpressionWithStaticProperties && compilerOptions.transformCompatibleEmit) { + else if (isClassExpressionWithStaticProperties) { for (const property of staticProperties) { write(","); writeLine(); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index fb5ab0c3609..07d1daec669 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2473,7 +2473,6 @@ namespace ts { allowJs?: boolean; /* @internal */ stripInternal?: boolean; /* @internal */ experimentalTransforms?: boolean; - /* @internal */ transformCompatibleEmit?: boolean; // Skip checking lib.d.ts to help speed up tests. /* @internal */ skipDefaultLibCheck?: boolean; diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.js b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.js index a0cb50e7382..63d3739846b 100644 --- a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.js +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.js @@ -28,9 +28,9 @@ var Point = (function () { this.x = x; this.y = y; } - Point.Origin = { x: 0, y: 0 }; return Point; }()); +Point.Origin = { x: 0, y: 0 }; var Point; (function (Point) { Point.Origin = ""; //expected duplicate identifier error @@ -42,9 +42,9 @@ var A; this.x = x; this.y = y; } - Point.Origin = { x: 0, y: 0 }; return Point; }()); + Point.Origin = { x: 0, y: 0 }; A.Point = Point; var Point; (function (Point) { diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.js b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.js index 3bbf3b98d6e..3921546a21c 100644 --- a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.js +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.js @@ -28,9 +28,9 @@ var Point = (function () { this.x = x; this.y = y; } - Point.Origin = { x: 0, y: 0 }; return Point; }()); +Point.Origin = { x: 0, y: 0 }; var Point; (function (Point) { var Origin = ""; // not an error, since not exported @@ -42,9 +42,9 @@ var A; this.x = x; this.y = y; } - Point.Origin = { x: 0, y: 0 }; return Point; }()); + Point.Origin = { x: 0, y: 0 }; A.Point = Point; var Point; (function (Point) { diff --git a/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js index d5c3b3d63f4..7633955b227 100644 --- a/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js +++ b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.js @@ -7,6 +7,6 @@ class AtomicNumbers { var AtomicNumbers = (function () { function AtomicNumbers() { } - AtomicNumbers.H = 1; return AtomicNumbers; }()); +AtomicNumbers.H = 1; diff --git a/tests/baselines/reference/ES5SymbolProperty1.js b/tests/baselines/reference/ES5SymbolProperty1.js index 1073a33163d..ab3f420c95c 100644 --- a/tests/baselines/reference/ES5SymbolProperty1.js +++ b/tests/baselines/reference/ES5SymbolProperty1.js @@ -14,7 +14,6 @@ obj[Symbol.foo]; var Symbol; var obj = (_a = {}, _a[Symbol.foo] = 0, - _a -); + _a); obj[Symbol.foo]; var _a; diff --git a/tests/baselines/reference/amdImportNotAsPrimaryExpression.js b/tests/baselines/reference/amdImportNotAsPrimaryExpression.js index beb91191bc0..0739792fddd 100644 --- a/tests/baselines/reference/amdImportNotAsPrimaryExpression.js +++ b/tests/baselines/reference/amdImportNotAsPrimaryExpression.js @@ -38,9 +38,9 @@ define(["require", "exports"], function (require, exports) { function C1() { this.m1 = 42; } - C1.s1 = true; return C1; }()); + C1.s1 = true; exports.C1 = C1; (function (E1) { E1[E1["A"] = 0] = "A"; diff --git a/tests/baselines/reference/autolift4.js b/tests/baselines/reference/autolift4.js index 8ee1f397d43..e6790021f63 100644 --- a/tests/baselines/reference/autolift4.js +++ b/tests/baselines/reference/autolift4.js @@ -37,9 +37,9 @@ var Point = (function () { Point.prototype.getDist = function () { return Math.sqrt(this.x * this.x + this.y * this.y); }; - Point.origin = new Point(0, 0); return Point; }()); +Point.origin = new Point(0, 0); var Point3D = (function (_super) { __extends(Point3D, _super); function Point3D(x, y, z, m) { diff --git a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js index 06eaa9916e3..0197d919fef 100644 --- a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js +++ b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.js @@ -163,31 +163,35 @@ function foo8() { var x; } function foo9() { - var y = (function () { - function class_3() { - } - class_3.a = x; - return class_3; - }()); + var y = (_a = (function () { + function class_3() { + } + return class_3; + }()), + _a.a = x, + _a); var x; + var _a; } function foo10() { var A = (function () { function A() { } - A.a = x; return A; }()); + A.a = x; var x; } function foo11() { function f() { - var y = (function () { - function class_4() { - } - class_4.a = x; - return class_4; - }()); + var y = (_a = (function () { + function class_4() { + } + return class_4; + }()), + _a.a = x, + _a); + var _a; } var x; } diff --git a/tests/baselines/reference/class2.js b/tests/baselines/reference/class2.js index 6ef78ed46ee..91ac89da109 100644 --- a/tests/baselines/reference/class2.js +++ b/tests/baselines/reference/class2.js @@ -5,6 +5,6 @@ class foo { constructor() { static f = 3; } } var foo = (function () { function foo() { } - foo.f = 3; return foo; }()); +foo.f = 3; diff --git a/tests/baselines/reference/classExpressionWithDecorator1.js b/tests/baselines/reference/classExpressionWithDecorator1.js index e051e05251b..9b52891b559 100644 --- a/tests/baselines/reference/classExpressionWithDecorator1.js +++ b/tests/baselines/reference/classExpressionWithDecorator1.js @@ -12,10 +12,10 @@ var v = ; var C = (function () { function C() { } - C.p = 1; - C = __decorate([ - decorate - ], C); return C; }()); +C.p = 1; +C = __decorate([ + decorate +], C); ; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties1.js b/tests/baselines/reference/classExpressionWithStaticProperties1.js index cfe85d97a71..23d18d76766 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties1.js +++ b/tests/baselines/reference/classExpressionWithStaticProperties1.js @@ -2,10 +2,12 @@ var v = class C { static a = 1; static b = 2 }; //// [classExpressionWithStaticProperties1.js] -var v = (function () { - function C() { - } - C.a = 1; - C.b = 2; - return C; -}()); +var v = (_a = (function () { + function C() { + } + return C; + }()), + _a.a = 1, + _a.b = 2, + _a); +var _a; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties2.js b/tests/baselines/reference/classExpressionWithStaticProperties2.js index 134441e0ad9..b9fc0345591 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties2.js +++ b/tests/baselines/reference/classExpressionWithStaticProperties2.js @@ -2,9 +2,11 @@ var v = class C { static a = 1; static b }; //// [classExpressionWithStaticProperties2.js] -var v = (function () { - function C() { - } - C.a = 1; - return C; -}()); +var v = (_a = (function () { + function C() { + } + return C; + }()), + _a.a = 1, + _a); +var _a; diff --git a/tests/baselines/reference/classMemberInitializerScoping.js b/tests/baselines/reference/classMemberInitializerScoping.js index 8f78cfb9ac6..52bbaee8945 100644 --- a/tests/baselines/reference/classMemberInitializerScoping.js +++ b/tests/baselines/reference/classMemberInitializerScoping.js @@ -27,9 +27,9 @@ var CCC = (function () { this.y = aaa; this.y = ''; // was: error, cannot assign string to number } - CCC.staticY = aaa; // This shouldnt be error return CCC; }()); +CCC.staticY = aaa; // This shouldnt be error // above is equivalent to this: var aaaa = 1; var CCCC = (function () { diff --git a/tests/baselines/reference/classMemberInitializerWithLamdaScoping.js b/tests/baselines/reference/classMemberInitializerWithLamdaScoping.js index 752220a4cbc..c5b661831a2 100644 --- a/tests/baselines/reference/classMemberInitializerWithLamdaScoping.js +++ b/tests/baselines/reference/classMemberInitializerWithLamdaScoping.js @@ -40,12 +40,12 @@ var Test = (function () { console.log(field); // Using field here shouldnt be error }; } - Test.staticMessageHandler = function () { - var field = Test.field; - console.log(field); // Using field here shouldnt be error - }; return Test; }()); +Test.staticMessageHandler = function () { + var field = Test.field; + console.log(field); // Using field here shouldnt be error +}; var field1; var Test1 = (function () { function Test1(field1) { @@ -56,8 +56,8 @@ var Test1 = (function () { // it would resolve to private field1 and thats not what user intended here. }; } - Test1.staticMessageHandler = function () { - console.log(field1); // This shouldnt be error as its a static property - }; return Test1; }()); +Test1.staticMessageHandler = function () { + console.log(field1); // This shouldnt be error as its a static property +}; diff --git a/tests/baselines/reference/classWithPrivateProperty.js b/tests/baselines/reference/classWithPrivateProperty.js index 6e75797523f..c94f1d8ed80 100644 --- a/tests/baselines/reference/classWithPrivateProperty.js +++ b/tests/baselines/reference/classWithPrivateProperty.js @@ -32,9 +32,9 @@ var C = (function () { } C.prototype.c = function () { return ''; }; C.f = function () { return ''; }; - C.g = function () { return ''; }; return C; }()); +C.g = function () { return ''; }; var c = new C(); var r1 = c.x; var r2 = c.a; diff --git a/tests/baselines/reference/classWithProtectedProperty.js b/tests/baselines/reference/classWithProtectedProperty.js index 75eadaf4010..2b2e01e59df 100644 --- a/tests/baselines/reference/classWithProtectedProperty.js +++ b/tests/baselines/reference/classWithProtectedProperty.js @@ -42,9 +42,9 @@ var C = (function () { } C.prototype.c = function () { return ''; }; C.f = function () { return ''; }; - C.g = function () { return ''; }; return C; }()); +C.g = function () { return ''; }; var D = (function (_super) { __extends(D, _super); function D() { diff --git a/tests/baselines/reference/classWithPublicProperty.js b/tests/baselines/reference/classWithPublicProperty.js index 054713264bd..47708b7aff3 100644 --- a/tests/baselines/reference/classWithPublicProperty.js +++ b/tests/baselines/reference/classWithPublicProperty.js @@ -30,9 +30,9 @@ var C = (function () { } C.prototype.c = function () { return ''; }; C.f = function () { return ''; }; - C.g = function () { return ''; }; return C; }()); +C.g = function () { return ''; }; // all of these are valid var c = new C(); var r1 = c.x; diff --git a/tests/baselines/reference/cloduleStaticMembers.js b/tests/baselines/reference/cloduleStaticMembers.js index 6095442b629..868b9305bdf 100644 --- a/tests/baselines/reference/cloduleStaticMembers.js +++ b/tests/baselines/reference/cloduleStaticMembers.js @@ -16,10 +16,10 @@ module Clod { var Clod = (function () { function Clod() { } - Clod.x = 10; - Clod.y = 10; return Clod; }()); +Clod.x = 10; +Clod.y = 10; var Clod; (function (Clod) { var p = Clod.x; diff --git a/tests/baselines/reference/commentsOnStaticMembers.js b/tests/baselines/reference/commentsOnStaticMembers.js index 51ed906841d..851f9025be3 100644 --- a/tests/baselines/reference/commentsOnStaticMembers.js +++ b/tests/baselines/reference/commentsOnStaticMembers.js @@ -24,13 +24,13 @@ class test { var test = (function () { function test() { } - /** - * p1 comment appears in output - */ - test.p1 = ""; - /** - * p3 comment appears in output - */ - test.p3 = ""; return test; }()); +/** + * p1 comment appears in output + */ +test.p1 = ""; +/** + * p3 comment appears in output + */ +test.p3 = ""; diff --git a/tests/baselines/reference/commonJSImportAsPrimaryExpression.js b/tests/baselines/reference/commonJSImportAsPrimaryExpression.js index 3f49588c103..b8cf42ea762 100644 --- a/tests/baselines/reference/commonJSImportAsPrimaryExpression.js +++ b/tests/baselines/reference/commonJSImportAsPrimaryExpression.js @@ -19,9 +19,9 @@ var C1 = (function () { function C1() { this.m1 = 42; } - C1.s1 = true; return C1; }()); +C1.s1 = true; exports.C1 = C1; //// [foo_1.js] "use strict"; diff --git a/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js b/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js index 720554f7e32..34d5c343b3c 100644 --- a/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js +++ b/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js @@ -37,9 +37,9 @@ var C1 = (function () { function C1() { this.m1 = 42; } - C1.s1 = true; return C1; }()); +C1.s1 = true; exports.C1 = C1; (function (E1) { E1[E1["A"] = 0] = "A"; diff --git a/tests/baselines/reference/computedPropertyNames10_ES5.js b/tests/baselines/reference/computedPropertyNames10_ES5.js index 14d9235b12b..302f9355be8 100644 --- a/tests/baselines/reference/computedPropertyNames10_ES5.js +++ b/tests/baselines/reference/computedPropertyNames10_ES5.js @@ -32,6 +32,5 @@ var v = (_a = {}, _a[true] = function () { }, _a["hello bye"] = function () { }, _a["hello " + a + " bye"] = function () { }, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames11_ES5.js b/tests/baselines/reference/computedPropertyNames11_ES5.js index 0917f824770..4fc74b30cbe 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES5.js +++ b/tests/baselines/reference/computedPropertyNames11_ES5.js @@ -68,6 +68,5 @@ var v = (_a = {}, enumerable: true, configurable: true }), - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames12_ES5.js b/tests/baselines/reference/computedPropertyNames12_ES5.js index 2aec8856286..10427b5dc13 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES5.js +++ b/tests/baselines/reference/computedPropertyNames12_ES5.js @@ -26,6 +26,6 @@ var C = (function () { this[s + n] = 2; this["hello bye"] = 0; } - C["hello " + a + " bye"] = 0; return C; }()); +C["hello " + a + " bye"] = 0; diff --git a/tests/baselines/reference/computedPropertyNames18_ES5.js b/tests/baselines/reference/computedPropertyNames18_ES5.js index b65c7fd4f7d..a62af506531 100644 --- a/tests/baselines/reference/computedPropertyNames18_ES5.js +++ b/tests/baselines/reference/computedPropertyNames18_ES5.js @@ -9,7 +9,6 @@ function foo() { function foo() { var obj = (_a = {}, _a[this.bar] = 0, - _a - ); + _a); var _a; } diff --git a/tests/baselines/reference/computedPropertyNames19_ES5.js b/tests/baselines/reference/computedPropertyNames19_ES5.js index 36f3e66c7c2..bda3e01bbed 100644 --- a/tests/baselines/reference/computedPropertyNames19_ES5.js +++ b/tests/baselines/reference/computedPropertyNames19_ES5.js @@ -10,7 +10,6 @@ var M; (function (M) { var obj = (_a = {}, _a[this.bar] = 0, - _a - ); + _a); var _a; })(M || (M = {})); diff --git a/tests/baselines/reference/computedPropertyNames1_ES5.js b/tests/baselines/reference/computedPropertyNames1_ES5.js index 4fdec28c7aa..75bbe909927 100644 --- a/tests/baselines/reference/computedPropertyNames1_ES5.js +++ b/tests/baselines/reference/computedPropertyNames1_ES5.js @@ -17,6 +17,5 @@ var v = (_a = {}, enumerable: true, configurable: true }), - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames20_ES5.js b/tests/baselines/reference/computedPropertyNames20_ES5.js index 65acd7fa08f..1eec0a7bcdb 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES5.js +++ b/tests/baselines/reference/computedPropertyNames20_ES5.js @@ -6,6 +6,5 @@ var obj = { //// [computedPropertyNames20_ES5.js] var obj = (_a = {}, _a[this.bar] = 0, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames22_ES5.js b/tests/baselines/reference/computedPropertyNames22_ES5.js index 5448f4dcf8d..721418ee930 100644 --- a/tests/baselines/reference/computedPropertyNames22_ES5.js +++ b/tests/baselines/reference/computedPropertyNames22_ES5.js @@ -15,8 +15,7 @@ var C = (function () { C.prototype.bar = function () { var obj = (_a = {}, _a[this.bar()] = function () { }, - _a - ); + _a); return 0; var _a; }; diff --git a/tests/baselines/reference/computedPropertyNames25_ES5.js b/tests/baselines/reference/computedPropertyNames25_ES5.js index f38ac0b2e0d..b03dd285ced 100644 --- a/tests/baselines/reference/computedPropertyNames25_ES5.js +++ b/tests/baselines/reference/computedPropertyNames25_ES5.js @@ -35,8 +35,7 @@ var C = (function (_super) { C.prototype.foo = function () { var obj = (_a = {}, _a[_super.prototype.bar.call(this)] = function () { }, - _a - ); + _a); return 0; var _a; }; diff --git a/tests/baselines/reference/computedPropertyNames28_ES5.js b/tests/baselines/reference/computedPropertyNames28_ES5.js index b5b1fdf77aa..ed15bbf0145 100644 --- a/tests/baselines/reference/computedPropertyNames28_ES5.js +++ b/tests/baselines/reference/computedPropertyNames28_ES5.js @@ -27,8 +27,7 @@ var C = (function (_super) { _super.call(this); var obj = (_a = {}, _a[(_super.call(this), "prop")] = function () { }, - _a - ); + _a); var _a; } return C; diff --git a/tests/baselines/reference/computedPropertyNames29_ES5.js b/tests/baselines/reference/computedPropertyNames29_ES5.js index 46ba529d7a5..af6f93c8ad9 100644 --- a/tests/baselines/reference/computedPropertyNames29_ES5.js +++ b/tests/baselines/reference/computedPropertyNames29_ES5.js @@ -19,8 +19,7 @@ var C = (function () { (function () { var obj = (_a = {}, _a[_this.bar()] = function () { }, - _a - ); + _a); var _a; }); return 0; diff --git a/tests/baselines/reference/computedPropertyNames30_ES5.js b/tests/baselines/reference/computedPropertyNames30_ES5.js index e787689d393..a900fd44c67 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES5.js +++ b/tests/baselines/reference/computedPropertyNames30_ES5.js @@ -36,8 +36,7 @@ var C = (function (_super) { // illegal, and not capturing this is consistent with //treatment of other similar violations. _a[(_super.call(this), "prop")] = function () { }, - _a - ); + _a); var _a; }); } diff --git a/tests/baselines/reference/computedPropertyNames31_ES5.js b/tests/baselines/reference/computedPropertyNames31_ES5.js index 8417f103fb7..86fb6655a27 100644 --- a/tests/baselines/reference/computedPropertyNames31_ES5.js +++ b/tests/baselines/reference/computedPropertyNames31_ES5.js @@ -39,8 +39,7 @@ var C = (function (_super) { (function () { var obj = (_a = {}, _a[_super.prototype.bar.call(_this)] = function () { }, - _a - ); + _a); var _a; }); return 0; diff --git a/tests/baselines/reference/computedPropertyNames33_ES5.js b/tests/baselines/reference/computedPropertyNames33_ES5.js index 8db62818e22..e6d46b03c10 100644 --- a/tests/baselines/reference/computedPropertyNames33_ES5.js +++ b/tests/baselines/reference/computedPropertyNames33_ES5.js @@ -17,8 +17,7 @@ var C = (function () { C.prototype.bar = function () { var obj = (_a = {}, _a[foo()] = function () { }, - _a - ); + _a); return 0; var _a; }; diff --git a/tests/baselines/reference/computedPropertyNames34_ES5.js b/tests/baselines/reference/computedPropertyNames34_ES5.js index fa0af2897f7..3109c400422 100644 --- a/tests/baselines/reference/computedPropertyNames34_ES5.js +++ b/tests/baselines/reference/computedPropertyNames34_ES5.js @@ -17,8 +17,7 @@ var C = (function () { C.bar = function () { var obj = (_a = {}, _a[foo()] = function () { }, - _a - ); + _a); return 0; var _a; }; diff --git a/tests/baselines/reference/computedPropertyNames46_ES5.js b/tests/baselines/reference/computedPropertyNames46_ES5.js index 307dadcbe91..815f5769f3b 100644 --- a/tests/baselines/reference/computedPropertyNames46_ES5.js +++ b/tests/baselines/reference/computedPropertyNames46_ES5.js @@ -6,6 +6,5 @@ var o = { //// [computedPropertyNames46_ES5.js] var o = (_a = {}, _a["" || 0] = 0, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames47_ES5.js b/tests/baselines/reference/computedPropertyNames47_ES5.js index d03b614b29b..a2fff2110b4 100644 --- a/tests/baselines/reference/computedPropertyNames47_ES5.js +++ b/tests/baselines/reference/computedPropertyNames47_ES5.js @@ -16,6 +16,5 @@ var E2; })(E2 || (E2 = {})); var o = (_a = {}, _a[E1.x || E2.x] = 0, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames48_ES5.js b/tests/baselines/reference/computedPropertyNames48_ES5.js index 15123a98f30..55b08ef8301 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES5.js +++ b/tests/baselines/reference/computedPropertyNames48_ES5.js @@ -25,14 +25,11 @@ var E; var a; extractIndexer((_a = {}, _a[a] = "", - _a -)); // Should return string + _a)); // Should return string extractIndexer((_b = {}, _b[E.x] = "", - _b -)); // Should return string + _b)); // Should return string extractIndexer((_c = {}, _c["" || 0] = "", - _c -)); // Should return any (widened form of undefined) + _c)); // Should return any (widened form of undefined) var _a, _b, _c; diff --git a/tests/baselines/reference/computedPropertyNames49_ES5.js b/tests/baselines/reference/computedPropertyNames49_ES5.js index 3427ea665a0..12c3430fbe9 100644 --- a/tests/baselines/reference/computedPropertyNames49_ES5.js +++ b/tests/baselines/reference/computedPropertyNames49_ES5.js @@ -62,6 +62,5 @@ var x = (_a = { }), , _a.p2 = 20, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames4_ES5.js b/tests/baselines/reference/computedPropertyNames4_ES5.js index f91476c79c1..ac0fa8ec937 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES5.js +++ b/tests/baselines/reference/computedPropertyNames4_ES5.js @@ -32,6 +32,5 @@ var v = (_a = {}, _a[true] = 0, _a["hello bye"] = 0, _a["hello " + a + " bye"] = 0, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames50_ES5.js b/tests/baselines/reference/computedPropertyNames50_ES5.js index a74561295be..db9a03578df 100644 --- a/tests/baselines/reference/computedPropertyNames50_ES5.js +++ b/tests/baselines/reference/computedPropertyNames50_ES5.js @@ -58,6 +58,5 @@ var x = (_a = { }), , _a.p2 = 20, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames5_ES5.js b/tests/baselines/reference/computedPropertyNames5_ES5.js index 58c5af2efa3..3367faa2c20 100644 --- a/tests/baselines/reference/computedPropertyNames5_ES5.js +++ b/tests/baselines/reference/computedPropertyNames5_ES5.js @@ -18,6 +18,5 @@ var v = (_a = {}, _a[{}] = 0, _a[undefined] = undefined, _a[null] = null, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames6_ES5.js b/tests/baselines/reference/computedPropertyNames6_ES5.js index 7e9c6202940..29d035bfcbf 100644 --- a/tests/baselines/reference/computedPropertyNames6_ES5.js +++ b/tests/baselines/reference/computedPropertyNames6_ES5.js @@ -16,6 +16,5 @@ var v = (_a = {}, _a[p1] = 0, _a[p2] = 1, _a[p3] = 2, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames7_ES5.js b/tests/baselines/reference/computedPropertyNames7_ES5.js index 3311ec7e092..01cf2efc030 100644 --- a/tests/baselines/reference/computedPropertyNames7_ES5.js +++ b/tests/baselines/reference/computedPropertyNames7_ES5.js @@ -13,6 +13,5 @@ var E; })(E || (E = {})); var v = (_a = {}, _a[E.member] = 0, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNames8_ES5.js b/tests/baselines/reference/computedPropertyNames8_ES5.js index 6eceee81adb..82d262c7e4e 100644 --- a/tests/baselines/reference/computedPropertyNames8_ES5.js +++ b/tests/baselines/reference/computedPropertyNames8_ES5.js @@ -15,7 +15,6 @@ function f() { var v = (_a = {}, _a[t] = 0, _a[u] = 1, - _a - ); + _a); var _a; } diff --git a/tests/baselines/reference/computedPropertyNames9_ES5.js b/tests/baselines/reference/computedPropertyNames9_ES5.js index 6c1d7bcb4d0..b1ac6c9e3b6 100644 --- a/tests/baselines/reference/computedPropertyNames9_ES5.js +++ b/tests/baselines/reference/computedPropertyNames9_ES5.js @@ -16,6 +16,5 @@ var v = (_a = {}, _a[f("")] = 0, _a[f(0)] = 0, _a[f(true)] = 0, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js index 1f7a3ae123e..d8a33951d4a 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.js @@ -12,6 +12,5 @@ var o: I = { var o = (_a = {}, _a[+"foo"] = "", _a[+"bar"] = 0, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js index c4bfde03531..1ee88351154 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.js @@ -13,6 +13,5 @@ var o: I = { var o = (_a = {}, _a["" + 0] = function (y) { return y.length; }, _a["" + 1] = function (y) { return y.length; }, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js index 945475f8533..6be09e4bef3 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.js @@ -13,6 +13,5 @@ var o: I = { var o = (_a = {}, _a[+"foo"] = function (y) { return y.length; }, _a[+"bar"] = function (y) { return y.length; }, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js index 98042f201e3..b510cda2916 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.js @@ -12,6 +12,5 @@ var o: I = { var o = (_a = {}, _a[+"foo"] = function (y) { return y.length; }, _a[+"bar"] = function (y) { return y.length; }, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js index b17f91be38b..0c319a526f4 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.js @@ -13,6 +13,5 @@ var o: I = { var o = (_a = {}, _a["" + "foo"] = "", _a["" + "bar"] = 0, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js index c7a728e5ef8..51d78be59d4 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.js @@ -13,6 +13,5 @@ var o: I = { var o = (_a = {}, _a[+"foo"] = "", _a[+"bar"] = 0, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js index c97b7c5b1f8..c6ef45d7fab 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.js @@ -21,6 +21,5 @@ foo((_a = { _a["hi" + "bye"] = true, _a[0 + 1] = 0, _a[+"hi"] = [0], - _a -)); + _a)); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js index 9ca7e826aa7..9caf5f2aebf 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.js @@ -21,6 +21,5 @@ foo((_a = { _a["hi" + "bye"] = true, _a[0 + 1] = 0, _a[+"hi"] = [0], - _a -)); + _a)); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js index 419ea906550..24f6218864c 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.js @@ -13,6 +13,5 @@ var o: I = { var o = (_a = {}, _a["" + "foo"] = "", _a["" + "bar"] = 0, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js b/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js index d3beb8b8deb..340802da2af 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.js @@ -13,6 +13,5 @@ var o: I = { var o = (_a = {}, _a[+"foo"] = "", _a[+"bar"] = 0, - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js index e77eb79dc70..c903b864829 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.js @@ -20,8 +20,7 @@ var v = (_a = {}, enumerable: true, configurable: true }), - _a -); + _a); var _a; diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js index 39e393c46cc..972aaf9b52f 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js @@ -10,7 +10,6 @@ var v = (_a = {}, _a["hello"] = function () { debugger; }, - _a -); + _a); var _a; //# sourceMappingURL=computedPropertyNamesSourceMap2_ES5.js.map \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map index baf1e998efd..bdc21497651 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.js.map @@ -1,2 +1,2 @@ //// [computedPropertyNamesSourceMap2_ES5.js.map] -{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG;IACJ,GAAC,OAAO,CAAC,GAAT;QACI,QAAQ,CAAC;IACb,CAAC;;CACJ,CAAA"} \ No newline at end of file +{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG;IACJ,GAAC,OAAO,CAAC,GAAT;QACI,QAAQ,CAAC;IACb,CAAC;OACJ,CAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt index f6501777985..0535196f923 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.sourcemap.txt @@ -56,23 +56,21 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts >>> }, 1 >^^^^ 2 > ^ -3 > ^^-> +3 > ^^^^-> 1 > > 2 > } 1 >Emitted(4, 5) Source(4, 5) + SourceIndex(0) 2 >Emitted(4, 6) Source(4, 6) + SourceIndex(0) --- ->>> _a ->>>); -1->^ -2 > ^ -3 > ^^^^^^-> +>>> _a); +1->^^^^^^^ +2 > ^ 1-> >} -2 > -1->Emitted(6, 2) Source(5, 2) + SourceIndex(0) -2 >Emitted(6, 3) Source(5, 2) + SourceIndex(0) +2 > +1->Emitted(5, 8) Source(5, 2) + SourceIndex(0) +2 >Emitted(5, 9) Source(5, 2) + SourceIndex(0) --- >>>var _a; >>>//# sourceMappingURL=computedPropertyNamesSourceMap2_ES5.js.map \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.js b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.js index 11081be4fb3..2c8efdd424a 100644 --- a/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.js +++ b/tests/baselines/reference/contextuallyTypedClassExpressionMethodDeclaration01.js @@ -61,28 +61,32 @@ function getFoo1() { }()); } function getFoo2() { - return (function () { - function class_2() { - } - class_2.method1 = function (arg) { + return (_a = (function () { + function class_2() { + } + return class_2; + }()), + _a.method1 = function (arg) { arg.numProp = 10; - }; - class_2.method2 = function (arg) { + }, + _a.method2 = function (arg) { arg.strProp = "hello"; - }; - return class_2; - }()); + }, + _a); + var _a; } function getFoo3() { - return (function () { - function class_3() { - } - class_3.method1 = function (arg) { + return (_a = (function () { + function class_3() { + } + return class_3; + }()), + _a.method1 = function (arg) { arg.numProp = 10; - }; - class_3.method2 = function (arg) { + }, + _a.method2 = function (arg) { arg.strProp = "hello"; - }; - return class_3; - }()); + }, + _a); + var _a; } diff --git a/tests/baselines/reference/declFilePrivateStatic.js b/tests/baselines/reference/declFilePrivateStatic.js index 30cd85444cf..fb24bea7660 100644 --- a/tests/baselines/reference/declFilePrivateStatic.js +++ b/tests/baselines/reference/declFilePrivateStatic.js @@ -40,10 +40,10 @@ var C = (function () { enumerable: true, configurable: true }); - C.x = 1; - C.y = 1; return C; }()); +C.x = 1; +C.y = 1; //// [declFilePrivateStatic.d.ts] diff --git a/tests/baselines/reference/decoratorCallGeneric.js b/tests/baselines/reference/decoratorCallGeneric.js index acc9c48297d..a1d470b7063 100644 --- a/tests/baselines/reference/decoratorCallGeneric.js +++ b/tests/baselines/reference/decoratorCallGeneric.js @@ -24,8 +24,8 @@ var C = (function () { function C() { } C.m = function () { }; - C = __decorate([ - dec - ], C); return C; }()); +C = __decorate([ + dec +], C); diff --git a/tests/baselines/reference/decoratorChecksFunctionBodies.js b/tests/baselines/reference/decoratorChecksFunctionBodies.js index d70c4a33460..68dbe6bd1ef 100644 --- a/tests/baselines/reference/decoratorChecksFunctionBodies.js +++ b/tests/baselines/reference/decoratorChecksFunctionBodies.js @@ -30,12 +30,12 @@ var A = (function () { } A.prototype.m = function () { }; - __decorate([ - (function (x, p) { - var a = 3; - func(a); - return x; - }) - ], A.prototype, "m", null); return A; }()); +__decorate([ + (function (x, p) { + var a = 3; + func(a); + return x; + }) +], A.prototype, "m", null); diff --git a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js index 92dcc1f836c..28b620a3e8c 100644 --- a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js +++ b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.js @@ -45,8 +45,8 @@ var Wat = (function () { Wat.whatever = function () { // ... }; - __decorate([ - filter(function () { return a_1.test == 'abc'; }) - ], Wat, "whatever", null); return Wat; }()); +__decorate([ + filter(function () { return a_1.test == 'abc'; }) +], Wat, "whatever", null); diff --git a/tests/baselines/reference/decoratorMetadata.js b/tests/baselines/reference/decoratorMetadata.js index 2f360df0618..d95658c7f18 100644 --- a/tests/baselines/reference/decoratorMetadata.js +++ b/tests/baselines/reference/decoratorMetadata.js @@ -45,15 +45,15 @@ var MyComponent = (function () { } MyComponent.prototype.method = function (x) { }; - __decorate([ - decorator, - __metadata('design:type', Function), - __metadata('design:paramtypes', [Object]), - __metadata('design:returntype', void 0) - ], MyComponent.prototype, "method", null); - MyComponent = __decorate([ - decorator, - __metadata('design:paramtypes', [service_1.default]) - ], MyComponent); return MyComponent; }()); +__decorate([ + decorator, + __metadata('design:type', Function), + __metadata('design:paramtypes', [Object]), + __metadata('design:returntype', void 0) +], MyComponent.prototype, "method", null); +MyComponent = __decorate([ + decorator, + __metadata('design:paramtypes', [service_1.default]) +], MyComponent); diff --git a/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js b/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js index f5048ead631..e5127987d53 100644 --- a/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js +++ b/tests/baselines/reference/decoratorMetadataForMethodWithNoReturnTypeAnnotation01.js @@ -20,11 +20,11 @@ var MyClass = (function () { } MyClass.prototype.doSomething = function () { }; - __decorate([ - decorator, - __metadata('design:type', Function), - __metadata('design:paramtypes', []), - __metadata('design:returntype', void 0) - ], MyClass.prototype, "doSomething", null); return MyClass; }()); +__decorate([ + decorator, + __metadata('design:type', Function), + __metadata('design:paramtypes', []), + __metadata('design:returntype', void 0) +], MyClass.prototype, "doSomething", null); diff --git a/tests/baselines/reference/decoratorMetadataOnInferredType.js b/tests/baselines/reference/decoratorMetadataOnInferredType.js index 5a39a6ce42c..47b6c45e806 100644 --- a/tests/baselines/reference/decoratorMetadataOnInferredType.js +++ b/tests/baselines/reference/decoratorMetadataOnInferredType.js @@ -31,10 +31,10 @@ var B = (function () { function B() { this.x = new A(); } - __decorate([ - decorator, - __metadata('design:type', Object) - ], B.prototype, "x", void 0); return B; }()); +__decorate([ + decorator, + __metadata('design:type', Object) +], B.prototype, "x", void 0); exports.B = B; diff --git a/tests/baselines/reference/decoratorMetadataWithConstructorType.js b/tests/baselines/reference/decoratorMetadataWithConstructorType.js index 39e8d1811aa..0559e62754c 100644 --- a/tests/baselines/reference/decoratorMetadataWithConstructorType.js +++ b/tests/baselines/reference/decoratorMetadataWithConstructorType.js @@ -31,10 +31,10 @@ var B = (function () { function B() { this.x = new A(); } - __decorate([ - decorator, - __metadata('design:type', A) - ], B.prototype, "x", void 0); return B; }()); +__decorate([ + decorator, + __metadata('design:type', A) +], B.prototype, "x", void 0); exports.B = B; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js index b549d28c7f1..a0bc68bd8d8 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision.js @@ -44,10 +44,10 @@ var MyClass = (function () { this.db = db; this.db.doSomething(); } - MyClass = __decorate([ - someDecorator, - __metadata('design:paramtypes', [db_1.db]) - ], MyClass); return MyClass; }()); +MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db_1.db]) +], MyClass); exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js index acd86e78d76..49a2983ce70 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision2.js @@ -44,10 +44,10 @@ var MyClass = (function () { this.db = db; this.db.doSomething(); } - MyClass = __decorate([ - someDecorator, - __metadata('design:paramtypes', [db_1.db]) - ], MyClass); return MyClass; }()); +MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db_1.db]) +], MyClass); exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js index 2acd829c107..f3c1d1b5da5 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision3.js @@ -44,10 +44,10 @@ var MyClass = (function () { this.db = db; this.db.doSomething(); } - MyClass = __decorate([ - someDecorator, - __metadata('design:paramtypes', [db.db]) - ], MyClass); return MyClass; }()); +MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db.db]) +], MyClass); exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js index 4af0beeddcb..3448352eaaf 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js @@ -44,10 +44,10 @@ var MyClass = (function () { this.db = db; this.db.doSomething(); } - MyClass = __decorate([ - someDecorator, - __metadata('design:paramtypes', [Object]) - ], MyClass); return MyClass; }()); +MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [Object]) +], MyClass); exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js index f1537e3b447..8eae92ec4d1 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js @@ -45,10 +45,10 @@ var MyClass = (function () { this.db = db; this.db.doSomething(); } - MyClass = __decorate([ - someDecorator, - __metadata('design:paramtypes', [db_1.default]) - ], MyClass); return MyClass; }()); +MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db_1.default]) +], MyClass); exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js index 7ef2c288810..26e714c16a1 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js @@ -45,10 +45,10 @@ var MyClass = (function () { this.db = db; this.db.doSomething(); } - MyClass = __decorate([ - someDecorator, - __metadata('design:paramtypes', [db_1.default]) - ], MyClass); return MyClass; }()); +MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [db_1.default]) +], MyClass); exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js index f8469cdd6a4..1d3b8a92349 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js @@ -45,10 +45,10 @@ var MyClass = (function () { this.db = db; this.db.doSomething(); } - MyClass = __decorate([ - someDecorator, - __metadata('design:paramtypes', [Object]) - ], MyClass); return MyClass; }()); +MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [Object]) +], MyClass); exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js index f1885ccfaec..910008b9c27 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision8.js @@ -44,10 +44,10 @@ var MyClass = (function () { this.db = db; this.db.doSomething(); } - MyClass = __decorate([ - someDecorator, - __metadata('design:paramtypes', [database.db]) - ], MyClass); return MyClass; }()); +MyClass = __decorate([ + someDecorator, + __metadata('design:paramtypes', [database.db]) +], MyClass); exports.MyClass = MyClass; diff --git a/tests/baselines/reference/decoratorOnClass1.js b/tests/baselines/reference/decoratorOnClass1.js index 7ea46b4698f..5cff4c2649c 100644 --- a/tests/baselines/reference/decoratorOnClass1.js +++ b/tests/baselines/reference/decoratorOnClass1.js @@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var C = (function () { function C() { } - C = __decorate([ - dec - ], C); return C; }()); +C = __decorate([ + dec +], C); diff --git a/tests/baselines/reference/decoratorOnClass2.js b/tests/baselines/reference/decoratorOnClass2.js index 3f24c7ae55b..4d9c2007ad0 100644 --- a/tests/baselines/reference/decoratorOnClass2.js +++ b/tests/baselines/reference/decoratorOnClass2.js @@ -16,9 +16,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var C = (function () { function C() { } - C = __decorate([ - dec - ], C); return C; }()); +C = __decorate([ + dec +], C); exports.C = C; diff --git a/tests/baselines/reference/decoratorOnClass3.js b/tests/baselines/reference/decoratorOnClass3.js index 5a3601fc1f3..fd09a6d8de5 100644 --- a/tests/baselines/reference/decoratorOnClass3.js +++ b/tests/baselines/reference/decoratorOnClass3.js @@ -16,8 +16,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var C = (function () { function C() { } - C = __decorate([ - dec - ], C); return C; }()); +C = __decorate([ + dec +], C); diff --git a/tests/baselines/reference/decoratorOnClass4.js b/tests/baselines/reference/decoratorOnClass4.js index adbe30db662..daf19e20327 100644 --- a/tests/baselines/reference/decoratorOnClass4.js +++ b/tests/baselines/reference/decoratorOnClass4.js @@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var C = (function () { function C() { } - C = __decorate([ - dec() - ], C); return C; }()); +C = __decorate([ + dec() +], C); diff --git a/tests/baselines/reference/decoratorOnClass5.js b/tests/baselines/reference/decoratorOnClass5.js index 6741b26373b..70fc5515140 100644 --- a/tests/baselines/reference/decoratorOnClass5.js +++ b/tests/baselines/reference/decoratorOnClass5.js @@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var C = (function () { function C() { } - C = __decorate([ - dec() - ], C); return C; }()); +C = __decorate([ + dec() +], C); diff --git a/tests/baselines/reference/decoratorOnClass8.js b/tests/baselines/reference/decoratorOnClass8.js index e5cd8812ea7..ae50ab75ab8 100644 --- a/tests/baselines/reference/decoratorOnClass8.js +++ b/tests/baselines/reference/decoratorOnClass8.js @@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var C = (function () { function C() { } - C = __decorate([ - dec() - ], C); return C; }()); +C = __decorate([ + dec() +], C); diff --git a/tests/baselines/reference/decoratorOnClassAccessor1.js b/tests/baselines/reference/decoratorOnClassAccessor1.js index cf989705b79..27966350fae 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor1.js +++ b/tests/baselines/reference/decoratorOnClassAccessor1.js @@ -20,8 +20,8 @@ var C = (function () { enumerable: true, configurable: true }); - __decorate([ - dec - ], C.prototype, "accessor", null); return C; }()); +__decorate([ + dec +], C.prototype, "accessor", null); diff --git a/tests/baselines/reference/decoratorOnClassAccessor2.js b/tests/baselines/reference/decoratorOnClassAccessor2.js index 9e9455b4380..57cb3b50461 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor2.js +++ b/tests/baselines/reference/decoratorOnClassAccessor2.js @@ -20,8 +20,8 @@ var C = (function () { enumerable: true, configurable: true }); - __decorate([ - dec - ], C.prototype, "accessor", null); return C; }()); +__decorate([ + dec +], C.prototype, "accessor", null); diff --git a/tests/baselines/reference/decoratorOnClassAccessor3.js b/tests/baselines/reference/decoratorOnClassAccessor3.js index 8a27914e0c8..c02f984e70a 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor3.js +++ b/tests/baselines/reference/decoratorOnClassAccessor3.js @@ -20,8 +20,8 @@ var C = (function () { enumerable: true, configurable: true }); - __decorate([ - dec - ], C.prototype, "accessor", null); return C; }()); +__decorate([ + dec +], C.prototype, "accessor", null); diff --git a/tests/baselines/reference/decoratorOnClassAccessor4.js b/tests/baselines/reference/decoratorOnClassAccessor4.js index 85b35e95cef..0e0af58f526 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor4.js +++ b/tests/baselines/reference/decoratorOnClassAccessor4.js @@ -20,8 +20,8 @@ var C = (function () { enumerable: true, configurable: true }); - __decorate([ - dec - ], C.prototype, "accessor", null); return C; }()); +__decorate([ + dec +], C.prototype, "accessor", null); diff --git a/tests/baselines/reference/decoratorOnClassAccessor5.js b/tests/baselines/reference/decoratorOnClassAccessor5.js index 12ec7a08adc..c7d5d109cc0 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor5.js +++ b/tests/baselines/reference/decoratorOnClassAccessor5.js @@ -20,8 +20,8 @@ var C = (function () { enumerable: true, configurable: true }); - __decorate([ - dec - ], C.prototype, "accessor", null); return C; }()); +__decorate([ + dec +], C.prototype, "accessor", null); diff --git a/tests/baselines/reference/decoratorOnClassAccessor6.js b/tests/baselines/reference/decoratorOnClassAccessor6.js index d5477deb5af..8ac40e72299 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor6.js +++ b/tests/baselines/reference/decoratorOnClassAccessor6.js @@ -20,8 +20,8 @@ var C = (function () { enumerable: true, configurable: true }); - __decorate([ - dec - ], C.prototype, "accessor", null); return C; }()); +__decorate([ + dec +], C.prototype, "accessor", null); diff --git a/tests/baselines/reference/decoratorOnClassConstructorParameter1.js b/tests/baselines/reference/decoratorOnClassConstructorParameter1.js index fe04f569e30..176e2309ae0 100644 --- a/tests/baselines/reference/decoratorOnClassConstructorParameter1.js +++ b/tests/baselines/reference/decoratorOnClassConstructorParameter1.js @@ -18,8 +18,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { var C = (function () { function C(p) { } - C = __decorate([ - __param(0, dec) - ], C); return C; }()); +C = __decorate([ + __param(0, dec) +], C); diff --git a/tests/baselines/reference/decoratorOnClassConstructorParameter4.js b/tests/baselines/reference/decoratorOnClassConstructorParameter4.js index 8d02bd467d6..e14f0358808 100644 --- a/tests/baselines/reference/decoratorOnClassConstructorParameter4.js +++ b/tests/baselines/reference/decoratorOnClassConstructorParameter4.js @@ -18,8 +18,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) { var C = (function () { function C(public, p) { } - C = __decorate([ - __param(1, dec) - ], C); return C; }()); +C = __decorate([ + __param(1, dec) +], C); diff --git a/tests/baselines/reference/decoratorOnClassMethod1.js b/tests/baselines/reference/decoratorOnClassMethod1.js index ef029b84543..b93d7f88771 100644 --- a/tests/baselines/reference/decoratorOnClassMethod1.js +++ b/tests/baselines/reference/decoratorOnClassMethod1.js @@ -16,8 +16,8 @@ var C = (function () { function C() { } C.prototype.method = function () { }; - __decorate([ - dec - ], C.prototype, "method", null); return C; }()); +__decorate([ + dec +], C.prototype, "method", null); diff --git a/tests/baselines/reference/decoratorOnClassMethod10.js b/tests/baselines/reference/decoratorOnClassMethod10.js index f90251d6196..bfa57f0aeb7 100644 --- a/tests/baselines/reference/decoratorOnClassMethod10.js +++ b/tests/baselines/reference/decoratorOnClassMethod10.js @@ -16,8 +16,8 @@ var C = (function () { function C() { } C.prototype.method = function () { }; - __decorate([ - dec - ], C.prototype, "method", null); return C; }()); +__decorate([ + dec +], C.prototype, "method", null); diff --git a/tests/baselines/reference/decoratorOnClassMethod11.js b/tests/baselines/reference/decoratorOnClassMethod11.js index f1589a39286..c703459b88d 100644 --- a/tests/baselines/reference/decoratorOnClassMethod11.js +++ b/tests/baselines/reference/decoratorOnClassMethod11.js @@ -22,9 +22,9 @@ var M; } C.prototype.decorator = function (target, key) { }; C.prototype.method = function () { }; - __decorate([ - this.decorator - ], C.prototype, "method", null); return C; }()); + __decorate([ + this.decorator + ], C.prototype, "method", null); })(M || (M = {})); diff --git a/tests/baselines/reference/decoratorOnClassMethod12.js b/tests/baselines/reference/decoratorOnClassMethod12.js index 0650f1d00ee..6e9b9763a3a 100644 --- a/tests/baselines/reference/decoratorOnClassMethod12.js +++ b/tests/baselines/reference/decoratorOnClassMethod12.js @@ -35,9 +35,9 @@ var M; _super.apply(this, arguments); } C.prototype.method = function () { }; - __decorate([ - _super.decorator - ], C.prototype, "method", null); return C; }(S)); + __decorate([ + _super.decorator + ], C.prototype, "method", null); })(M || (M = {})); diff --git a/tests/baselines/reference/decoratorOnClassMethod2.js b/tests/baselines/reference/decoratorOnClassMethod2.js index 5db2922ed71..98ad8ad43ad 100644 --- a/tests/baselines/reference/decoratorOnClassMethod2.js +++ b/tests/baselines/reference/decoratorOnClassMethod2.js @@ -16,8 +16,8 @@ var C = (function () { function C() { } C.prototype.method = function () { }; - __decorate([ - dec - ], C.prototype, "method", null); return C; }()); +__decorate([ + dec +], C.prototype, "method", null); diff --git a/tests/baselines/reference/decoratorOnClassMethod3.js b/tests/baselines/reference/decoratorOnClassMethod3.js index 30f527368f2..4a5943681d4 100644 --- a/tests/baselines/reference/decoratorOnClassMethod3.js +++ b/tests/baselines/reference/decoratorOnClassMethod3.js @@ -16,8 +16,8 @@ var C = (function () { function C() { } C.prototype.method = function () { }; - __decorate([ - dec - ], C.prototype, "method", null); return C; }()); +__decorate([ + dec +], C.prototype, "method", null); diff --git a/tests/baselines/reference/decoratorOnClassMethod8.js b/tests/baselines/reference/decoratorOnClassMethod8.js index bf8c06d9b90..c1ad826cab0 100644 --- a/tests/baselines/reference/decoratorOnClassMethod8.js +++ b/tests/baselines/reference/decoratorOnClassMethod8.js @@ -16,8 +16,8 @@ var C = (function () { function C() { } C.prototype.method = function () { }; - __decorate([ - dec - ], C.prototype, "method", null); return C; }()); +__decorate([ + dec +], C.prototype, "method", null); diff --git a/tests/baselines/reference/decoratorOnClassMethodOverload2.js b/tests/baselines/reference/decoratorOnClassMethodOverload2.js index eafa5da7110..db077dd7b51 100644 --- a/tests/baselines/reference/decoratorOnClassMethodOverload2.js +++ b/tests/baselines/reference/decoratorOnClassMethodOverload2.js @@ -18,8 +18,8 @@ var C = (function () { function C() { } C.prototype.method = function () { }; - __decorate([ - dec - ], C.prototype, "method", null); return C; }()); +__decorate([ + dec +], C.prototype, "method", null); diff --git a/tests/baselines/reference/decoratorOnClassMethodParameter1.js b/tests/baselines/reference/decoratorOnClassMethodParameter1.js index efb1e4abff2..d5d8599d7a8 100644 --- a/tests/baselines/reference/decoratorOnClassMethodParameter1.js +++ b/tests/baselines/reference/decoratorOnClassMethodParameter1.js @@ -19,8 +19,8 @@ var C = (function () { function C() { } C.prototype.method = function (p) { }; - __decorate([ - __param(0, dec) - ], C.prototype, "method", null); return C; }()); +__decorate([ + __param(0, dec) +], C.prototype, "method", null); diff --git a/tests/baselines/reference/decoratorOnClassProperty1.js b/tests/baselines/reference/decoratorOnClassProperty1.js index 65a399332f1..6547e0bdb18 100644 --- a/tests/baselines/reference/decoratorOnClassProperty1.js +++ b/tests/baselines/reference/decoratorOnClassProperty1.js @@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var C = (function () { function C() { } - __decorate([ - dec - ], C.prototype, "prop", void 0); return C; }()); +__decorate([ + dec +], C.prototype, "prop", void 0); diff --git a/tests/baselines/reference/decoratorOnClassProperty10.js b/tests/baselines/reference/decoratorOnClassProperty10.js index 9df40eaf83a..174f26a315a 100644 --- a/tests/baselines/reference/decoratorOnClassProperty10.js +++ b/tests/baselines/reference/decoratorOnClassProperty10.js @@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var C = (function () { function C() { } - __decorate([ - dec() - ], C.prototype, "prop", void 0); return C; }()); +__decorate([ + dec() +], C.prototype, "prop", void 0); diff --git a/tests/baselines/reference/decoratorOnClassProperty11.js b/tests/baselines/reference/decoratorOnClassProperty11.js index 8b771caf8b5..c901637402d 100644 --- a/tests/baselines/reference/decoratorOnClassProperty11.js +++ b/tests/baselines/reference/decoratorOnClassProperty11.js @@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var C = (function () { function C() { } - __decorate([ - dec - ], C.prototype, "prop", void 0); return C; }()); +__decorate([ + dec +], C.prototype, "prop", void 0); diff --git a/tests/baselines/reference/decoratorOnClassProperty2.js b/tests/baselines/reference/decoratorOnClassProperty2.js index 3ab2b515e3c..ceaf43caa59 100644 --- a/tests/baselines/reference/decoratorOnClassProperty2.js +++ b/tests/baselines/reference/decoratorOnClassProperty2.js @@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var C = (function () { function C() { } - __decorate([ - dec - ], C.prototype, "prop", void 0); return C; }()); +__decorate([ + dec +], C.prototype, "prop", void 0); diff --git a/tests/baselines/reference/decoratorOnClassProperty3.js b/tests/baselines/reference/decoratorOnClassProperty3.js index 9c0d3f90e42..8436be93968 100644 --- a/tests/baselines/reference/decoratorOnClassProperty3.js +++ b/tests/baselines/reference/decoratorOnClassProperty3.js @@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var C = (function () { function C() { } - __decorate([ - dec - ], C.prototype, "prop", void 0); return C; }()); +__decorate([ + dec +], C.prototype, "prop", void 0); diff --git a/tests/baselines/reference/decoratorOnClassProperty6.js b/tests/baselines/reference/decoratorOnClassProperty6.js index 823a652af24..c7f5490c648 100644 --- a/tests/baselines/reference/decoratorOnClassProperty6.js +++ b/tests/baselines/reference/decoratorOnClassProperty6.js @@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var C = (function () { function C() { } - __decorate([ - dec - ], C.prototype, "prop", void 0); return C; }()); +__decorate([ + dec +], C.prototype, "prop", void 0); diff --git a/tests/baselines/reference/decoratorOnClassProperty7.js b/tests/baselines/reference/decoratorOnClassProperty7.js index 134f35022e0..828d548ff6b 100644 --- a/tests/baselines/reference/decoratorOnClassProperty7.js +++ b/tests/baselines/reference/decoratorOnClassProperty7.js @@ -15,8 +15,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var C = (function () { function C() { } - __decorate([ - dec - ], C.prototype, "prop", void 0); return C; }()); +__decorate([ + dec +], C.prototype, "prop", void 0); diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js index e043ee8a5c5..50408d3bee7 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js @@ -77,6 +77,6 @@ var Derived = (function (_super) { enumerable: true, configurable: true }); - Derived.a = _super.call(this); return Derived; }(Base)); +Derived.a = _super.call(this); diff --git a/tests/baselines/reference/errorSuperCalls.js b/tests/baselines/reference/errorSuperCalls.js index 4cc6a4d968f..097b16b3024 100644 --- a/tests/baselines/reference/errorSuperCalls.js +++ b/tests/baselines/reference/errorSuperCalls.js @@ -119,10 +119,10 @@ var NoBase = (function () { enumerable: true, configurable: true }); - //super call in static class member initializer with no base type - NoBase.k = _super.call(this); return NoBase; }()); +//super call in static class member initializer with no base type +NoBase.k = _super.call(this); var Base = (function () { function Base() { } diff --git a/tests/baselines/reference/errorSuperPropertyAccess.js b/tests/baselines/reference/errorSuperPropertyAccess.js index cf6ed2598ea..dbfbdb46940 100644 --- a/tests/baselines/reference/errorSuperPropertyAccess.js +++ b/tests/baselines/reference/errorSuperPropertyAccess.js @@ -175,10 +175,10 @@ var SomeBase = (function () { SomeBase.prototype.publicFunc = function () { }; SomeBase.privateStaticFunc = function () { }; SomeBase.publicStaticFunc = function () { }; - SomeBase.privateStaticMember = 0; - SomeBase.publicStaticMember = 0; return SomeBase; }()); +SomeBase.privateStaticMember = 0; +SomeBase.publicStaticMember = 0; //super.publicInstanceMemberNotFunction in constructor of derived class //super.publicInstanceMemberNotFunction in instance member function of derived class //super.publicInstanceMemberNotFunction in instance member accessor(get and set) of derived class diff --git a/tests/baselines/reference/es3defaultAliasIsQuoted.js b/tests/baselines/reference/es3defaultAliasIsQuoted.js index ac6a0bd24da..89fd0c47a7e 100644 --- a/tests/baselines/reference/es3defaultAliasIsQuoted.js +++ b/tests/baselines/reference/es3defaultAliasIsQuoted.js @@ -19,9 +19,9 @@ assert(Foo.CONSTANT === "Foo"); var Foo = (function () { function Foo() { } - Foo.CONSTANT = "Foo"; return Foo; }()); +Foo.CONSTANT = "Foo"; exports.Foo = Foo; function assert(value) { if (!value) diff --git a/tests/baselines/reference/es6ClassTest.js b/tests/baselines/reference/es6ClassTest.js index 365e91321a4..a722cce1670 100644 --- a/tests/baselines/reference/es6ClassTest.js +++ b/tests/baselines/reference/es6ClassTest.js @@ -113,9 +113,9 @@ var Foo = (function (_super) { } Foo.prototype.bar = function () { return 0; }; Foo.prototype.boo = function (x) { return x; }; - Foo.statVal = 0; return Foo; }(Bar)); +Foo.statVal = 0; var f = new Foo(); //class GetSetMonster { // // attack(target) { diff --git a/tests/baselines/reference/es6ClassTest2.js b/tests/baselines/reference/es6ClassTest2.js index 86ff00121cf..1881e6b8c87 100644 --- a/tests/baselines/reference/es6ClassTest2.js +++ b/tests/baselines/reference/es6ClassTest2.js @@ -283,9 +283,9 @@ var Statics = (function () { Statics.baz = function () { return ""; }; - Statics.foo = 1; return Statics; }()); +Statics.foo = 1; var stat = new Statics(); var ImplementsInterface = (function () { function ImplementsInterface() { diff --git a/tests/baselines/reference/generatedContextualTyping.js b/tests/baselines/reference/generatedContextualTyping.js index 8093c8bec41..e5488121d34 100644 --- a/tests/baselines/reference/generatedContextualTyping.js +++ b/tests/baselines/reference/generatedContextualTyping.js @@ -612,219 +612,219 @@ var x48 = (function () { var x49 = (function () { function x49() { } - x49.member = function () { return [d1, d2]; }; return x49; }()); +x49.member = function () { return [d1, d2]; }; var x50 = (function () { function x50() { } - x50.member = function () { return [d1, d2]; }; return x50; }()); +x50.member = function () { return [d1, d2]; }; var x51 = (function () { function x51() { } - x51.member = function named() { return [d1, d2]; }; return x51; }()); +x51.member = function named() { return [d1, d2]; }; var x52 = (function () { function x52() { } - x52.member = function () { return [d1, d2]; }; return x52; }()); +x52.member = function () { return [d1, d2]; }; var x53 = (function () { function x53() { } - x53.member = function () { return [d1, d2]; }; return x53; }()); +x53.member = function () { return [d1, d2]; }; var x54 = (function () { function x54() { } - x54.member = function named() { return [d1, d2]; }; return x54; }()); +x54.member = function named() { return [d1, d2]; }; var x55 = (function () { function x55() { } - x55.member = [d1, d2]; return x55; }()); +x55.member = [d1, d2]; var x56 = (function () { function x56() { } - x56.member = [d1, d2]; return x56; }()); +x56.member = [d1, d2]; var x57 = (function () { function x57() { } - x57.member = [d1, d2]; return x57; }()); +x57.member = [d1, d2]; var x58 = (function () { function x58() { } - x58.member = { n: [d1, d2] }; return x58; }()); +x58.member = { n: [d1, d2] }; var x59 = (function () { function x59() { } - x59.member = function (n) { var n; return null; }; return x59; }()); +x59.member = function (n) { var n; return null; }; var x60 = (function () { function x60() { } - x60.member = { func: function (n) { return [d1, d2]; } }; return x60; }()); +x60.member = { func: function (n) { return [d1, d2]; } }; var x61 = (function () { function x61() { } - x61.member = function () { return [d1, d2]; }; return x61; }()); +x61.member = function () { return [d1, d2]; }; var x62 = (function () { function x62() { } - x62.member = function () { return [d1, d2]; }; return x62; }()); +x62.member = function () { return [d1, d2]; }; var x63 = (function () { function x63() { } - x63.member = function named() { return [d1, d2]; }; return x63; }()); +x63.member = function named() { return [d1, d2]; }; var x64 = (function () { function x64() { } - x64.member = function () { return [d1, d2]; }; return x64; }()); +x64.member = function () { return [d1, d2]; }; var x65 = (function () { function x65() { } - x65.member = function () { return [d1, d2]; }; return x65; }()); +x65.member = function () { return [d1, d2]; }; var x66 = (function () { function x66() { } - x66.member = function named() { return [d1, d2]; }; return x66; }()); +x66.member = function named() { return [d1, d2]; }; var x67 = (function () { function x67() { } - x67.member = [d1, d2]; return x67; }()); +x67.member = [d1, d2]; var x68 = (function () { function x68() { } - x68.member = [d1, d2]; return x68; }()); +x68.member = [d1, d2]; var x69 = (function () { function x69() { } - x69.member = [d1, d2]; return x69; }()); +x69.member = [d1, d2]; var x70 = (function () { function x70() { } - x70.member = { n: [d1, d2] }; return x70; }()); +x70.member = { n: [d1, d2] }; var x71 = (function () { function x71() { } - x71.member = function (n) { var n; return null; }; return x71; }()); +x71.member = function (n) { var n; return null; }; var x72 = (function () { function x72() { } - x72.member = { func: function (n) { return [d1, d2]; } }; return x72; }()); +x72.member = { func: function (n) { return [d1, d2]; } }; var x73 = (function () { function x73() { } - x73.member = function () { return [d1, d2]; }; return x73; }()); +x73.member = function () { return [d1, d2]; }; var x74 = (function () { function x74() { } - x74.member = function () { return [d1, d2]; }; return x74; }()); +x74.member = function () { return [d1, d2]; }; var x75 = (function () { function x75() { } - x75.member = function named() { return [d1, d2]; }; return x75; }()); +x75.member = function named() { return [d1, d2]; }; var x76 = (function () { function x76() { } - x76.member = function () { return [d1, d2]; }; return x76; }()); +x76.member = function () { return [d1, d2]; }; var x77 = (function () { function x77() { } - x77.member = function () { return [d1, d2]; }; return x77; }()); +x77.member = function () { return [d1, d2]; }; var x78 = (function () { function x78() { } - x78.member = function named() { return [d1, d2]; }; return x78; }()); +x78.member = function named() { return [d1, d2]; }; var x79 = (function () { function x79() { } - x79.member = [d1, d2]; return x79; }()); +x79.member = [d1, d2]; var x80 = (function () { function x80() { } - x80.member = [d1, d2]; return x80; }()); +x80.member = [d1, d2]; var x81 = (function () { function x81() { } - x81.member = [d1, d2]; return x81; }()); +x81.member = [d1, d2]; var x82 = (function () { function x82() { } - x82.member = { n: [d1, d2] }; return x82; }()); +x82.member = { n: [d1, d2] }; var x83 = (function () { function x83() { } - x83.member = function (n) { var n; return null; }; return x83; }()); +x83.member = function (n) { var n; return null; }; var x84 = (function () { function x84() { } - x84.member = { func: function (n) { return [d1, d2]; } }; return x84; }()); +x84.member = { func: function (n) { return [d1, d2]; } }; var x85 = (function () { function x85(parm) { if (parm === void 0) { parm = function () { return [d1, d2]; }; } diff --git a/tests/baselines/reference/genericClassWithStaticsUsingTypeArguments.js b/tests/baselines/reference/genericClassWithStaticsUsingTypeArguments.js index 2039e459572..053fa785ee0 100644 --- a/tests/baselines/reference/genericClassWithStaticsUsingTypeArguments.js +++ b/tests/baselines/reference/genericClassWithStaticsUsingTypeArguments.js @@ -25,9 +25,9 @@ var Foo = (function () { Foo.f = function (xs) { return xs.reverse(); }; - Foo.a = function (n) { }; - Foo.c = []; - Foo.d = false || (function (x) { return x || undefined; })(null); - Foo.e = function (x) { return null; }; return Foo; }()); +Foo.a = function (n) { }; +Foo.c = []; +Foo.d = false || (function (x) { return x || undefined; })(null); +Foo.e = function (x) { return null; }; diff --git a/tests/baselines/reference/gettersAndSetters.js b/tests/baselines/reference/gettersAndSetters.js index 16d66c7dc71..265a1210b16 100644 --- a/tests/baselines/reference/gettersAndSetters.js +++ b/tests/baselines/reference/gettersAndSetters.js @@ -65,9 +65,9 @@ var C = (function () { enumerable: true, configurable: true }); - C.barBack = ""; return C; }()); +C.barBack = ""; var c = new C(); var foo = c.Foo; c.Foo = "foov"; diff --git a/tests/baselines/reference/importImportOnlyModule.js b/tests/baselines/reference/importImportOnlyModule.js index 7b41e4400c5..013999321f9 100644 --- a/tests/baselines/reference/importImportOnlyModule.js +++ b/tests/baselines/reference/importImportOnlyModule.js @@ -22,9 +22,9 @@ define(["require", "exports"], function (require, exports) { function C1() { this.m1 = 42; } - C1.s1 = true; return C1; }()); + C1.s1 = true; exports.C1 = C1; }); //// [foo_1.js] diff --git a/tests/baselines/reference/instanceAndStaticDeclarations1.js b/tests/baselines/reference/instanceAndStaticDeclarations1.js index 093e9c15cc8..bf9b6963bb2 100644 --- a/tests/baselines/reference/instanceAndStaticDeclarations1.js +++ b/tests/baselines/reference/instanceAndStaticDeclarations1.js @@ -25,6 +25,6 @@ var Point = (function () { return Math.sqrt(dx * dx + dy * dy); }; Point.distance = function (p1, p2) { return p1.distance(p2); }; - Point.origin = new Point(0, 0); return Point; }()); +Point.origin = new Point(0, 0); diff --git a/tests/baselines/reference/invalidStaticField.js b/tests/baselines/reference/invalidStaticField.js index dc582e830c7..08a06d5ee27 100644 --- a/tests/baselines/reference/invalidStaticField.js +++ b/tests/baselines/reference/invalidStaticField.js @@ -12,6 +12,6 @@ var A = (function () { var B = (function () { function B() { } - B.NOT_NULL = new B(); return B; }()); +B.NOT_NULL = new B(); diff --git a/tests/baselines/reference/literalsInComputedProperties1.js b/tests/baselines/reference/literalsInComputedProperties1.js index 82a6367e5d2..4c28a5e9083 100644 --- a/tests/baselines/reference/literalsInComputedProperties1.js +++ b/tests/baselines/reference/literalsInComputedProperties1.js @@ -58,8 +58,7 @@ var x = (_a = { _a[2] = 1, _a["3"] = 1, _a["4"] = 1, - _a -); + _a); x[1].toExponential(); x[2].toExponential(); x[3].toExponential(); diff --git a/tests/baselines/reference/missingDecoratorType.js b/tests/baselines/reference/missingDecoratorType.js index 7356be39798..1dcbb3febc5 100644 --- a/tests/baselines/reference/missingDecoratorType.js +++ b/tests/baselines/reference/missingDecoratorType.js @@ -33,8 +33,8 @@ var C = (function () { function C() { } C.prototype.method = function () { }; - __decorate([ - dec - ], C.prototype, "method", null); return C; }()); +__decorate([ + dec +], C.prototype, "method", null); diff --git a/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.js b/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.js index 70eea5b2c5c..211c80bcce8 100644 --- a/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.js +++ b/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.js @@ -10,14 +10,16 @@ function g() { //// [modifierOnClassExpressionMemberInFunction.js] function g() { - var x = (function () { - function C() { - this.prop1 = 1; - } - C.prototype.foo = function () { }; - C.prop2 = 43; - return C; - }()); + var x = (_a = (function () { + function C() { + this.prop1 = 1; + } + C.prototype.foo = function () { }; + return C; + }()), + _a.prop2 = 43, + _a); + var _a; } diff --git a/tests/baselines/reference/noEmitHelpers2.js b/tests/baselines/reference/noEmitHelpers2.js index f3bbfe54896..fc4baf334c3 100644 --- a/tests/baselines/reference/noEmitHelpers2.js +++ b/tests/baselines/reference/noEmitHelpers2.js @@ -12,10 +12,10 @@ class A { var A = (function () { function A(a, b) { } - A = __decorate([ - decorator, - __param(1, decorator), - __metadata('design:paramtypes', [Number, String]) - ], A); return A; }()); +A = __decorate([ + decorator, + __param(1, decorator), + __metadata('design:paramtypes', [Number, String]) +], A); diff --git a/tests/baselines/reference/parserAccessibilityAfterStatic3.js b/tests/baselines/reference/parserAccessibilityAfterStatic3.js index 7a9ae06e439..38202bc5dc8 100644 --- a/tests/baselines/reference/parserAccessibilityAfterStatic3.js +++ b/tests/baselines/reference/parserAccessibilityAfterStatic3.js @@ -9,6 +9,6 @@ static public = 1; var Outer = (function () { function Outer() { } - Outer.public = 1; return Outer; }()); +Outer.public = 1; diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.js b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.js index 9bb4395e556..57d0536e975 100644 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.js +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.js @@ -41,10 +41,10 @@ var Shapes; } // Instance member Point.prototype.getDist = function () { return Math.sqrt(this.x * this.x + this.y * this.y); }; - // Static member - Point.origin = new Point(0, 0); return Point; }()); + // Static member + Point.origin = new Point(0, 0); Shapes.Point = Point; })(Shapes || (Shapes = {})); // Local variables diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.js b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.js index 0ee73b8b1e5..2bb08a14e35 100644 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.js +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.js @@ -42,10 +42,10 @@ var Shapes; } // Instance member Point.prototype.getDist = function () { return Math.sqrt(this.x * this.x + this.y * this.y); }; - // Static member - Point.origin = new Point(0, 0); return Point; }()); + // Static member + Point.origin = new Point(0, 0); Shapes.Point = Point; })(Shapes || (Shapes = {})); // Local variables diff --git a/tests/baselines/reference/parserharness.js b/tests/baselines/reference/parserharness.js index 6b38a8c9e4c..1a525c49d19 100644 --- a/tests/baselines/reference/parserharness.js +++ b/tests/baselines/reference/parserharness.js @@ -2371,11 +2371,11 @@ var Harness; errorHandlerStack[errorHandlerStack.length - 1](e); } }; - // The current stack of Runnable objects - Runnable.currentStack = []; - Runnable.errorHandlerStack = []; return Runnable; }()); + // The current stack of Runnable objects + Runnable.currentStack = []; + Runnable.errorHandlerStack = []; Harness.Runnable = Runnable; var TestCase = (function (_super) { __extends(TestCase, _super); diff --git a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js index 6c2dcf304cf..c139b6279fd 100644 --- a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js +++ b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js @@ -159,12 +159,12 @@ var publicClassWithWithPrivatePropertyTypes = (function () { this.myPublicProperty1 = exporter.createExportedWidget3(); // Error this.myPrivateProperty1 = exporter.createExportedWidget3(); } - publicClassWithWithPrivatePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget1(); // Error - publicClassWithWithPrivatePropertyTypes.myPrivateStaticProperty = exporter.createExportedWidget1(); - publicClassWithWithPrivatePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget3(); // Error - publicClassWithWithPrivatePropertyTypes.myPrivateStaticProperty1 = exporter.createExportedWidget3(); return publicClassWithWithPrivatePropertyTypes; }()); +publicClassWithWithPrivatePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget1(); // Error +publicClassWithWithPrivatePropertyTypes.myPrivateStaticProperty = exporter.createExportedWidget1(); +publicClassWithWithPrivatePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget3(); // Error +publicClassWithWithPrivatePropertyTypes.myPrivateStaticProperty1 = exporter.createExportedWidget3(); exports.publicClassWithWithPrivatePropertyTypes = publicClassWithWithPrivatePropertyTypes; var privateClassWithWithPrivatePropertyTypes = (function () { function privateClassWithWithPrivatePropertyTypes() { @@ -173,12 +173,12 @@ var privateClassWithWithPrivatePropertyTypes = (function () { this.myPublicProperty1 = exporter.createExportedWidget3(); this.myPrivateProperty1 = exporter.createExportedWidget3(); } - privateClassWithWithPrivatePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget1(); - privateClassWithWithPrivatePropertyTypes.myPrivateStaticProperty = exporter.createExportedWidget1(); - privateClassWithWithPrivatePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget3(); - privateClassWithWithPrivatePropertyTypes.myPrivateStaticProperty1 = exporter.createExportedWidget3(); return privateClassWithWithPrivatePropertyTypes; }()); +privateClassWithWithPrivatePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget1(); +privateClassWithWithPrivatePropertyTypes.myPrivateStaticProperty = exporter.createExportedWidget1(); +privateClassWithWithPrivatePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget3(); +privateClassWithWithPrivatePropertyTypes.myPrivateStaticProperty1 = exporter.createExportedWidget3(); exports.publicVarWithPrivatePropertyTypes = exporter.createExportedWidget1(); // Error var privateVarWithPrivatePropertyTypes = exporter.createExportedWidget1(); exports.publicVarWithPrivatePropertyTypes1 = exporter.createExportedWidget3(); // Error @@ -188,10 +188,10 @@ var publicClassWithPrivateModulePropertyTypes = (function () { this.myPublicProperty = exporter.createExportedWidget2(); // Error this.myPublicProperty1 = exporter.createExportedWidget4(); // Error } - publicClassWithPrivateModulePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget2(); // Error - publicClassWithPrivateModulePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget4(); // Error return publicClassWithPrivateModulePropertyTypes; }()); +publicClassWithPrivateModulePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget2(); // Error +publicClassWithPrivateModulePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget4(); // Error exports.publicClassWithPrivateModulePropertyTypes = publicClassWithPrivateModulePropertyTypes; exports.publicVarWithPrivateModulePropertyTypes = exporter.createExportedWidget2(); // Error exports.publicVarWithPrivateModulePropertyTypes1 = exporter.createExportedWidget4(); // Error @@ -200,10 +200,10 @@ var privateClassWithPrivateModulePropertyTypes = (function () { this.myPublicProperty = exporter.createExportedWidget2(); this.myPublicProperty1 = exporter.createExportedWidget4(); } - privateClassWithPrivateModulePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget2(); - privateClassWithPrivateModulePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget4(); return privateClassWithPrivateModulePropertyTypes; }()); +privateClassWithPrivateModulePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget2(); +privateClassWithPrivateModulePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget4(); var privateVarWithPrivateModulePropertyTypes = exporter.createExportedWidget2(); var privateVarWithPrivateModulePropertyTypes1 = exporter.createExportedWidget4(); diff --git a/tests/baselines/reference/privateIndexer2.js b/tests/baselines/reference/privateIndexer2.js index 1268c6e4c25..a90e03a5bc2 100644 --- a/tests/baselines/reference/privateIndexer2.js +++ b/tests/baselines/reference/privateIndexer2.js @@ -14,7 +14,6 @@ var y: { var x = (_a = {}, _a[x] = string, _a.string = , - _a -); + _a); var y; var _a; diff --git a/tests/baselines/reference/privateStaticMemberAccessibility.js b/tests/baselines/reference/privateStaticMemberAccessibility.js index 2074e5aa864..352256ac9bd 100644 --- a/tests/baselines/reference/privateStaticMemberAccessibility.js +++ b/tests/baselines/reference/privateStaticMemberAccessibility.js @@ -25,6 +25,6 @@ var Derived = (function (_super) { _super.apply(this, arguments); this.bing = function () { return Base.foo; }; // error } - Derived.bar = Base.foo; // error return Derived; }(Base)); +Derived.bar = Base.foo; // error diff --git a/tests/baselines/reference/propertyAccessibility2.js b/tests/baselines/reference/propertyAccessibility2.js index afce6c4c24a..3618b86fcc5 100644 --- a/tests/baselines/reference/propertyAccessibility2.js +++ b/tests/baselines/reference/propertyAccessibility2.js @@ -9,7 +9,7 @@ var c = C.x; var C = (function () { function C() { } - C.x = 1; return C; }()); +C.x = 1; var c = C.x; diff --git a/tests/baselines/reference/quotedPropertyName2.js b/tests/baselines/reference/quotedPropertyName2.js index 1c4d85076ea..550e5299702 100644 --- a/tests/baselines/reference/quotedPropertyName2.js +++ b/tests/baselines/reference/quotedPropertyName2.js @@ -7,6 +7,6 @@ class Test1 { var Test1 = (function () { function Test1() { } - Test1["prop1"] = 0; return Test1; }()); +Test1["prop1"] = 0; diff --git a/tests/baselines/reference/reassignStaticProp.js b/tests/baselines/reference/reassignStaticProp.js index 2bf2bafa128..d9c37c29ad5 100644 --- a/tests/baselines/reference/reassignStaticProp.js +++ b/tests/baselines/reference/reassignStaticProp.js @@ -15,6 +15,6 @@ class foo { var foo = (function () { function foo() { } - foo.bar = 1; return foo; }()); +foo.bar = 1; diff --git a/tests/baselines/reference/sourceMap-FileWithComments.js b/tests/baselines/reference/sourceMap-FileWithComments.js index 9bb18dba33d..dd2131889af 100644 --- a/tests/baselines/reference/sourceMap-FileWithComments.js +++ b/tests/baselines/reference/sourceMap-FileWithComments.js @@ -49,10 +49,10 @@ var Shapes; } // Instance member Point.prototype.getDist = function () { return Math.sqrt(this.x * this.x + this.y * this.y); }; - // Static member - Point.origin = new Point(0, 0); return Point; }()); + // Static member + Point.origin = new Point(0, 0); Shapes.Point = Point; // Variable comment after class var a = 10; diff --git a/tests/baselines/reference/sourceMap-FileWithComments.js.map b/tests/baselines/reference/sourceMap-FileWithComments.js.map index f3e9674336d..80437501d33 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;QAElE,gBAAgB;QACT,YAAM,GAAG,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACpC,YAAC;IAAD,CAAC,AATD,IASC;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,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 diff --git a/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt b/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt index 3bcf2634507..2abfabff566 100644 --- a/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt +++ b/tests/baselines/reference/sourceMap-FileWithComments.sourcemap.txt @@ -271,93 +271,90 @@ sourceFile:sourceMap-FileWithComments.ts 28>Emitted(12, 102) Source(16, 74) + SourceIndex(0) 29>Emitted(12, 103) Source(16, 75) + SourceIndex(0) --- ->>> // Static member -1 >^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^ -3 > ^^^^^^^^^^^^^^^^-> -1 > - > - > -2 > // Static member -1 >Emitted(13, 9) Source(18, 9) + SourceIndex(0) -2 >Emitted(13, 25) Source(18, 25) + SourceIndex(0) ---- ->>> Point.origin = new Point(0, 0); -1->^^^^^^^^ -2 > ^^^^^^^^^^^^ -3 > ^^^ -4 > ^^^^ -5 > ^^^^^ -6 > ^ -7 > ^ -8 > ^^ -9 > ^ -10> ^ -11> ^ -1-> - > static -2 > origin -3 > = -4 > new -5 > Point -6 > ( -7 > 0 -8 > , -9 > 0 -10> ) -11> ; -1->Emitted(14, 9) Source(19, 16) + SourceIndex(0) -2 >Emitted(14, 21) Source(19, 22) + SourceIndex(0) -3 >Emitted(14, 24) Source(19, 25) + SourceIndex(0) -4 >Emitted(14, 28) Source(19, 29) + SourceIndex(0) -5 >Emitted(14, 33) Source(19, 34) + SourceIndex(0) -6 >Emitted(14, 34) Source(19, 35) + SourceIndex(0) -7 >Emitted(14, 35) Source(19, 36) + SourceIndex(0) -8 >Emitted(14, 37) Source(19, 38) + SourceIndex(0) -9 >Emitted(14, 38) Source(19, 39) + SourceIndex(0) -10>Emitted(14, 39) Source(19, 40) + SourceIndex(0) -11>Emitted(14, 40) Source(19, 41) + SourceIndex(0) ---- >>> return Point; 1 >^^^^^^^^ 2 > ^^^^^^^^^^^^ 1 > + > + > // Static member + > static origin = new Point(0, 0); > 2 > } -1 >Emitted(15, 9) Source(20, 5) + SourceIndex(0) -2 >Emitted(15, 21) Source(20, 6) + SourceIndex(0) +1 >Emitted(13, 9) Source(20, 5) + SourceIndex(0) +2 >Emitted(13, 21) Source(20, 6) + SourceIndex(0) --- >>> }()); 1 >^^^^ 2 > ^ 3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^-> +4 > ^^^^^^^^^^^^^^^^-> 1 > 2 > } 3 > -4 > export class Point implements IPoint { - > // Constructor - > constructor(public x: number, public y: number) { } - > - > // Instance member - > getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } - > - > // Static member - > static origin = new Point(0, 0); - > } -1 >Emitted(16, 5) Source(20, 5) + SourceIndex(0) -2 >Emitted(16, 6) Source(20, 6) + SourceIndex(0) -3 >Emitted(16, 6) Source(11, 5) + SourceIndex(0) -4 >Emitted(16, 10) Source(20, 6) + SourceIndex(0) +1 >Emitted(14, 5) Source(20, 5) + SourceIndex(0) +2 >Emitted(14, 6) Source(20, 6) + SourceIndex(0) +3 >Emitted(14, 6) Source(11, 5) + SourceIndex(0) +--- +>>> // Static member +1->^^^^ +2 > ^^^^^^^^^^^^^^^^ +3 > ^^^^^^^^^^^^^^^^-> +1->export class Point implements IPoint { + > // Constructor + > constructor(public x: number, public y: number) { } + > + > // Instance member + > getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } + > + > +2 > // Static member +1->Emitted(15, 5) Source(18, 9) + SourceIndex(0) +2 >Emitted(15, 21) Source(18, 25) + SourceIndex(0) +--- +>>> Point.origin = new Point(0, 0); +1->^^^^ +2 > ^^^^^^^^^^^^ +3 > ^^^ +4 > ^^^^ +5 > ^^^^^ +6 > ^ +7 > ^ +8 > ^^ +9 > ^ +10> ^ +11> ^ +1-> + > static +2 > origin +3 > = +4 > new +5 > Point +6 > ( +7 > 0 +8 > , +9 > 0 +10> ) +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) +4 >Emitted(16, 24) Source(19, 29) + SourceIndex(0) +5 >Emitted(16, 29) Source(19, 34) + SourceIndex(0) +6 >Emitted(16, 30) Source(19, 35) + SourceIndex(0) +7 >Emitted(16, 31) Source(19, 36) + SourceIndex(0) +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) --- >>> Shapes.Point = Point; -1->^^^^ +1 >^^^^ 2 > ^^^^^^^^^^^^ 3 > ^^^^^^^^ 4 > ^ 5 > ^^^^^^^^^^^-> -1-> +1 > 2 > Point 3 > implements IPoint { > // Constructor @@ -370,7 +367,7 @@ sourceFile:sourceMap-FileWithComments.ts > static origin = new Point(0, 0); > } 4 > -1->Emitted(17, 5) Source(11, 18) + SourceIndex(0) +1 >Emitted(17, 5) Source(11, 18) + SourceIndex(0) 2 >Emitted(17, 17) Source(11, 23) + SourceIndex(0) 3 >Emitted(17, 25) Source(20, 6) + SourceIndex(0) 4 >Emitted(17, 26) Source(20, 6) + SourceIndex(0) diff --git a/tests/baselines/reference/sourceMapValidationDecorators.js b/tests/baselines/reference/sourceMapValidationDecorators.js index c3bb5cd7225..63cdb25900c 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.js +++ b/tests/baselines/reference/sourceMapValidationDecorators.js @@ -88,37 +88,37 @@ var Greeter = (function () { enumerable: true, configurable: true }); - Greeter.x1 = 10; - __decorate([ - PropertyDecorator1, - PropertyDecorator2(40) - ], Greeter.prototype, "greet", null); - __decorate([ - PropertyDecorator1, - PropertyDecorator2(50) - ], Greeter.prototype, "x", void 0); - __decorate([ - __param(0, ParameterDecorator1), - __param(0, ParameterDecorator2(70)) - ], Greeter.prototype, "fn", null); - __decorate([ - PropertyDecorator1, - PropertyDecorator2(80), - __param(0, ParameterDecorator1), - __param(0, ParameterDecorator2(90)) - ], Greeter.prototype, "greetings", null); - __decorate([ - PropertyDecorator1, - PropertyDecorator2(60) - ], Greeter, "x1", void 0); - Greeter = __decorate([ - ClassDecorator1, - ClassDecorator2(10), - __param(0, ParameterDecorator1), - __param(0, ParameterDecorator2(20)), - __param(1, ParameterDecorator1), - __param(1, ParameterDecorator2(30)) - ], Greeter); return Greeter; }()); +Greeter.x1 = 10; +__decorate([ + PropertyDecorator1, + PropertyDecorator2(40) +], Greeter.prototype, "greet", null); +__decorate([ + PropertyDecorator1, + PropertyDecorator2(50) +], Greeter.prototype, "x", void 0); +__decorate([ + __param(0, ParameterDecorator1), + __param(0, ParameterDecorator2(70)) +], Greeter.prototype, "fn", null); +__decorate([ + PropertyDecorator1, + PropertyDecorator2(80), + __param(0, ParameterDecorator1), + __param(0, ParameterDecorator2(90)) +], Greeter.prototype, "greetings", null); +__decorate([ + PropertyDecorator1, + PropertyDecorator2(60) +], Greeter, "x1", void 0); +Greeter = __decorate([ + ClassDecorator1, + ClassDecorator2(10), + __param(0, ParameterDecorator1), + __param(0, ParameterDecorator2(20)), + __param(1, ParameterDecorator1), + __param(1, ParameterDecorator2(30)) +], Greeter); //# sourceMappingURL=sourceMapValidationDecorators.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDecorators.js.map b/tests/baselines/reference/sourceMapValidationDecorators.js.map index 0a6b45eb383..18b24ddf37e 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.js.map +++ b/tests/baselines/reference/sourceMapValidationDecorators.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationDecorators.js.map] -{"version":3,"file":"sourceMapValidationDecorators.js","sourceRoot":"","sources":["sourceMapValidationDecorators.ts"],"names":[],"mappings":";;;;;;;;;AASA;IACI,iBAGS,QAAgB;QAIvB,WAAc;aAAd,WAAc,CAAd,sBAAc,CAAd,IAAc;YAAd,0BAAc;;QAJP,aAAQ,GAAR,QAAQ,CAAQ;IAKzB,CAAC;IAID,uBAAK,GAAL;QACI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5C,CAAC;IAUO,oBAAE,GAAV,UAGE,CAAS;QACP,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAID,sBAAI,8BAAS;aAAb;YACI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;aAED,UAGE,SAAiB;YACf,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC9B,CAAC;;;OAPA;IAbc,UAAE,GAAW,EAAE,CAAC;IAZ/B;QAAC,kBAAkB;QAClB,kBAAkB,CAAC,EAAE,CAAC;wCAAA;IAKvB;QAAC,kBAAkB;QAClB,kBAAkB,CAAC,EAAE,CAAC;sCAAA;IAQrB;mBAAC,mBAAmB;mBACnB,mBAAmB,CAAC,EAAE,CAAC;qCAAA;IAK1B;QAAC,kBAAkB;QAClB,kBAAkB,CAAC,EAAE,CAAC;mBAMpB,mBAAmB;mBACnB,mBAAmB,CAAC,EAAE,CAAC;4CAPH;IAZvB;QAAC,kBAAkB;QAClB,kBAAkB,CAAC,EAAE,CAAC;6BAAA;IAxB3B;QAAC,eAAe;QACf,eAAe,CAAC,EAAE,CAAC;mBAGb,mBAAmB;mBACnB,mBAAmB,CAAC,EAAE,CAAC;mBAGvB,mBAAmB;mBACnB,mBAAmB,CAAC,EAAE,CAAC;eARV;IA6CpB,cAAC;AAAD,CAAC,AA5CD,IA4CC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationDecorators.js","sourceRoot":"","sources":["sourceMapValidationDecorators.ts"],"names":[],"mappings":";;;;;;;;;AASA;IACI,iBAGS,QAAgB;QAIvB,WAAc;aAAd,WAAc,CAAd,sBAAc,CAAd,IAAc;YAAd,0BAAc;;QAJP,aAAQ,GAAR,QAAQ,CAAQ;IAKzB,CAAC;IAID,uBAAK,GAAL;QACI,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC5C,CAAC;IAUO,oBAAE,GAAV,UAGE,CAAS;QACP,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAID,sBAAI,8BAAS;aAAb;YACI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;aAED,UAGE,SAAiB;YACf,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC9B,CAAC;;;OAPA;IAQL,cAAC;AAAD,CAAC,AA5CD;AAuBmB,UAAE,GAAW,EAAE,CAAC;AAZ/B;IAAC,kBAAkB;IAClB,kBAAkB,CAAC,EAAE,CAAC;oCAAA;AAKvB;IAAC,kBAAkB;IAClB,kBAAkB,CAAC,EAAE,CAAC;kCAAA;AAQrB;eAAC,mBAAmB;eACnB,mBAAmB,CAAC,EAAE,CAAC;iCAAA;AAK1B;IAAC,kBAAkB;IAClB,kBAAkB,CAAC,EAAE,CAAC;eAMpB,mBAAmB;eACnB,mBAAmB,CAAC,EAAE,CAAC;wCAPH;AAZvB;IAAC,kBAAkB;IAClB,kBAAkB,CAAC,EAAE,CAAC;yBAAA;AAxB3B;IAAC,eAAe;IACf,eAAe,CAAC,EAAE,CAAC;eAGb,mBAAmB;eACnB,mBAAmB,CAAC,EAAE,CAAC;eAGvB,mBAAmB;eACnB,mBAAmB,CAAC,EAAE,CAAC;WARV;AA6CnB"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt index 16820428856..58b5eaefc7c 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationDecorators.sourcemap.txt @@ -356,113 +356,164 @@ sourceFile:sourceMapValidationDecorators.ts >>> configurable: true >>> }); 1->^^^^^^^ -2 > ^^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^-> 1-> 1->Emitted(33, 8) Source(46, 6) + SourceIndex(0) --- ->>> Greeter.x1 = 10; +>>> return Greeter; 1->^^^^ -2 > ^^^^^^^^^^ -3 > ^^^ -4 > ^^ -5 > ^ -1-> -2 > x1 -3 > : number = -4 > 10 -5 > ; -1->Emitted(34, 5) Source(33, 20) + SourceIndex(0) -2 >Emitted(34, 15) Source(33, 22) + SourceIndex(0) -3 >Emitted(34, 18) Source(33, 33) + SourceIndex(0) -4 >Emitted(34, 20) Source(33, 35) + SourceIndex(0) -5 >Emitted(34, 21) Source(33, 36) + SourceIndex(0) +2 > ^^^^^^^^^^^^^^ +1-> + > + > set greetings( + > @ParameterDecorator1 + > @ParameterDecorator2(90) + > greetings: string) { + > this.greeting = greetings; + > } + > +2 > } +1->Emitted(34, 5) Source(54, 1) + SourceIndex(0) +2 >Emitted(34, 19) Source(54, 2) + SourceIndex(0) --- ->>> __decorate([ -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> +>>>}()); 1 > -1 >Emitted(35, 5) Source(21, 5) + SourceIndex(0) +2 >^ +3 > +4 > ^^^^^^^^^^^^^^^^-> +1 > +2 >} +3 > +1 >Emitted(35, 1) Source(54, 1) + SourceIndex(0) +2 >Emitted(35, 2) Source(54, 2) + SourceIndex(0) +3 >Emitted(35, 2) Source(10, 1) + SourceIndex(0) --- ->>> PropertyDecorator1, -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^^^^^-> +>>>Greeter.x1 = 10; +1-> +2 >^^^^^^^^^^ +3 > ^^^ +4 > ^^ +5 > ^ +1->class Greeter { + > constructor( + > @ParameterDecorator1 + > @ParameterDecorator2(20) + > public greeting: string, + > + > @ParameterDecorator1 + > @ParameterDecorator2(30) + > ...b: string[]) { + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(40) + > greet() { + > return "

" + this.greeting + "

"; + > } + > + > @PropertyDecorator1 + > @PropertyDecorator2(50) + > private x: string; + > + > @PropertyDecorator1 + > @PropertyDecorator2(60) + > private static +2 >x1 +3 > : number = +4 > 10 +5 > ; +1->Emitted(36, 1) Source(33, 20) + SourceIndex(0) +2 >Emitted(36, 11) Source(33, 22) + SourceIndex(0) +3 >Emitted(36, 14) Source(33, 33) + SourceIndex(0) +4 >Emitted(36, 16) Source(33, 35) + SourceIndex(0) +5 >Emitted(36, 17) Source(33, 36) + SourceIndex(0) +--- +>>>__decorate([ +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +1 >Emitted(37, 1) Source(21, 5) + SourceIndex(0) +--- +>>> PropertyDecorator1, +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^^^^^-> 1->@ -2 > PropertyDecorator1 -1->Emitted(36, 9) Source(21, 6) + SourceIndex(0) -2 >Emitted(36, 27) Source(21, 24) + SourceIndex(0) +2 > PropertyDecorator1 +1->Emitted(38, 5) Source(21, 6) + SourceIndex(0) +2 >Emitted(38, 23) Source(21, 24) + SourceIndex(0) --- ->>> PropertyDecorator2(40) -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^-> +>>> PropertyDecorator2(40) +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^^^^^-> 1-> > @ -2 > PropertyDecorator2 -3 > ( -4 > 40 -5 > ) -1->Emitted(37, 9) Source(22, 6) + SourceIndex(0) -2 >Emitted(37, 27) Source(22, 24) + SourceIndex(0) -3 >Emitted(37, 28) Source(22, 25) + SourceIndex(0) -4 >Emitted(37, 30) Source(22, 27) + SourceIndex(0) -5 >Emitted(37, 31) Source(22, 28) + SourceIndex(0) +2 > PropertyDecorator2 +3 > ( +4 > 40 +5 > ) +1->Emitted(39, 5) Source(22, 6) + SourceIndex(0) +2 >Emitted(39, 23) Source(22, 24) + SourceIndex(0) +3 >Emitted(39, 24) Source(22, 25) + SourceIndex(0) +4 >Emitted(39, 26) Source(22, 27) + SourceIndex(0) +5 >Emitted(39, 27) Source(22, 28) + SourceIndex(0) --- ->>> ], Greeter.prototype, "greet", null); -1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>>>], Greeter.prototype, "greet", null); +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> -1->Emitted(38, 41) Source(22, 28) + SourceIndex(0) +1->Emitted(40, 37) Source(22, 28) + SourceIndex(0) --- ->>> __decorate([ -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> +>>>__decorate([ +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > greet() { > return "

" + this.greeting + "

"; > } > > -1 >Emitted(39, 5) Source(27, 5) + SourceIndex(0) +1 >Emitted(41, 1) Source(27, 5) + SourceIndex(0) --- ->>> PropertyDecorator1, -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^^^^^-> +>>> PropertyDecorator1, +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^^^^^-> 1->@ -2 > PropertyDecorator1 -1->Emitted(40, 9) Source(27, 6) + SourceIndex(0) -2 >Emitted(40, 27) Source(27, 24) + SourceIndex(0) +2 > PropertyDecorator1 +1->Emitted(42, 5) Source(27, 6) + SourceIndex(0) +2 >Emitted(42, 23) Source(27, 24) + SourceIndex(0) --- ->>> PropertyDecorator2(50) -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^-> +>>> PropertyDecorator2(50) +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^^^-> 1-> > @ -2 > PropertyDecorator2 -3 > ( -4 > 50 -5 > ) -1->Emitted(41, 9) Source(28, 6) + SourceIndex(0) -2 >Emitted(41, 27) Source(28, 24) + SourceIndex(0) -3 >Emitted(41, 28) Source(28, 25) + SourceIndex(0) -4 >Emitted(41, 30) Source(28, 27) + SourceIndex(0) -5 >Emitted(41, 31) Source(28, 28) + SourceIndex(0) +2 > PropertyDecorator2 +3 > ( +4 > 50 +5 > ) +1->Emitted(43, 5) Source(28, 6) + SourceIndex(0) +2 >Emitted(43, 23) Source(28, 24) + SourceIndex(0) +3 >Emitted(43, 24) Source(28, 25) + SourceIndex(0) +4 >Emitted(43, 26) Source(28, 27) + SourceIndex(0) +5 >Emitted(43, 27) Source(28, 28) + SourceIndex(0) --- ->>> ], Greeter.prototype, "x", void 0); -1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>>>], Greeter.prototype, "x", void 0); +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> -1->Emitted(42, 39) Source(28, 28) + SourceIndex(0) +1->Emitted(44, 35) Source(28, 28) + SourceIndex(0) --- ->>> __decorate([ -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +>>>__decorate([ +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > private x: string; > @@ -472,83 +523,83 @@ sourceFile:sourceMapValidationDecorators.ts > > private fn( > -1 >Emitted(43, 5) Source(36, 7) + SourceIndex(0) +1 >Emitted(45, 1) Source(36, 7) + SourceIndex(0) --- ->>> __param(0, ParameterDecorator1), -1->^^^^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^-> +>>> __param(0, ParameterDecorator1), +1->^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^-> 1->@ -2 > ParameterDecorator1 -1->Emitted(44, 20) Source(36, 8) + SourceIndex(0) -2 >Emitted(44, 39) Source(36, 27) + SourceIndex(0) +2 > ParameterDecorator1 +1->Emitted(46, 16) Source(36, 8) + SourceIndex(0) +2 >Emitted(46, 35) Source(36, 27) + SourceIndex(0) --- ->>> __param(0, ParameterDecorator2(70)) -1->^^^^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^ -5 > ^ +>>> __param(0, ParameterDecorator2(70)) +1->^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ 1-> > @ -2 > ParameterDecorator2 -3 > ( -4 > 70 -5 > ) -1->Emitted(45, 20) Source(37, 8) + SourceIndex(0) -2 >Emitted(45, 39) Source(37, 27) + SourceIndex(0) -3 >Emitted(45, 40) Source(37, 28) + SourceIndex(0) -4 >Emitted(45, 42) Source(37, 30) + SourceIndex(0) -5 >Emitted(45, 43) Source(37, 31) + SourceIndex(0) +2 > ParameterDecorator2 +3 > ( +4 > 70 +5 > ) +1->Emitted(47, 16) Source(37, 8) + SourceIndex(0) +2 >Emitted(47, 35) Source(37, 27) + SourceIndex(0) +3 >Emitted(47, 36) Source(37, 28) + SourceIndex(0) +4 >Emitted(47, 38) Source(37, 30) + SourceIndex(0) +5 >Emitted(47, 39) Source(37, 31) + SourceIndex(0) --- ->>> ], Greeter.prototype, "fn", null); -1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>>>], Greeter.prototype, "fn", null); +1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > -1 >Emitted(46, 38) Source(37, 31) + SourceIndex(0) +1 >Emitted(48, 34) Source(37, 31) + SourceIndex(0) --- ->>> __decorate([ -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> +>>>__decorate([ +1 > +2 >^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > x: number) { > return this.greeting; > } > > -1 >Emitted(47, 5) Source(42, 5) + SourceIndex(0) +1 >Emitted(49, 1) Source(42, 5) + SourceIndex(0) --- ->>> PropertyDecorator1, -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^-> +>>> PropertyDecorator1, +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^-> 1->@ -2 > PropertyDecorator1 -1->Emitted(48, 9) Source(42, 6) + SourceIndex(0) -2 >Emitted(48, 27) Source(42, 24) + SourceIndex(0) +2 > PropertyDecorator1 +1->Emitted(50, 5) Source(42, 6) + SourceIndex(0) +2 >Emitted(50, 23) Source(42, 24) + SourceIndex(0) --- ->>> PropertyDecorator2(80), -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^-> +>>> PropertyDecorator2(80), +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^^^^-> 1-> > @ -2 > PropertyDecorator2 -3 > ( -4 > 80 -5 > ) -1->Emitted(49, 9) Source(43, 6) + SourceIndex(0) -2 >Emitted(49, 27) Source(43, 24) + SourceIndex(0) -3 >Emitted(49, 28) Source(43, 25) + SourceIndex(0) -4 >Emitted(49, 30) Source(43, 27) + SourceIndex(0) -5 >Emitted(49, 31) Source(43, 28) + SourceIndex(0) +2 > PropertyDecorator2 +3 > ( +4 > 80 +5 > ) +1->Emitted(51, 5) Source(43, 6) + SourceIndex(0) +2 >Emitted(51, 23) Source(43, 24) + SourceIndex(0) +3 >Emitted(51, 24) Source(43, 25) + SourceIndex(0) +4 >Emitted(51, 26) Source(43, 27) + SourceIndex(0) +5 >Emitted(51, 27) Source(43, 28) + SourceIndex(0) --- ->>> __param(0, ParameterDecorator1), -1->^^^^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^-> +>>> __param(0, ParameterDecorator1), +1->^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^-> 1-> > get greetings() { > return this.greeting; @@ -556,176 +607,175 @@ sourceFile:sourceMapValidationDecorators.ts > > set greetings( > @ -2 > ParameterDecorator1 -1->Emitted(50, 20) Source(49, 8) + SourceIndex(0) -2 >Emitted(50, 39) Source(49, 27) + SourceIndex(0) +2 > ParameterDecorator1 +1->Emitted(52, 16) Source(49, 8) + SourceIndex(0) +2 >Emitted(52, 35) Source(49, 27) + SourceIndex(0) --- ->>> __param(0, ParameterDecorator2(90)) -1->^^^^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -6 > ^^^^-> +>>> __param(0, ParameterDecorator2(90)) +1->^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^^-> 1-> > @ -2 > ParameterDecorator2 -3 > ( -4 > 90 -5 > ) -1->Emitted(51, 20) Source(50, 8) + SourceIndex(0) -2 >Emitted(51, 39) Source(50, 27) + SourceIndex(0) -3 >Emitted(51, 40) Source(50, 28) + SourceIndex(0) -4 >Emitted(51, 42) Source(50, 30) + SourceIndex(0) -5 >Emitted(51, 43) Source(50, 31) + SourceIndex(0) +2 > ParameterDecorator2 +3 > ( +4 > 90 +5 > ) +1->Emitted(53, 16) Source(50, 8) + SourceIndex(0) +2 >Emitted(53, 35) Source(50, 27) + SourceIndex(0) +3 >Emitted(53, 36) Source(50, 28) + SourceIndex(0) +4 >Emitted(53, 38) Source(50, 30) + SourceIndex(0) +5 >Emitted(53, 39) Source(50, 31) + SourceIndex(0) --- ->>> ], Greeter.prototype, "greetings", null); -1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>>>], Greeter.prototype, "greetings", null); +1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> -1->Emitted(52, 45) Source(43, 28) + SourceIndex(0) +1->Emitted(54, 41) Source(43, 28) + SourceIndex(0) --- ->>> __decorate([ -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^-> +>>>__decorate([ 1 > -1 >Emitted(53, 5) Source(31, 5) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > +1 >Emitted(55, 1) Source(31, 5) + SourceIndex(0) --- ->>> PropertyDecorator1, -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^^^^^-> +>>> PropertyDecorator1, +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^^^^^-> 1->@ -2 > PropertyDecorator1 -1->Emitted(54, 9) Source(31, 6) + SourceIndex(0) -2 >Emitted(54, 27) Source(31, 24) + SourceIndex(0) +2 > PropertyDecorator1 +1->Emitted(56, 5) Source(31, 6) + SourceIndex(0) +2 >Emitted(56, 23) Source(31, 24) + SourceIndex(0) --- ->>> PropertyDecorator2(60) -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -6 > ^-> +>>> PropertyDecorator2(60) +1->^^^^ +2 > ^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^-> 1-> > @ -2 > PropertyDecorator2 -3 > ( -4 > 60 -5 > ) -1->Emitted(55, 9) Source(32, 6) + SourceIndex(0) -2 >Emitted(55, 27) Source(32, 24) + SourceIndex(0) -3 >Emitted(55, 28) Source(32, 25) + SourceIndex(0) -4 >Emitted(55, 30) Source(32, 27) + SourceIndex(0) -5 >Emitted(55, 31) Source(32, 28) + SourceIndex(0) +2 > PropertyDecorator2 +3 > ( +4 > 60 +5 > ) +1->Emitted(57, 5) Source(32, 6) + SourceIndex(0) +2 >Emitted(57, 23) Source(32, 24) + SourceIndex(0) +3 >Emitted(57, 24) Source(32, 25) + SourceIndex(0) +4 >Emitted(57, 26) Source(32, 27) + SourceIndex(0) +5 >Emitted(57, 27) Source(32, 28) + SourceIndex(0) --- ->>> ], Greeter, "x1", void 0); -1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>>>], Greeter, "x1", void 0); +1->^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> -1->Emitted(56, 30) Source(32, 28) + SourceIndex(0) +1->Emitted(58, 26) Source(32, 28) + SourceIndex(0) --- ->>> Greeter = __decorate([ -1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^-> +>>>Greeter = __decorate([ 1 > -1 >Emitted(57, 5) Source(8, 1) + SourceIndex(0) +2 >^^^^^^^^^^^^^^^^^^^^^-> +1 > +1 >Emitted(59, 1) Source(8, 1) + SourceIndex(0) --- ->>> ClassDecorator1, -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^ -3 > ^^^^^^-> +>>> ClassDecorator1, +1->^^^^ +2 > ^^^^^^^^^^^^^^^ +3 > ^^^^^^-> 1->@ -2 > ClassDecorator1 -1->Emitted(58, 9) Source(8, 2) + SourceIndex(0) -2 >Emitted(58, 24) Source(8, 17) + SourceIndex(0) +2 > ClassDecorator1 +1->Emitted(60, 5) Source(8, 2) + SourceIndex(0) +2 >Emitted(60, 20) Source(8, 17) + SourceIndex(0) --- ->>> ClassDecorator2(10), -1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^ -5 > ^ -6 > ^^^^^^^^^^^^^^-> +>>> ClassDecorator2(10), +1->^^^^ +2 > ^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ +6 > ^^^^^^^^^^^^^^-> 1-> >@ -2 > ClassDecorator2 -3 > ( -4 > 10 -5 > ) -1->Emitted(59, 9) Source(9, 2) + SourceIndex(0) -2 >Emitted(59, 24) Source(9, 17) + SourceIndex(0) -3 >Emitted(59, 25) Source(9, 18) + SourceIndex(0) -4 >Emitted(59, 27) Source(9, 20) + SourceIndex(0) -5 >Emitted(59, 28) Source(9, 21) + SourceIndex(0) +2 > ClassDecorator2 +3 > ( +4 > 10 +5 > ) +1->Emitted(61, 5) Source(9, 2) + SourceIndex(0) +2 >Emitted(61, 20) Source(9, 17) + SourceIndex(0) +3 >Emitted(61, 21) Source(9, 18) + SourceIndex(0) +4 >Emitted(61, 23) Source(9, 20) + SourceIndex(0) +5 >Emitted(61, 24) Source(9, 21) + SourceIndex(0) --- ->>> __param(0, ParameterDecorator1), -1->^^^^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^^-> +>>> __param(0, ParameterDecorator1), +1->^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^^-> 1-> >class Greeter { > constructor( > @ -2 > ParameterDecorator1 -1->Emitted(60, 20) Source(12, 8) + SourceIndex(0) -2 >Emitted(60, 39) Source(12, 27) + SourceIndex(0) +2 > ParameterDecorator1 +1->Emitted(62, 16) Source(12, 8) + SourceIndex(0) +2 >Emitted(62, 35) Source(12, 27) + SourceIndex(0) --- ->>> __param(0, ParameterDecorator2(20)), -1->^^^^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^ -5 > ^ +>>> __param(0, ParameterDecorator2(20)), +1->^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ 1-> > @ -2 > ParameterDecorator2 -3 > ( -4 > 20 -5 > ) -1->Emitted(61, 20) Source(13, 8) + SourceIndex(0) -2 >Emitted(61, 39) Source(13, 27) + SourceIndex(0) -3 >Emitted(61, 40) Source(13, 28) + SourceIndex(0) -4 >Emitted(61, 42) Source(13, 30) + SourceIndex(0) -5 >Emitted(61, 43) Source(13, 31) + SourceIndex(0) +2 > ParameterDecorator2 +3 > ( +4 > 20 +5 > ) +1->Emitted(63, 16) Source(13, 8) + SourceIndex(0) +2 >Emitted(63, 35) Source(13, 27) + SourceIndex(0) +3 >Emitted(63, 36) Source(13, 28) + SourceIndex(0) +4 >Emitted(63, 38) Source(13, 30) + SourceIndex(0) +5 >Emitted(63, 39) Source(13, 31) + SourceIndex(0) --- ->>> __param(1, ParameterDecorator1), -1 >^^^^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^ -3 > ^^^^^^-> +>>> __param(1, ParameterDecorator1), +1 >^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^^^^^^-> 1 > > public greeting: string, > > @ -2 > ParameterDecorator1 -1 >Emitted(62, 20) Source(16, 8) + SourceIndex(0) -2 >Emitted(62, 39) Source(16, 27) + SourceIndex(0) +2 > ParameterDecorator1 +1 >Emitted(64, 16) Source(16, 8) + SourceIndex(0) +2 >Emitted(64, 35) Source(16, 27) + SourceIndex(0) --- ->>> __param(1, ParameterDecorator2(30)) -1->^^^^^^^^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^ -5 > ^ +>>> __param(1, ParameterDecorator2(30)) +1->^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^ +5 > ^ 1-> > @ -2 > ParameterDecorator2 -3 > ( -4 > 30 -5 > ) -1->Emitted(63, 20) Source(17, 8) + SourceIndex(0) -2 >Emitted(63, 39) Source(17, 27) + SourceIndex(0) -3 >Emitted(63, 40) Source(17, 28) + SourceIndex(0) -4 >Emitted(63, 42) Source(17, 30) + SourceIndex(0) -5 >Emitted(63, 43) Source(17, 31) + SourceIndex(0) +2 > ParameterDecorator2 +3 > ( +4 > 30 +5 > ) +1->Emitted(65, 16) Source(17, 8) + SourceIndex(0) +2 >Emitted(65, 35) Source(17, 27) + SourceIndex(0) +3 >Emitted(65, 36) Source(17, 28) + SourceIndex(0) +4 >Emitted(65, 38) Source(17, 30) + SourceIndex(0) +5 >Emitted(65, 39) Source(17, 31) + SourceIndex(0) --- ->>> ], Greeter); -1 >^^^^^^^^^^^^^^^ -2 > ^^^^^-> +>>>], Greeter); +1 >^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > -1 >Emitted(64, 16) Source(9, 21) + SourceIndex(0) +1 >Emitted(66, 12) Source(9, 21) + SourceIndex(0) --- ->>> return Greeter; -1->^^^^ -2 > ^^^^^^^^^^^^^^ +>>>//# sourceMappingURL=sourceMapValidationDecorators.js.map1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> >class Greeter { > constructor( @@ -771,68 +821,6 @@ sourceFile:sourceMapValidationDecorators.ts > greetings: string) { > this.greeting = greetings; > } - > -2 > } -1->Emitted(65, 5) Source(54, 1) + SourceIndex(0) -2 >Emitted(65, 19) Source(54, 2) + SourceIndex(0) ---- ->>>}()); -1 > -2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > -2 >} -3 > -4 > class Greeter { - > constructor( - > @ParameterDecorator1 - > @ParameterDecorator2(20) - > public greeting: string, - > - > @ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[]) { - > } - > - > @PropertyDecorator1 - > @PropertyDecorator2(40) - > greet() { - > return "

" + this.greeting + "

"; - > } - > - > @PropertyDecorator1 - > @PropertyDecorator2(50) - > private x: string; - > - > @PropertyDecorator1 - > @PropertyDecorator2(60) - > private static x1: number = 10; - > - > private fn( - > @ParameterDecorator1 - > @ParameterDecorator2(70) - > x: number) { - > return this.greeting; - > } - > - > @PropertyDecorator1 - > @PropertyDecorator2(80) - > get greetings() { - > return this.greeting; - > } - > - > set greetings( - > @ParameterDecorator1 - > @ParameterDecorator2(90) - > greetings: string) { - > this.greeting = greetings; - > } - > } -1 >Emitted(66, 1) Source(54, 1) + SourceIndex(0) -2 >Emitted(66, 2) Source(54, 2) + SourceIndex(0) -3 >Emitted(66, 2) Source(10, 1) + SourceIndex(0) -4 >Emitted(66, 6) Source(54, 2) + SourceIndex(0) ---- ->>>//# sourceMappingURL=sourceMapValidationDecorators.js.map \ No newline at end of file + >} +1->Emitted(67, 1) Source(54, 2) + SourceIndex(0) +--- \ No newline at end of file diff --git a/tests/baselines/reference/staticClassProps.js b/tests/baselines/reference/staticClassProps.js index c808e4eb7fd..8a61bb7400f 100644 --- a/tests/baselines/reference/staticClassProps.js +++ b/tests/baselines/reference/staticClassProps.js @@ -13,6 +13,6 @@ var C = (function () { function C() { } C.prototype.foo = function () { }; - C.z = 1; return C; }()); +C.z = 1; diff --git a/tests/baselines/reference/staticMemberAccessOffDerivedType1.js b/tests/baselines/reference/staticMemberAccessOffDerivedType1.js index a05ece1dbbb..1c76a251220 100644 --- a/tests/baselines/reference/staticMemberAccessOffDerivedType1.js +++ b/tests/baselines/reference/staticMemberAccessOffDerivedType1.js @@ -28,6 +28,6 @@ var P = (function (_super) { function P() { _super.apply(this, arguments); } - P.SomeNumber = P.GetNumber(); return P; }(SomeBase)); +P.SomeNumber = P.GetNumber(); diff --git a/tests/baselines/reference/staticMemberInitialization.js b/tests/baselines/reference/staticMemberInitialization.js index c21c29ed4f8..13a5c8c25c6 100644 --- a/tests/baselines/reference/staticMemberInitialization.js +++ b/tests/baselines/reference/staticMemberInitialization.js @@ -10,8 +10,8 @@ var r = C.x; var C = (function () { function C() { } - C.x = 1; return C; }()); +C.x = 1; var c = new C(); var r = C.x; diff --git a/tests/baselines/reference/staticMemberWithStringAndNumberNames.js b/tests/baselines/reference/staticMemberWithStringAndNumberNames.js index 2fdd64ea04b..9d8846ba963 100644 --- a/tests/baselines/reference/staticMemberWithStringAndNumberNames.js +++ b/tests/baselines/reference/staticMemberWithStringAndNumberNames.js @@ -19,10 +19,10 @@ var C = (function () { this.x2 = C['0']; this.x3 = C[0]; } - C["foo"] = 0; - C[0] = 1; - C.s = C['foo']; - C.s2 = C['0']; - C.s3 = C[0]; return C; }()); +C["foo"] = 0; +C[0] = 1; +C.s = C['foo']; +C.s2 = C['0']; +C.s3 = C[0]; diff --git a/tests/baselines/reference/staticModifierAlreadySeen.js b/tests/baselines/reference/staticModifierAlreadySeen.js index 76f8b050d6f..c37d4c0807a 100644 --- a/tests/baselines/reference/staticModifierAlreadySeen.js +++ b/tests/baselines/reference/staticModifierAlreadySeen.js @@ -9,6 +9,6 @@ var C = (function () { function C() { } C.bar = function () { }; - C.foo = 1; return C; }()); +C.foo = 1; diff --git a/tests/baselines/reference/staticPropSuper.js b/tests/baselines/reference/staticPropSuper.js index f4bc5ece8d1..c25c406746d 100644 --- a/tests/baselines/reference/staticPropSuper.js +++ b/tests/baselines/reference/staticPropSuper.js @@ -52,9 +52,9 @@ var B = (function (_super) { var x = 1; // should not error _super.call(this); } - B.s = 9; return B; }(A)); +B.s = 9; var C = (function (_super) { __extends(C, _super); function C() { diff --git a/tests/baselines/reference/statics.js b/tests/baselines/reference/statics.js index 3776c09c8ce..d52a28208e6 100644 --- a/tests/baselines/reference/statics.js +++ b/tests/baselines/reference/statics.js @@ -45,11 +45,11 @@ var M; C.f = function (n) { return "wow: " + (n + C.y + C.pub + C.priv); }; - C.priv = 2; - C.pub = 3; - C.y = C.priv; return C; }()); + C.priv = 2; + C.pub = 3; + C.y = C.priv; M.C = C; var c = C.y; function f() { diff --git a/tests/baselines/reference/staticsInConstructorBodies.js b/tests/baselines/reference/staticsInConstructorBodies.js index 9bc3ed29325..edd49456ef7 100644 --- a/tests/baselines/reference/staticsInConstructorBodies.js +++ b/tests/baselines/reference/staticsInConstructorBodies.js @@ -11,6 +11,6 @@ var C = (function () { function C() { } C.m1 = function () { }; // ERROR - C.p1 = 0; // ERROR return C; }()); +C.p1 = 0; // ERROR diff --git a/tests/baselines/reference/staticsNotInScopeInClodule.js b/tests/baselines/reference/staticsNotInScopeInClodule.js index 150ae8aca5b..e10ed2b31d3 100644 --- a/tests/baselines/reference/staticsNotInScopeInClodule.js +++ b/tests/baselines/reference/staticsNotInScopeInClodule.js @@ -11,9 +11,9 @@ module Clod { var Clod = (function () { function Clod() { } - Clod.x = 10; return Clod; }()); +Clod.x = 10; var Clod; (function (Clod) { var p = x; // x isn't in scope here diff --git a/tests/baselines/reference/strictModeInConstructor.js b/tests/baselines/reference/strictModeInConstructor.js index 3b315861548..30dbfa58d70 100644 --- a/tests/baselines/reference/strictModeInConstructor.js +++ b/tests/baselines/reference/strictModeInConstructor.js @@ -105,18 +105,18 @@ var Bs = (function (_super) { "use strict"; // No error _super.call(this); } - Bs.s = 9; return Bs; }(A)); +Bs.s = 9; var Cs = (function (_super) { __extends(Cs, _super); function Cs() { _super.call(this); // No error "use strict"; } - Cs.s = 9; return Cs; }(A)); +Cs.s = 9; var Ds = (function (_super) { __extends(Ds, _super); function Ds() { @@ -124,6 +124,6 @@ var Ds = (function (_super) { _super.call(this); "use strict"; } - Ds.s = 9; return Ds; }(A)); +Ds.s = 9; diff --git a/tests/baselines/reference/superAccess.js b/tests/baselines/reference/superAccess.js index 37c6a9816a6..6e5cd9aca44 100644 --- a/tests/baselines/reference/superAccess.js +++ b/tests/baselines/reference/superAccess.js @@ -24,9 +24,9 @@ var MyBase = (function () { this.S2 = "test"; this.f = function () { return 5; }; } - MyBase.S1 = 5; return MyBase; }()); +MyBase.S1 = 5; var MyDerived = (function (_super) { __extends(MyDerived, _super); function MyDerived() { diff --git a/tests/baselines/reference/superAccess2.js b/tests/baselines/reference/superAccess2.js index b27d695cb31..c72bf387c24 100644 --- a/tests/baselines/reference/superAccess2.js +++ b/tests/baselines/reference/superAccess2.js @@ -59,6 +59,6 @@ var Q = (function (_super) { _super.x.call(this); // error _super.y.call(this); }; - Q.yy = _super.; // error for static initializer accessing super return Q; }(P)); +Q.yy = _super.; // error for static initializer accessing super diff --git a/tests/baselines/reference/thisInArrowFunctionInStaticInitializer1.js b/tests/baselines/reference/thisInArrowFunctionInStaticInitializer1.js index 4b23326c7a3..07d65c726b3 100644 --- a/tests/baselines/reference/thisInArrowFunctionInStaticInitializer1.js +++ b/tests/baselines/reference/thisInArrowFunctionInStaticInitializer1.js @@ -14,9 +14,9 @@ var Vector = (function () { function Vector() { var _this = this; } - Vector.foo = function () { - // 'this' should not be available in a static initializer. - log(_this); - }; return Vector; }()); +Vector.foo = function () { + // 'this' should not be available in a static initializer. + log(_this); +}; diff --git a/tests/baselines/reference/thisInConstructorParameter2.js b/tests/baselines/reference/thisInConstructorParameter2.js index 7260ecafcb9..ba2917c5a4e 100644 --- a/tests/baselines/reference/thisInConstructorParameter2.js +++ b/tests/baselines/reference/thisInConstructorParameter2.js @@ -25,6 +25,6 @@ var P = (function () { if (zz === void 0) { zz = this; } zz.y; }; - P.y = this; return P; }()); +P.y = this; diff --git a/tests/baselines/reference/thisInInvalidContexts.js b/tests/baselines/reference/thisInInvalidContexts.js index 75ccd12c288..76eeef0139c 100644 --- a/tests/baselines/reference/thisInInvalidContexts.js +++ b/tests/baselines/reference/thisInInvalidContexts.js @@ -58,9 +58,9 @@ var __extends = (this && this.__extends) || function (d, b) { var ErrClass1 = (function () { function ErrClass1() { } - ErrClass1.t = this; // Error return ErrClass1; }()); +ErrClass1.t = this; // Error var BaseErrClass = (function () { function BaseErrClass(t) { } diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.js b/tests/baselines/reference/thisInInvalidContextsExternalModule.js index 2e7e6d8b47c..634b5ef0a20 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.js +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.js @@ -59,9 +59,9 @@ var __extends = (this && this.__extends) || function (d, b) { var ErrClass1 = (function () { function ErrClass1() { } - ErrClass1.t = this; // Error return ErrClass1; }()); +ErrClass1.t = this; // Error var BaseErrClass = (function () { function BaseErrClass(t) { } diff --git a/tests/baselines/reference/thisInOuterClassBody.js b/tests/baselines/reference/thisInOuterClassBody.js index 40e4a2e2485..40b0e2b78ae 100644 --- a/tests/baselines/reference/thisInOuterClassBody.js +++ b/tests/baselines/reference/thisInOuterClassBody.js @@ -36,6 +36,6 @@ var Foo = (function () { var a = this.y; var b = this.x; }; - Foo.y = this; return Foo; }()); +Foo.y = this; diff --git a/tests/baselines/reference/thisInPropertyBoundDeclarations.js b/tests/baselines/reference/thisInPropertyBoundDeclarations.js index 0b378cec51a..f5967fbb5b2 100644 --- a/tests/baselines/reference/thisInPropertyBoundDeclarations.js +++ b/tests/baselines/reference/thisInPropertyBoundDeclarations.js @@ -74,13 +74,13 @@ var Bug = (function () { Bug.prototype.foo = function (name) { this.name = name; }; - Bug.func = [ - function (that, name) { - that.foo(name); - } - ]; return Bug; }()); +Bug.func = [ + function (that, name) { + that.foo(name); + } +]; // Valid use of this in a property bound decl var A = (function () { function A() { diff --git a/tests/baselines/reference/thisInStaticMethod1.js b/tests/baselines/reference/thisInStaticMethod1.js index a42415c0b62..1e39ded3b61 100644 --- a/tests/baselines/reference/thisInStaticMethod1.js +++ b/tests/baselines/reference/thisInStaticMethod1.js @@ -14,7 +14,7 @@ var foo = (function () { foo.bar = function () { return this.x; }; - foo.x = 3; return foo; }()); +foo.x = 3; var x = foo.bar(); diff --git a/tests/baselines/reference/thisTypeErrors.js b/tests/baselines/reference/thisTypeErrors.js index f246b80f4f4..5811ec6b709 100644 --- a/tests/baselines/reference/thisTypeErrors.js +++ b/tests/baselines/reference/thisTypeErrors.js @@ -75,9 +75,9 @@ var C2 = (function () { C2.foo = function (x) { return undefined; }; - C2.y = undefined; return C2; }()); +C2.y = undefined; var N1; (function (N1) { N1.y = this; diff --git a/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.js b/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.js index d18181dd1dc..44b37cc3be5 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.js +++ b/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.js @@ -14,9 +14,11 @@ function foo(x) { }()); } return undefined; } -foo((function () { - function class_2() { - } - class_2.prop = "hello"; - return class_2; -}())).length; +foo((_a = (function () { + function class_2() { + } + return class_2; + }()), + _a.prop = "hello", + _a)).length; +var _a; diff --git a/tests/baselines/reference/typeArgumentInferenceWithClassExpression2.js b/tests/baselines/reference/typeArgumentInferenceWithClassExpression2.js index 66da2ffbff6..bd221a30137 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithClassExpression2.js +++ b/tests/baselines/reference/typeArgumentInferenceWithClassExpression2.js @@ -16,9 +16,11 @@ function foo(x) { return undefined; } // Should not infer string because it is a static property -foo((function () { - function class_2() { - } - class_2.prop = "hello"; - return class_2; -}())).length; +foo((_a = (function () { + function class_2() { + } + return class_2; + }()), + _a.prop = "hello", + _a)).length; +var _a; diff --git a/tests/baselines/reference/typeOfPrototype.js b/tests/baselines/reference/typeOfPrototype.js index 3e8b3186936..a0f076113e0 100644 --- a/tests/baselines/reference/typeOfPrototype.js +++ b/tests/baselines/reference/typeOfPrototype.js @@ -11,7 +11,7 @@ var Foo = (function () { function Foo() { this.bar = 3; } - Foo.bar = ''; return Foo; }()); +Foo.bar = ''; Foo.prototype.bar = undefined; // Should be OK diff --git a/tests/baselines/reference/typeOfThisInStaticMembers2.js b/tests/baselines/reference/typeOfThisInStaticMembers2.js index b01770446be..886ea04e23d 100644 --- a/tests/baselines/reference/typeOfThisInStaticMembers2.js +++ b/tests/baselines/reference/typeOfThisInStaticMembers2.js @@ -11,12 +11,12 @@ class C2 { var C = (function () { function C() { } - C.foo = this; // error return C; }()); +C.foo = this; // error var C2 = (function () { function C2() { } - C2.foo = this; // error return C2; }()); +C2.foo = this; // error diff --git a/tests/baselines/reference/typeQueryOnClass.js b/tests/baselines/reference/typeQueryOnClass.js index 85dff0de831..80623af5be8 100644 --- a/tests/baselines/reference/typeQueryOnClass.js +++ b/tests/baselines/reference/typeQueryOnClass.js @@ -99,10 +99,10 @@ var C = (function () { enumerable: true, configurable: true }); - C.sa = 1; - C.sb = function () { return 1; }; return C; }()); +C.sa = 1; +C.sb = function () { return 1; }; var c; // BUG 820454 var r1; diff --git a/tests/baselines/reference/unqualifiedCallToClassStatic1.js b/tests/baselines/reference/unqualifiedCallToClassStatic1.js index 6c78a737fe8..906e9d3795f 100644 --- a/tests/baselines/reference/unqualifiedCallToClassStatic1.js +++ b/tests/baselines/reference/unqualifiedCallToClassStatic1.js @@ -10,9 +10,9 @@ class Vector { var Vector = (function () { function Vector() { } - Vector.foo = function () { - // 'foo' cannot be called in an unqualified manner. - foo(); - }; return Vector; }()); +Vector.foo = function () { + // 'foo' cannot be called in an unqualified manner. + foo(); +}; diff --git a/tests/baselines/reference/witness.js b/tests/baselines/reference/witness.js index e0a4c356873..56294a7cbb9 100644 --- a/tests/baselines/reference/witness.js +++ b/tests/baselines/reference/witness.js @@ -262,9 +262,9 @@ var c2inst; var C3 = (function () { function C3() { } - C3.q = C3.q; return C3; }()); +C3.q = C3.q; var qq = C3.q; var qq; // Parentheses - tested a bunch above diff --git a/tests/cases/unittests/transpile.ts b/tests/cases/unittests/transpile.ts index 6f46bb53405..084b2b08eab 100644 --- a/tests/cases/unittests/transpile.ts +++ b/tests/cases/unittests/transpile.ts @@ -2,26 +2,26 @@ module ts { describe("Transpile", () => { - + interface TranspileTestSettings { options?: TranspileOptions; expectedOutput?: string; expectedDiagnosticCodes?: number[]; } - + function checkDiagnostics(diagnostics: Diagnostic[], expectedDiagnosticCodes?: number[]) { if(!expectedDiagnosticCodes) { return; } - + for (let i = 0; i < expectedDiagnosticCodes.length; i++) { assert.equal(expectedDiagnosticCodes[i], diagnostics[i] && diagnostics[i].code, `Could not find expeced diagnostic.`); } - assert.equal(diagnostics.length, expectedDiagnosticCodes.length, "Resuting diagnostics count does not match expected"); + assert.equal(diagnostics.length, expectedDiagnosticCodes.length, "Resuting diagnostics count does not match expected"); } - + function test(input: string, testSettings: TranspileTestSettings): void { - + let transpileOptions: TranspileOptions = testSettings.options || {}; if (!transpileOptions.compilerOptions) { transpileOptions.compilerOptions = {}; @@ -30,43 +30,43 @@ module ts { // use \r\n as default new line transpileOptions.compilerOptions.newLine = ts.NewLineKind.CarriageReturnLineFeed; } - - let canUseOldTranspile = !transpileOptions.renamedDependencies; - + + let canUseOldTranspile = !transpileOptions.renamedDependencies; + transpileOptions.reportDiagnostics = true; let transpileModuleResult = transpileModule(input, transpileOptions); - + checkDiagnostics(transpileModuleResult.diagnostics, testSettings.expectedDiagnosticCodes); - + if (testSettings.expectedOutput !== undefined) { assert.equal(transpileModuleResult.outputText, testSettings.expectedOutput); } - + if (canUseOldTranspile) { let diagnostics: Diagnostic[] = []; - let transpileResult = transpile(input, transpileOptions.compilerOptions, transpileOptions.fileName, diagnostics, transpileOptions.moduleName); + let transpileResult = transpile(input, transpileOptions.compilerOptions, transpileOptions.fileName, diagnostics, transpileOptions.moduleName); checkDiagnostics(diagnostics, testSettings.expectedDiagnosticCodes); if (testSettings.expectedOutput) { assert.equal(transpileResult, testSettings.expectedOutput); } } - + // check source maps if (!transpileOptions.compilerOptions) { transpileOptions.compilerOptions = {}; } - + if (!transpileOptions.fileName) { transpileOptions.fileName = transpileOptions.compilerOptions.jsx ? "file.tsx" : "file.ts"; } - + transpileOptions.compilerOptions.sourceMap = true; let transpileModuleResultWithSourceMap = transpileModule(input, transpileOptions); assert.isTrue(transpileModuleResultWithSourceMap.sourceMapText !== undefined); - + let expectedSourceMapFileName = removeFileExtension(getBaseFileName(normalizeSlashes(transpileOptions.fileName))) + ".js.map"; let expectedSourceMappingUrlLine = `//# sourceMappingURL=${expectedSourceMapFileName}`; - + if (testSettings.expectedOutput !== undefined) { assert.equal(transpileModuleResultWithSourceMap.outputText, testSettings.expectedOutput + expectedSourceMappingUrlLine); } @@ -81,10 +81,10 @@ module ts { let suffix = getNewLineCharacter(transpileOptions.compilerOptions) + expectedSourceMappingUrlLine assert.isTrue(output.indexOf(suffix, output.length - suffix.length) !== -1); } - } + } } - + it("Generates correct compilerOptions diagnostics", () => { // Expecting 5047: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher." test(`var x = 0;`, { expectedDiagnosticCodes: [5047] }); @@ -97,7 +97,7 @@ module ts { it("Generates no diagnostics for missing file references", () => { test(`/// -var x = 0;`, +var x = 0;`, { options: { compilerOptions: { module: ModuleKind.CommonJS } } }); }); @@ -117,17 +117,17 @@ var x = 0;`, }); it("Generates module output", () => { - test(`var x = 0;`, - { - options: { compilerOptions: { module: ModuleKind.AMD } }, + test(`var x = 0;`, + { + options: { compilerOptions: { module: ModuleKind.AMD } }, expectedOutput: `define(["require", "exports"], function (require, exports) {\r\n "use strict";\r\n var x = 0;\r\n});\r\n` }); }); it("Uses correct newLine character", () => { - test(`var x = 0;`, - { - options: { compilerOptions: { module: ModuleKind.CommonJS, newLine: NewLineKind.LineFeed } }, + test(`var x = 0;`, + { + options: { compilerOptions: { module: ModuleKind.CommonJS, newLine: NewLineKind.LineFeed } }, expectedOutput: `"use strict";\nvar x = 0;\n` }); }); @@ -145,9 +145,9 @@ var x = 0;`, ` }\n` + ` }\n` + `});\n`; - test("var x = 1;", - { - options: { compilerOptions: { module: ModuleKind.System, newLine: NewLineKind.LineFeed }, moduleName: "NamedModule" }, + test("var x = 1;", + { + options: { compilerOptions: { module: ModuleKind.System, newLine: NewLineKind.LineFeed }, moduleName: "NamedModule" }, expectedOutput: output }) }); @@ -157,7 +157,7 @@ var x = 0;`, }); it("Rename dependencies - System", () => { - let input = + let input = `import {foo} from "SomeName";\n` + `declare function use(a: any);\n` + `use(foo);` @@ -177,15 +177,15 @@ var x = 0;`, ` }\n` + `});\n` - test(input, - { - options: { compilerOptions: { module: ModuleKind.System, newLine: NewLineKind.LineFeed }, renamedDependencies: { "SomeName": "SomeOtherName" } }, + test(input, + { + options: { compilerOptions: { module: ModuleKind.System, newLine: NewLineKind.LineFeed }, renamedDependencies: { "SomeName": "SomeOtherName" } }, expectedOutput: output }); }); it("Rename dependencies - AMD", () => { - let input = + let input = `import {foo} from "SomeName";\n` + `declare function use(a: any);\n` + `use(foo);` @@ -195,15 +195,15 @@ var x = 0;`, ` use(SomeName_1.foo);\n` + `});\n`; - test(input, - { - options: { compilerOptions: { module: ModuleKind.AMD, newLine: NewLineKind.LineFeed }, renamedDependencies: { "SomeName": "SomeOtherName" } }, + test(input, + { + options: { compilerOptions: { module: ModuleKind.AMD, newLine: NewLineKind.LineFeed }, renamedDependencies: { "SomeName": "SomeOtherName" } }, expectedOutput: output }); }); it("Rename dependencies - UMD", () => { - let input = + let input = `import {foo} from "SomeName";\n` + `declare function use(a: any);\n` + `use(foo);` @@ -221,15 +221,15 @@ var x = 0;`, ` use(SomeName_1.foo);\n` + `});\n`; - test(input, - { - options: { compilerOptions: { module: ModuleKind.UMD, newLine: NewLineKind.LineFeed }, renamedDependencies: { "SomeName": "SomeOtherName" } }, + test(input, + { + options: { compilerOptions: { module: ModuleKind.UMD, newLine: NewLineKind.LineFeed }, renamedDependencies: { "SomeName": "SomeOtherName" } }, expectedOutput: output }); }); - + it("Transpile with emit decorators and emit metadata", () => { - let input = + let input = `import {db} from './db';\n` + `function someDecorator(target) {\n` + ` return target;\n` + @@ -245,26 +245,26 @@ var x = 0;`, `export {MyClass}; \n` let output = `"use strict";\n` + - `var db_1 = require(\'./db\');\n` + + `var db_1 = require(\'./db\');\n` + `function someDecorator(target) {\n` + ` return target;\n` + - `}\n` + - `var MyClass = (function () {\n` + - ` function MyClass(db) {\n` + - ` this.db = db;\n` + - ` this.db.doSomething();\n` + - ` }\n` + - ` MyClass = __decorate([\n` + - ` someDecorator, \n` + - ` __metadata(\'design:paramtypes\', [(typeof (_a = typeof db_1.db !== \'undefined\' && db_1.db) === \'function\' && _a) || Object])\n` + - ` ], MyClass);\n` + - ` return MyClass;\n` + - ` var _a;\n` + - `}());\n` + - `exports.MyClass = MyClass;\n`; + `}\n` + + `var MyClass = (function () {\n` + + ` function MyClass(db) {\n` + + ` this.db = db;\n` + + ` this.db.doSomething();\n` + + ` }\n` + + ` return MyClass;\n` + + `}());\n` + + `MyClass = __decorate([\n` + + ` someDecorator, \n` + + ` __metadata(\'design:paramtypes\', [(typeof (_a = typeof db_1.db !== \'undefined\' && db_1.db) === \'function\' && _a) || Object])\n` + + `], MyClass);\n` + + `exports.MyClass = MyClass;\n` + + `var _a;\n`; - test(input, - { + test(input, + { options: { compilerOptions: { module: ModuleKind.CommonJS, @@ -274,7 +274,7 @@ var x = 0;`, experimentalDecorators: true, target: ScriptTarget.ES5, } - }, + }, expectedOutput: output }); }); @@ -282,7 +282,7 @@ var x = 0;`, it("Supports backslashes in file name", () => { test("var x", { expectedOutput: `"use strict";\r\nvar x;\r\n`, options: { fileName: "a\\b.ts" }}); }); - + it("transpile file as 'tsx' if 'jsx' is specified", () => { let input = `var x =
`; let output = `"use strict";\nvar x = React.createElement("div", null);\n`; From 359875b67de61c9acb68ae4f56540730f11e3508 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 29 Feb 2016 15:07:23 -0800 Subject: [PATCH 3/7] PR Feedback --- src/compiler/factory.ts | 2 +- src/compiler/transformers/ts.ts | 47 ++++++++++++++++++++------------- src/compiler/utilities.ts | 4 +++ 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index eae769fd562..ef908c40a9b 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -213,7 +213,7 @@ namespace ts { return name; } - export function createGeneratedNameForNode(node: Node, location?: TextRange): Identifier { + export function getGeneratedNameForNode(node: Node, location?: TextRange): Identifier { const name = createNode(SyntaxKind.Identifier, location); name.autoGenerateKind = GeneratedIdentifierKind.Node; name.original = node; diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index d791dd1eb4c..e672a0a79cd 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -8,8 +8,6 @@ namespace ts { export function transformTypeScript(context: TransformationContext) { const { - getGeneratedNameForNode, - makeUniqueName, setNodeEmitFlags, startLexicalEnvironment, endLexicalEnvironment, @@ -496,7 +494,7 @@ namespace ts { // Record an alias to avoid class double-binding. if (resolver.getNodeCheckFlags(getOriginalNode(node)) & NodeCheckFlags.ClassWithBodyScopedClassBinding) { enableExpressionSubstitutionForDecoratedClasses(); - decoratedClassAlias = makeUniqueName(node.name ? node.name.text : "default"); + decoratedClassAlias = createUniqueName(node.name && !isGeneratedIdentifier(node.name) ? node.name.text : "default"); decoratedClassAliases[getOriginalNodeId(node)] = decoratedClassAlias; // We emit the class alias as a `let` declaration here so that it has the same @@ -691,7 +689,7 @@ namespace ts { function transformConstructorParameters(constructor: ConstructorDeclaration, hasExtendsClause: boolean) { return constructor ? visitNodes(constructor.parameters, visitor, isParameter) - : hasExtendsClause ? [createRestParameter(makeUniqueName("args"))] : []; + : hasExtendsClause ? [createRestParameter(createUniqueName("args"))] : []; } /** @@ -2103,14 +2101,15 @@ namespace ts { } const savedCurrentNamespaceLocalName = currentNamespaceLocalName; - const modifiers = visitNodes(node.modifiers, visitor, isModifier); const statements: Statement[] = []; let location: TextRange = node; - if (!isNamespaceExport(node)) { + if (!isExported(node) || (isExternalModuleExport(node) && isFirstDeclarationOfKind(node, SyntaxKind.EnumDeclaration))) { + // Emit a VariableStatement if the enum is not exported, or is the first enum + // with the same name exported from an external module. addNode(statements, createVariableStatement( - modifiers, + visitNodes(node.modifiers, visitor, isModifier), createVariableDeclarationList([ createVariableDeclaration(node.name) ]), @@ -2179,7 +2178,7 @@ namespace ts { * * @param member The enum member node. */ - function transformEnumMember(member: EnumMember) { + function transformEnumMember(member: EnumMember): Statement { const name = getExpressionForPropertyName(member); return createStatement( createAssignment( @@ -2443,14 +2442,31 @@ namespace ts { && (isExternalModule(currentSourceFile) || !resolver.isTopLevelValueImportEqualsWithEntityName(node)); } + /** + * Gets a value indicating whether the node is exported. + * + * @param node The node to test. + */ + function isExported(node: Node) { + return (node.flags & NodeFlags.Export) !== 0; + } + + /** + * Gets a value indicating whether the node is exported from a namespace. + * + * @param node The node to test. + */ + function isNamespaceExport(node: Node) { + return currentNamespace !== undefined && isExported(node); + } + /** * Gets a value indicating whether the node is exported from an external module. * * @param node The node to test. */ function isExternalModuleExport(node: Node) { - return currentNamespace === undefined - && (node.flags & NodeFlags.Export) !== 0; + return currentNamespace === undefined && isExported(node); } /** @@ -2473,14 +2489,9 @@ namespace ts { && (node.flags & NodeFlags.Default) !== 0; } - /** - * Gets a value indicating whether the node is exported from a namespace. - * - * @param node The node to test. - */ - function isNamespaceExport(node: Node) { - return currentNamespace !== undefined - && (node.flags & NodeFlags.Export) !== 0; + function isFirstDeclarationOfKind(node: Declaration, kind: SyntaxKind) { + const original = getOriginalNode(node); + return !forEach(original.symbol && original.symbol.declarations, declaration => declaration.kind === kind && declaration.pos < original.pos); } /** diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index b700498cd4d..1b707cedc48 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2865,6 +2865,10 @@ namespace ts { return node.kind === SyntaxKind.Identifier; } + export function isGeneratedIdentifier(node: Node): node is Identifier { + return isIdentifier(node) && node.autoGenerateKind > GeneratedIdentifierKind.Node; + } + // Keywords export function isModifier(node: Node): node is Modifier { From fe7ad5fde3ec24e8caeb7a5ed712119e5606d541 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 29 Feb 2016 15:39:38 -0800 Subject: [PATCH 4/7] Minor tweaks to naming --- src/compiler/factory.ts | 20 +++++++++++++++----- src/compiler/transformers/ts.ts | 10 +++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index ef908c40a9b..0ad04c0a092 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -153,7 +153,21 @@ namespace ts { * Creates a shallow, memberwise clone of a node for mutation. */ export function getMutableNode(node: T): T { - return cloneNode(node, node, node.flags, node.parent, node); + return cloneNode(node, /*location*/ node, node.flags, /*parent*/ undefined, /*original*/ node); + } + + /** + * Creates a shallow, memberwise clone of a node with no source map location. + */ + export function getSynthesizedClone(node: T): T { + return nodeIsSynthesized(node) ? node : cloneNode(node, /*location*/ undefined, node.flags, /*parent*/ undefined, /*original*/ node); + } + + /** + * Creates a shallow, memberwise clone of a node at the specified source map location. + */ + export function getRelocatedClone(node: T, location: TextRange): T { + return cloneNode(node, location, node.flags, /*parent*/ undefined, /*original*/ node); } export function createNodeArrayNode(elements: T[]): NodeArrayNode { @@ -1340,8 +1354,4 @@ namespace ts { node.flags = flags; return node; } - - export function getSynthesizedNode(node: T): T { - return nodeIsSynthesized(node) ? node : cloneNode(node, /*location*/ undefined, node.flags, /*parent*/ undefined, /*original*/ node); - } } \ No newline at end of file diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index e672a0a79cd..b7a180aab92 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -1644,7 +1644,7 @@ namespace ts { return createLiteral(name.text); } else { - return getSynthesizedNode(name); + return getSynthesizedClone(name); } } @@ -1813,7 +1813,7 @@ namespace ts { if (isNamespaceExport(node)) { return createNodeArrayNode([ func, - createNamespaceExport(getSynthesizedNode(node.name), getSynthesizedNode(node.name)) + createNamespaceExport(getSynthesizedClone(node.name), getSynthesizedClone(node.name)) ]); } @@ -2420,7 +2420,7 @@ namespace ts { // exports.${name} = ${moduleReference}; return setOriginalNode( createNamespaceExport( - getSynthesizedNode(node.name), + getSynthesizedClone(node.name), moduleReference, node ), @@ -2520,14 +2520,14 @@ namespace ts { } function getNamespaceMemberName(name: Identifier): Expression { - name = getSynthesizedNode(name); + name = getSynthesizedClone(name); return currentNamespaceLocalName ? createPropertyAccess(currentNamespaceLocalName, name) : name; } function getDeclarationName(node: ClassExpression | ClassDeclaration | FunctionDeclaration) { - return node.name ? getSynthesizedNode(node.name) : getGeneratedNameForNode(node); + return node.name ? getSynthesizedClone(node.name) : getGeneratedNameForNode(node); } function getClassPrototype(node: ClassExpression | ClassDeclaration) { From a0dbe7601cf3eb5fff2a5aa61c459cee868b6e25 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 29 Feb 2016 17:35:50 -0800 Subject: [PATCH 5/7] PR Feedback --- src/compiler/checker.ts | 6 +- src/compiler/emitter.ts | 6 +- src/compiler/printer.ts | 2 +- src/compiler/transformers/ts.ts | 458 ++++++++++++++++++-------------- src/compiler/types.ts | 4 +- src/compiler/utilities.ts | 5 +- 6 files changed, 269 insertions(+), 212 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3cb9031fd99..278159469e1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4846,7 +4846,7 @@ namespace ts { const parent = container && container.parent; if (parent && (isClassLike(parent) || parent.kind === SyntaxKind.InterfaceDeclaration)) { if (!(container.flags & NodeFlags.Static) && - (container.kind !== SyntaxKind.Constructor || isNodeDescendentOf(node, (container).body))) { + (container.kind !== SyntaxKind.Constructor || isNodeDescendantOf(node, (container).body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -7206,8 +7206,8 @@ namespace ts { let container = getContainingClass(node); while (container !== undefined) { if (container === localOrExportSymbol.valueDeclaration && container.name !== node) { - getNodeLinks(container).flags |= NodeCheckFlags.ClassWithBodyScopedClassBinding; - getNodeLinks(node).flags |= NodeCheckFlags.BodyScopedClassBinding; + getNodeLinks(container).flags |= NodeCheckFlags.DecoratedClassWithSelfReference; + getNodeLinks(node).flags |= NodeCheckFlags.SelfReferenceInDecoratedClass; break; } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a3c27d8d817..bda2bd79506 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -346,7 +346,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; function isUniqueLocalName(name: string, container: Node): boolean { - for (let node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + for (let node = container; isNodeDescendantOf(node, container); node = node.nextContainer) { if (node.locals && hasProperty(node.locals, name)) { // We conservatively include alias symbols to cover cases where they're emitted as locals if (node.locals[name].flags & (SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias)) { @@ -1529,7 +1529,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge return; } } - else if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.BodyScopedClassBinding) { + else if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.SelfReferenceInDecoratedClass) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -5203,7 +5203,7 @@ const _super = (function (geti, seti) { // [Example 4] // - if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.ClassWithBodyScopedClassBinding) { + if (resolver.getNodeCheckFlags(node) & NodeCheckFlags.DecoratedClassWithSelfReference) { decoratedClassAlias = unescapeIdentifier(makeUniqueName(node.name ? node.name.text : "default")); decoratedClassAliases[getNodeId(node)] = decoratedClassAlias; write(`let ${decoratedClassAlias};`); diff --git a/src/compiler/printer.ts b/src/compiler/printer.ts index e44e88b4612..331e502b931 100644 --- a/src/compiler/printer.ts +++ b/src/compiler/printer.ts @@ -2368,7 +2368,7 @@ const _super = (function (geti, seti) { } function isUniqueLocalName(name: string, container: Node): boolean { - for (let node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { + for (let node = container; isNodeDescendantOf(node, container); node = node.nextContainer) { if (node.locals && hasProperty(node.locals, name)) { // We conservatively include alias symbols to cover cases where they're emitted as locals if (node.locals[name].flags & (SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias)) { diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index b7a180aab92..58f06cb214e 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -6,6 +6,15 @@ namespace ts { type SuperContainer = ClassDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration; + const enum TypeScriptSubstitutionFlags { + /** Enables substitutions for decorated classes. */ + DecoratedClasses = 1 << 0, + /** Enables substitutions for namespace exports. */ + NamespaceExports = 1 << 1, + /** Enables substitutions for async methods with `super` calls. */ + AsyncMethodsWithSuper = 1 << 2, + } + export function transformTypeScript(context: TransformationContext) { const { setNodeEmitFlags, @@ -19,14 +28,14 @@ namespace ts { const languageVersion = getEmitScriptTarget(compilerOptions); // Save the previous transformation hooks. - const previousExpressionSubstitution = context.expressionSubstitution; const previousOnBeforeEmitNode = context.onBeforeEmitNode; const previousOnAfterEmitNode = context.onAfterEmitNode; + const previousExpressionSubstitution = context.expressionSubstitution; // Set new transformation hooks. - context.expressionSubstitution = substituteExpression; context.onBeforeEmitNode = onBeforeEmitNode; context.onAfterEmitNode = onAfterEmitNode; + context.expressionSubstitution = substituteExpression; // These variables contain state that changes as we descend into the tree. let currentSourceFile: SourceFile; @@ -36,31 +45,46 @@ namespace ts { let currentParent: Node; let currentNode: Node; - // These variables keep track of whether expression substitution has been enabled for - // specific edge cases. They are persisted between each SourceFile transformation and - // should not be reset. - let hasEnabledExpressionSubstitutionForDecoratedClasses = false; - let hasEnabledExpressionSubstitutionForNamespaceExports = false; - let hasEnabledExpressionSubstitutionForAsyncMethodsWithSuper = false; + /** + * Keeps track of whether expression substitution has been enabled for specific edge cases. + * They are persisted between each SourceFile transformation and should not be reset. + */ + let enabledSubstitutions: TypeScriptSubstitutionFlags; - // This map keeps track of aliases created for classes with decorators to avoid issues - // with the double-binding behavior of classes. + /** + * A map that keeps track of aliases created for classes with decorators to avoid issues + * with the double-binding behavior of classes. + */ let decoratedClassAliases: Map; - // This map keeps track of currently active aliases defined in `decoratedClassAliases` - // when just-in-time substitution occurs while printing an expression identifier. + /** + * A map that keeps track of currently active aliases defined in `decoratedClassAliases` + * when just-in-time substitution occurs while printing an expression identifier. + */ let currentDecoratedClassAliases: Map; - // This value keeps track of how deeply nested we are within any containing namespaces - // when performing just-in-time substitution while printing an expression identifier. + /** + * Keeps track of how deeply nested we are within any containing namespaces + * when performing just-in-time substitution while printing an expression identifier. + * If the nest level is greater than zero, then we are performing a substitution + * inside of a namespace and we should perform the more costly checks to determine + * whether the identifier points to an exported declaration. + */ let namespaceNestLevel: number; - // This array keeps track of containers where `super` is valid, for use with - // just-in-time substitution for `super` expressions inside of async methods. + /** + * This array keeps track of containers where `super` is valid, for use with + * just-in-time substitution for `super` expressions inside of async methods. + */ let superContainerStack: SuperContainer[]; return transformSourceFile; + /** + * Transform TypeScript-specific syntax in a SourceFile. + * + * @param node A SourceFile node. + */ function transformSourceFile(node: SourceFile) { currentSourceFile = node; node = visitEachChild(node, visitor, context); @@ -136,8 +160,7 @@ namespace ts { * @param node The node to visit. */ function namespaceElementVisitorWorker(node: Node): Node { - if (node.transformFlags & TransformFlags.TypeScript - || node.flags & NodeFlags.Export) { + if (node.transformFlags & TransformFlags.TypeScript || isExported(node)) { // This node is explicitly marked as TypeScript, or is exported at the namespace // level, so we should transform the node. node = visitTypeScript(node); @@ -165,12 +188,25 @@ namespace ts { * @param node The node to visit. */ function classElementVisitorWorker(node: Node) { - if (node.kind === SyntaxKind.Constructor) { - // TypeScript constructors are elided. - return undefined; - } + switch (node.kind) { + case SyntaxKind.Constructor: + // TypeScript constructors are transformed in `transformClassDeclaration`. + // We elide them here as `visitorWorker` checks transform flags, which could + // erronously include an ES6 constructor without TypeScript syntax. + return undefined; - return visitorWorker(node); + case SyntaxKind.PropertyDeclaration: + case SyntaxKind.IndexSignature: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + case SyntaxKind.MethodDeclaration: + // Fallback to the default visit behavior. + return visitorWorker(node); + + default: + Debug.fail("Unexpected node."); + break; + } } /** @@ -179,9 +215,9 @@ namespace ts { * @param node The node to visit. */ function visitTypeScript(node: Node): Node { - // TypeScript ambient declarations are elided. if (node.flags & NodeFlags.Ambient) { - return; + // TypeScript ambient declarations are elided. + return undefined; } switch (node.kind) { @@ -233,8 +269,7 @@ namespace ts { // TypeScript property declarations are elided. case SyntaxKind.Constructor: - // TypeScript constructors are elided. The constructor of a class will be - // transformed as part of `transformClassDeclaration`. + // TypeScript constructors are transformed in `transformClassDeclaration`. return undefined; case SyntaxKind.ClassDeclaration: @@ -376,11 +411,7 @@ namespace ts { */ function visitClassDeclaration(node: ClassDeclaration): NodeArrayNode { const staticProperties = getInitializedProperties(node, /*isStatic*/ true); - const statements: Statement[] = []; - const modifiers = visitNodes(node.modifiers, visitor, isModifier); - const heritageClauses = visitNodes(node.heritageClauses, visitor, isHeritageClause); - const members = transformClassMembers(node, heritageClauses !== undefined); - let decoratedClassAlias: Identifier; + const hasExtendsClause = getClassExtendsHeritageClauseElement(node) !== undefined; // emit name if // - node has a name @@ -391,166 +422,28 @@ namespace ts { name = getGeneratedNameForNode(node); } - if (node.decorators) { - // When we emit an ES6 class that has a class decorator, we must tailor the - // emit to certain specific cases. - // - // In the simplest case, we emit the class declaration as a let declaration, and - // evaluate decorators after the close of the class body: - // - // [Example 1] - // --------------------------------------------------------------------- - // TypeScript | Javascript - // --------------------------------------------------------------------- - // @dec | let C = class C { - // class C { | } - // } | C = __decorate([dec], C); - // --------------------------------------------------------------------- - // @dec | let C = class C { - // export class C { | } - // } | C = __decorate([dec], C); - // | export { C }; - // --------------------------------------------------------------------- - // - // If a class declaration contains a reference to itself *inside* of the class body, - // this introduces two bindings to the class: One outside of the class body, and one - // inside of the class body. If we apply decorators as in [Example 1] above, there - // is the possibility that the decorator `dec` will return a new value for the - // constructor, which would result in the binding inside of the class no longer - // pointing to the same reference as the binding outside of the class. - // - // As a result, we must instead rewrite all references to the class *inside* of the - // class body to instead point to a local temporary alias for the class: - // - // [Example 2] - // --------------------------------------------------------------------- - // TypeScript | Javascript - // --------------------------------------------------------------------- - // @dec | let C_1; - // class C { | let C = C_1 = class C { - // static x() { return C.y; } | static x() { return C_1.y; } - // static y = 1; | } - // } | C.y = 1; - // | C = C_1 = __decorate([dec], C); - // --------------------------------------------------------------------- - // @dec | let C_1; - // export class C { | let C = C_1 = class C { - // static x() { return C.y; } | static x() { return C_1.y; } - // static y = 1; | } - // } | C.y = 1; - // | C = C_1 = __decorate([dec], C); - // | export { C }; - // --------------------------------------------------------------------- - // - // If a class declaration is the default export of a module, we instead emit - // the export after the decorated declaration: - // - // [Example 3] - // --------------------------------------------------------------------- - // TypeScript | Javascript - // --------------------------------------------------------------------- - // @dec | let default_1 = class { - // export default class { | } - // } | default_1 = __decorate([dec], default_1); - // | export default default_1; - // --------------------------------------------------------------------- - // @dec | let C = class C { - // export default class C { | } - // } | C = __decorate([dec], C); - // | export default C; - // --------------------------------------------------------------------- - // - // If the class declaration is the default export and a reference to itself - // inside of the class body, we must emit both an alias for the class *and* - // move the export after the declaration: - // - // [Example 4] - // --------------------------------------------------------------------- - // TypeScript | Javascript - // --------------------------------------------------------------------- - // @dec | let C_1; - // export default class C { | let C = C_1 = class C { - // static x() { return C.y; } | static x() { return C_1.y; } - // static y = 1; | } - // } | C.y = 1; - // | C = C_1 = __decorate([dec], C); - // | export default C; - // --------------------------------------------------------------------- - // - - // class ${name} ${heritageClauses} { - // ${members} - // } - let classExpression: Expression = setOriginalNode( - createClassExpression( - name, - heritageClauses, - members, - /*location*/ node - ), - node - ); - - // Record an alias to avoid class double-binding. - if (resolver.getNodeCheckFlags(getOriginalNode(node)) & NodeCheckFlags.ClassWithBodyScopedClassBinding) { - enableExpressionSubstitutionForDecoratedClasses(); - decoratedClassAlias = createUniqueName(node.name && !isGeneratedIdentifier(node.name) ? node.name.text : "default"); - decoratedClassAliases[getOriginalNodeId(node)] = decoratedClassAlias; - - // We emit the class alias as a `let` declaration here so that it has the same - // TDZ as the class. - - // let ${decoratedClassAlias}; - addNode(statements, - createVariableStatement( - /*modifiers*/ undefined, - createVariableDeclarationList([ - createVariableDeclaration(decoratedClassAlias) - ], - /*location*/ undefined, - NodeFlags.Let) - ) - ); - - // ${decoratedClassAlias} = ${classExpression} - classExpression = createAssignment( - cloneNode(decoratedClassAlias), - classExpression, - /*location*/ node); - } - - // let ${name} = ${classExpression}; - addNode(statements, - createVariableStatement( - /*modifiers*/ undefined, - createVariableDeclarationList([ - createVariableDeclaration( - name, - classExpression - ) - ], - /*location*/ undefined, - NodeFlags.Let) - ) - ); - } - else { + let decoratedClassAlias: Identifier; + const statements: Statement[] = []; + if (!node.decorators) { // ${modifiers} class ${name} ${heritageClauses} { // ${members} // } addNode(statements, setOriginalNode( createClassDeclaration( - modifiers, + visitNodes(node.modifiers, visitor, isModifier), name, - heritageClauses, - members, + visitNodes(node.heritageClauses, visitor, isHeritageClause), + transformClassMembers(node, hasExtendsClause), /*location*/ node ), node ) ); } + else { + decoratedClassAlias = addClassDeclarationHeadWithDecorators(statements, node, name, hasExtendsClause); + } // Emit static property assignment. Because classDeclaration is lexically evaluated, // it is safe to emit static property assignment after classDeclaration @@ -575,13 +468,168 @@ namespace ts { addNode(statements, createExportDefault(name)); } else if (isNamedExternalModuleExport(node)) { - addNode(statements, createModuleExport(name)); + addNode(statements, createExternalModuleExport(name)); } } return createNodeArrayNode(statements); } + /** + * Transforms a decorated class declaration and appends the resulting statements. If + * the class requires an alias to avoid issues with double-binding, the alias is returned. + * + * @param node A ClassDeclaration node. + * @param name The name of the class. + * @param hasExtendsClause A value indicating whether + */ + function addClassDeclarationHeadWithDecorators(statements: Statement[], node: ClassDeclaration, name: Identifier, hasExtendsClause: boolean) { + // When we emit an ES6 class that has a class decorator, we must tailor the + // emit to certain specific cases. + // + // In the simplest case, we emit the class declaration as a let declaration, and + // evaluate decorators after the close of the class body: + // + // [Example 1] + // --------------------------------------------------------------------- + // TypeScript | Javascript + // --------------------------------------------------------------------- + // @dec | let C = class C { + // class C { | } + // } | C = __decorate([dec], C); + // --------------------------------------------------------------------- + // @dec | let C = class C { + // export class C { | } + // } | C = __decorate([dec], C); + // | export { C }; + // --------------------------------------------------------------------- + // + // If a class declaration contains a reference to itself *inside* of the class body, + // this introduces two bindings to the class: One outside of the class body, and one + // inside of the class body. If we apply decorators as in [Example 1] above, there + // is the possibility that the decorator `dec` will return a new value for the + // constructor, which would result in the binding inside of the class no longer + // pointing to the same reference as the binding outside of the class. + // + // As a result, we must instead rewrite all references to the class *inside* of the + // class body to instead point to a local temporary alias for the class: + // + // [Example 2] + // --------------------------------------------------------------------- + // TypeScript | Javascript + // --------------------------------------------------------------------- + // @dec | let C_1; + // class C { | let C = C_1 = class C { + // static x() { return C.y; } | static x() { return C_1.y; } + // static y = 1; | } + // } | C.y = 1; + // | C = C_1 = __decorate([dec], C); + // --------------------------------------------------------------------- + // @dec | let C_1; + // export class C { | let C = C_1 = class C { + // static x() { return C.y; } | static x() { return C_1.y; } + // static y = 1; | } + // } | C.y = 1; + // | C = C_1 = __decorate([dec], C); + // | export { C }; + // --------------------------------------------------------------------- + // + // If a class declaration is the default export of a module, we instead emit + // the export after the decorated declaration: + // + // [Example 3] + // --------------------------------------------------------------------- + // TypeScript | Javascript + // --------------------------------------------------------------------- + // @dec | let default_1 = class { + // export default class { | } + // } | default_1 = __decorate([dec], default_1); + // | export default default_1; + // --------------------------------------------------------------------- + // @dec | let C = class C { + // export default class C { | } + // } | C = __decorate([dec], C); + // | export default C; + // --------------------------------------------------------------------- + // + // If the class declaration is the default export and a reference to itself + // inside of the class body, we must emit both an alias for the class *and* + // move the export after the declaration: + // + // [Example 4] + // --------------------------------------------------------------------- + // TypeScript | Javascript + // --------------------------------------------------------------------- + // @dec | let C_1; + // export default class C { | let C = C_1 = class C { + // static x() { return C.y; } | static x() { return C_1.y; } + // static y = 1; | } + // } | C.y = 1; + // | C = C_1 = __decorate([dec], C); + // | export default C; + // --------------------------------------------------------------------- + // + + // ... = class ${name} ${heritageClauses} { + // ${members} + // } + let classExpression: Expression = setOriginalNode( + createClassExpression( + name, + visitNodes(node.heritageClauses, visitor, isHeritageClause), + transformClassMembers(node, hasExtendsClause), + /*location*/ node + ), + node + ); + + // Record an alias to avoid class double-binding. + let decoratedClassAlias: Identifier; + if (resolver.getNodeCheckFlags(getOriginalNode(node)) & NodeCheckFlags.DecoratedClassWithSelfReference) { + enableExpressionSubstitutionForDecoratedClasses(); + decoratedClassAlias = createUniqueName(node.name && !isGeneratedIdentifier(node.name) ? node.name.text : "default"); + decoratedClassAliases[getOriginalNodeId(node)] = decoratedClassAlias; + + // We emit the class alias as a `let` declaration here so that it has the same + // TDZ as the class. + + // let ${decoratedClassAlias}; + addNode(statements, + createVariableStatement( + /*modifiers*/ undefined, + createVariableDeclarationList([ + createVariableDeclaration(decoratedClassAlias) + ], + /*location*/ undefined, + NodeFlags.Let) + ) + ); + + // ${decoratedClassAlias} = ${classExpression} + classExpression = createAssignment( + decoratedClassAlias, + classExpression, + /*location*/ node); + } + + // let ${name} = ${classExpression}; + addNode(statements, + createVariableStatement( + /*modifiers*/ undefined, + createVariableDeclarationList([ + createVariableDeclaration( + name, + classExpression + ) + ], + /*location*/ undefined, + NodeFlags.Let) + ) + ); + + return decoratedClassAlias; + } + /** * Transforms a class expression with TypeScript syntax into compatible ES6. * @@ -638,7 +686,7 @@ namespace ts { const members: ClassElement[] = []; addNode(members, transformConstructor(node, hasExtendsClause)); addNodes(members, visitNodes(node.members, classElementVisitor, isClassElement)); - return members; + return createNodeArray(members, /*location*/ node.members); } /** @@ -2489,9 +2537,15 @@ namespace ts { && (node.flags & NodeFlags.Default) !== 0; } + /** + * Gets a value indicating whether a node is the first declaration of its kind. + * + * @param node A Declaration node. + * @param kind The SyntaxKind to find among related declarations. + */ function isFirstDeclarationOfKind(node: Declaration, kind: SyntaxKind) { const original = getOriginalNode(node); - return !forEach(original.symbol && original.symbol.declarations, declaration => declaration.kind === kind && declaration.pos < original.pos); + return original.symbol && getDeclarationOfKind(original.symbol, kind) === original; } /** @@ -2511,7 +2565,7 @@ namespace ts { ); } - function createModuleExport(exportName: Identifier) { + function createExternalModuleExport(exportName: Identifier) { return createExportDeclaration( createNamedExports([ createExportSpecifier(exportName) @@ -2544,12 +2598,13 @@ namespace ts { previousOnBeforeEmitNode(node); const kind = node.kind; - if (hasEnabledExpressionSubstitutionForDecoratedClasses - && kind === SyntaxKind.ClassDeclaration && node.decorators) { + if (enabledSubstitutions & TypeScriptSubstitutionFlags.DecoratedClasses + && kind === SyntaxKind.ClassDeclaration + && node.decorators) { currentDecoratedClassAliases[getOriginalNodeId(node)] = decoratedClassAliases[getOriginalNodeId(node)]; } - if (hasEnabledExpressionSubstitutionForAsyncMethodsWithSuper + if (enabledSubstitutions & TypeScriptSubstitutionFlags.NamespaceExports && (kind === SyntaxKind.ClassDeclaration || kind === SyntaxKind.Constructor || kind === SyntaxKind.MethodDeclaration @@ -2563,7 +2618,7 @@ namespace ts { superContainerStack.push(node); } - if (hasEnabledExpressionSubstitutionForNamespaceExports + if (enabledSubstitutions & TypeScriptSubstitutionFlags.NamespaceExports && kind === SyntaxKind.ModuleDeclaration) { namespaceNestLevel++; } @@ -2573,12 +2628,13 @@ namespace ts { previousOnAfterEmitNode(node); const kind = node.kind; - if (hasEnabledExpressionSubstitutionForDecoratedClasses - && kind === SyntaxKind.ClassDeclaration && node.decorators) { + if (enabledSubstitutions & TypeScriptSubstitutionFlags.DecoratedClasses + && kind === SyntaxKind.ClassDeclaration + && node.decorators) { currentDecoratedClassAliases[getOriginalNodeId(node)] = undefined; } - if (hasEnabledExpressionSubstitutionForAsyncMethodsWithSuper + if (enabledSubstitutions & TypeScriptSubstitutionFlags.NamespaceExports && (kind === SyntaxKind.ClassDeclaration || kind === SyntaxKind.Constructor || kind === SyntaxKind.MethodDeclaration @@ -2590,7 +2646,7 @@ namespace ts { } } - if (hasEnabledExpressionSubstitutionForNamespaceExports + if (enabledSubstitutions & TypeScriptSubstitutionFlags.NamespaceExports && kind === SyntaxKind.ModuleDeclaration) { namespaceNestLevel--; } @@ -2604,7 +2660,7 @@ namespace ts { return substituteExpressionIdentifier(node); } - if (hasEnabledExpressionSubstitutionForAsyncMethodsWithSuper) { + if (enabledSubstitutions & TypeScriptSubstitutionFlags.NamespaceExports) { switch (node.kind) { case SyntaxKind.CallExpression: return substituteCallExpression(node); @@ -2619,9 +2675,9 @@ namespace ts { } function substituteExpressionIdentifier(node: Identifier): Expression { - if (hasEnabledExpressionSubstitutionForDecoratedClasses + if (enabledSubstitutions & TypeScriptSubstitutionFlags.DecoratedClasses && !nodeIsSynthesized(node) - && resolver.getNodeCheckFlags(node) & NodeCheckFlags.BodyScopedClassBinding) { + && resolver.getNodeCheckFlags(node) & NodeCheckFlags.SelfReferenceInDecoratedClass) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -2635,7 +2691,7 @@ namespace ts { } } - if (hasEnabledExpressionSubstitutionForNamespaceExports + if (enabledSubstitutions & TypeScriptSubstitutionFlags.NamespaceExports && namespaceNestLevel > 0) { // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. @@ -2702,8 +2758,8 @@ namespace ts { } function enableExpressionSubstitutionForAsyncMethodsWithSuper() { - if (!hasEnabledExpressionSubstitutionForAsyncMethodsWithSuper) { - hasEnabledExpressionSubstitutionForAsyncMethodsWithSuper = true; + if ((enabledSubstitutions & TypeScriptSubstitutionFlags.NamespaceExports) === 0) { + enabledSubstitutions |= TypeScriptSubstitutionFlags.NamespaceExports; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. @@ -2721,8 +2777,8 @@ namespace ts { } function enableExpressionSubstitutionForDecoratedClasses() { - if (!hasEnabledExpressionSubstitutionForDecoratedClasses) { - hasEnabledExpressionSubstitutionForDecoratedClasses = true; + if ((enabledSubstitutions & TypeScriptSubstitutionFlags.DecoratedClasses) === 0) { + enabledSubstitutions |= TypeScriptSubstitutionFlags.DecoratedClasses; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. @@ -2735,8 +2791,8 @@ namespace ts { } function enableExpressionSubstitutionForNamespaceExports() { - if (!hasEnabledExpressionSubstitutionForNamespaceExports) { - hasEnabledExpressionSubstitutionForNamespaceExports = true; + if ((enabledSubstitutions & TypeScriptSubstitutionFlags.NamespaceExports) === 0) { + enabledSubstitutions |= TypeScriptSubstitutionFlags.NamespaceExports; // We need to enable substitutions for identifiers. This allows us to // substitute the names of exported members of a namespace. diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 07d1daec669..5cced242498 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2091,8 +2091,8 @@ namespace ts { CapturedBlockScopedBinding = 0x00020000, // Block-scoped binding that is captured in some function BlockScopedBindingInLoop = 0x00040000, // Block-scoped binding with declaration nested inside iteration statement HasSeenSuperCall = 0x00080000, // Set during the binding when encounter 'super' - ClassWithBodyScopedClassBinding = 0x00100000, // Decorated class that contains a binding to itself inside of the class body. - BodyScopedClassBinding = 0x00200000, // Binding to a decorated class inside of the class's body. + DecoratedClassWithSelfReference = 0x00100000, // Decorated class that contains a binding to itself inside of the class body. + SelfReferenceInDecoratedClass = 0x00200000, // Binding to a decorated class inside of the class's body. } /* @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 1b707cedc48..421737553d4 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1352,7 +1352,7 @@ namespace ts { - export function isNodeDescendentOf(node: Node, ancestor: Node): boolean { + export function isNodeDescendantOf(node: Node, ancestor: Node): boolean { while (node) { if (node === ancestor) return true; node = node.parent; @@ -2866,7 +2866,8 @@ namespace ts { } export function isGeneratedIdentifier(node: Node): node is Identifier { - return isIdentifier(node) && node.autoGenerateKind > GeneratedIdentifierKind.Node; + // Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`. + return isIdentifier(node) && node.autoGenerateKind > GeneratedIdentifierKind.None; } // Keywords From 7d05ba28bf7979c94d4eac7b586ce7c13c6fdfef Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 1 Mar 2016 15:16:41 -0800 Subject: [PATCH 6/7] Fixed visitJsxText, plus PR Feedback --- src/compiler/core.ts | 92 ++++++++++- src/compiler/transformers/jsx.ts | 251 ++++++++++++++++--------------- src/compiler/utilities.ts | 4 + 3 files changed, 217 insertions(+), 130 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index a464bd86682..15a8ce87eab 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -172,25 +172,101 @@ namespace ts { } /** - * Maps an array. If the mapped value is an array, it is spread into the result. + * Flattens an array containing a mix of array or non-array elements. + * + * @param array The array to flatten. */ - export function flatMap(array: T[], f: (x: T, i: number) => U | U[]): U[] { + export function flatten(array: (T | T[])[]): T[] { + let result: T[]; + if (array) { + result = []; + for (const v of array) { + if (v) { + if (isArray(v)) { + addRange(result, v); + } + else { + result.push(v); + } + } + } + } + + return result; + } + + /** + * Maps an array. If the mapped value is an array, it is spread into the result. + * + * @param array The array to map. + * @param mapfn The callback used to map the result into one or more values. + */ + export function flatMap(array: T[], mapfn: (x: T, i: number) => U | U[]): U[] { let result: U[]; if (array) { result = []; for (let i = 0; i < array.length; i++) { - const v = array[i]; - const ar = f(v, i); - if (ar) { - // We cast to here to leverage the behavior of Array#concat - // which will append a single value here. - result = result.concat(ar); + const v = mapfn(array[i], i); + if (v) { + if (isArray(v)) { + addRange(result, v); + } + else { + result.push(v); + } } } } return result; } + /** + * Maps contiguous spans of values with the same key. + * + * @param array The array to map. + * @param keyfn A callback used to select the key for an element. + * @param mapfn A callback used to map a contiguous chunk of values to a single value. + */ + export function spanMap(array: T[], keyfn: (x: T, i: number) => K, mapfn: (chunk: T[], key: K) => U): U[] { + let result: U[]; + if (array) { + result = []; + const len = array.length; + let previousKey: K; + let key: K; + let start = 0; + let pos = 0; + while (start < len) { + while (pos < len) { + const value = array[pos]; + key = keyfn(value, pos); + if (pos === 0) { + previousKey = key; + } + else if (key !== previousKey) { + break; + } + + pos++; + } + + if (start < pos) { + const v = mapfn(array.slice(start, pos), previousKey); + if (v) { + result.push(v); + } + + start = pos; + } + + previousKey = key; + pos++; + } + } + + return result; + } + export function concatenate(array1: T[], array2: T[]): T[] { if (!array2 || !array2.length) return array1; if (!array1 || !array1.length) return array2; diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index cb1aef32a97..924cfbfdb90 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -9,6 +9,11 @@ namespace ts { const compilerOptions = context.getCompilerOptions(); return transformSourceFile; + /** + * Transform JSX-specific syntax in a SourceFile. + * + * @param node A SourceFile node. + */ function transformSourceFile(node: SourceFile) { return visitEachChild(node, visitor, context); } @@ -64,7 +69,6 @@ namespace ts { } function visitJsxOpeningLikeElement(node: JsxOpeningLikeElement, children: JsxChild[]) { - // We must the node onto the node stack if it is not already at the top. const tagName = getTagName(node); let objectProperties: Expression; if (node.attributes.length === 0) { @@ -75,41 +79,35 @@ namespace ts { // Either emit one big object literal (no spread attribs), or // a call to React.__spread const attrs = node.attributes; - if (forEach(attrs, isJsxSpreadAttribute)) { - const segments: Expression[] = []; - let properties: ObjectLiteralElement[] = []; - for (const attr of attrs) { - if (isJsxSpreadAttribute(attr)) { - if (properties) { - segments.push(createObjectLiteral(properties)); - properties = undefined; - } - - addNode(segments, transformJsxSpreadAttributeToExpression(attr)); - } - else { - if (!properties) { - properties = []; - } - - addNode(properties, transformJsxAttributeToObjectLiteralElement(attr)); - } - } - - if (properties) { - segments.push(createObjectLiteral(properties)); - } - - objectProperties = createJsxSpread(compilerOptions.reactNamespace, segments); + if (!forEach(attrs, isJsxSpreadAttribute)) { + objectProperties = createObjectLiteral(map(node.attributes, transformJsxAttributeToObjectLiteralElement)); } else { - const properties = map(node.attributes, transformJsxAttributeToObjectLiteralElement); - objectProperties = createObjectLiteral(properties); + objectProperties = createJsxSpread(compilerOptions.reactNamespace, + concatenate( + // We must always emit at least one object literal before a spread + // argument. + isJsxSpreadAttribute(attrs[0]) ? [createObjectLiteral()] : undefined, + + // Map spans of JsxAttribute nodes into object literals and spans + // of JsxSpreadAttribute nodes into expressions. + flatten( + spanMap(attrs, isJsxSpreadAttribute, (attrs, isSpread) => isSpread + ? map(attrs, transformJsxSpreadAttributeToExpression) + : createObjectLiteral(map(attrs, transformJsxAttributeToObjectLiteralElement)) + ) + ) + ) + ); } } - const childExpressions = filter(map(children, transformJsxChildToExpression), isDefined); - return createJsxCreateElement(compilerOptions.reactNamespace, tagName, objectProperties, childExpressions); + return createJsxCreateElement( + compilerOptions.reactNamespace, + tagName, + objectProperties, + filter(map(children, transformJsxChildToExpression), isDefined) + ); } function transformJsxSpreadAttributeToExpression(node: JsxSpreadAttribute) { @@ -125,39 +123,29 @@ namespace ts { } function visitJsxText(node: JsxText) { - const text = getTextToEmit(node); - if (text !== undefined) { - return createLiteral(text); - } - return undefined; - } - - function getTextToEmit(node: JsxText) { - const text = trimReactWhitespaceAndApplyEntities(node); - if (text === undefined || text.length === 0) { - return undefined; - } - else { - return text; - } - } - - function trimReactWhitespaceAndApplyEntities(node: JsxText): string { const text = getTextOfNode(node, /*includeTrivia*/ true); - let result: string = undefined; + let parts: Expression[]; let firstNonWhitespace = 0; let lastNonWhitespace = -1; // JSX trims whitespace at the end and beginning of lines, except that the // start/end of a tag is considered a start/end of a line only if that line is - // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx + // on the same line as the closing tag. See examples in + // tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx for (let i = 0; i < text.length; i++) { const c = text.charCodeAt(i); if (isLineBreak(c)) { if (firstNonWhitespace !== -1 && (lastNonWhitespace - firstNonWhitespace + 1 > 0)) { const part = text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1); - result = (result ? result + "\" + ' ' + \"" : "") + part; + if (!parts) { + parts = []; + } + + // We do not escape the string here as that is handled by the printer + // when it emits the literal. We do, however, need to decode JSX entities. + parts.push(createLiteral(decodeEntities(part))); } + firstNonWhitespace = -1; } else if (!isWhiteSpace(c)) { @@ -170,22 +158,41 @@ namespace ts { if (firstNonWhitespace !== -1) { const part = text.substr(firstNonWhitespace); - result = (result ? result + "\" + ' ' + \"" : "") + part; + if (!parts) { + parts = []; + } + + // We do not escape the string here as that is handled by the printer + // when it emits the literal. We do, however, need to decode JSX entities. + parts.push(createLiteral(decodeEntities(part))); } - if (result) { - // Replace entities like   - result = result.replace(/&(\w+);/g, function(s: any, m: string) { - if (entities[m] !== undefined) { - return String.fromCharCode(entities[m]); - } - else { - return s; - } - }); + if (parts) { + return reduceLeft(parts, aggregateJsxTextParts); } - return result; + return undefined; + } + + /** + * Aggregates two expressions by interpolating them with a whitespace literal. + */ + function aggregateJsxTextParts(left: Expression, right: Expression) { + return createAdd(createAdd(left, createLiteral(" ")), right); + } + + /** + * Decodes JSX entities. + */ + function decodeEntities(text: string) { + return text.replace(/&(\w+);/g, function(s: any, m: string) { + if (entities[m] !== undefined) { + return String.fromCharCode(entities[m]); + } + else { + return s; + } + }); } function getTagName(node: JsxElement | JsxOpeningLikeElement): Expression { @@ -210,7 +217,7 @@ namespace ts { */ function getAttributeName(node: JsxAttribute): StringLiteral | Identifier { const name = node.name; - if (/[A-Za-z_]+[\w*]/.test(name.text)) { + if (/^[A-Za-z_]\w*$/.test(name.text)) { return createLiteral(name.text); } else { @@ -422,62 +429,62 @@ namespace ts { "uarr": 0x2191, "rarr": 0x2192, "darr": 0x2193, - "harr": 0x2194, - "crarr": 0x21B5, - "lArr": 0x21D0, - "uArr": 0x21D1, - "rArr": 0x21D2, - "dArr": 0x21D3, - "hArr": 0x21D4, - "forall": 0x2200, - "part": 0x2202, - "exist": 0x2203, - "empty": 0x2205, - "nabla": 0x2207, - "isin": 0x2208, - "notin": 0x2209, - "ni": 0x220B, - "prod": 0x220F, - "sum": 0x2211, - "minus": 0x2212, - "lowast": 0x2217, - "radic": 0x221A, - "prop": 0x221D, - "infin": 0x221E, - "ang": 0x2220, - "and": 0x2227, - "or": 0x2228, - "cap": 0x2229, - "cup": 0x222A, - "int": 0x222B, - "there4": 0x2234, - "sim": 0x223C, - "cong": 0x2245, - "asymp": 0x2248, - "ne": 0x2260, - "equiv": 0x2261, - "le": 0x2264, - "ge": 0x2265, - "sub": 0x2282, - "sup": 0x2283, - "nsub": 0x2284, - "sube": 0x2286, - "supe": 0x2287, - "oplus": 0x2295, - "otimes": 0x2297, - "perp": 0x22A5, - "sdot": 0x22C5, - "lceil": 0x2308, - "rceil": 0x2309, - "lfloor": 0x230A, - "rfloor": 0x230B, - "lang": 0x2329, - "rang": 0x232A, - "loz": 0x25CA, - "spades": 0x2660, - "clubs": 0x2663, - "hearts": 0x2665, - "diams": 0x2666 - }; + "harr": 0x2194, + "crarr": 0x21B5, + "lArr": 0x21D0, + "uArr": 0x21D1, + "rArr": 0x21D2, + "dArr": 0x21D3, + "hArr": 0x21D4, + "forall": 0x2200, + "part": 0x2202, + "exist": 0x2203, + "empty": 0x2205, + "nabla": 0x2207, + "isin": 0x2208, + "notin": 0x2209, + "ni": 0x220B, + "prod": 0x220F, + "sum": 0x2211, + "minus": 0x2212, + "lowast": 0x2217, + "radic": 0x221A, + "prop": 0x221D, + "infin": 0x221E, + "ang": 0x2220, + "and": 0x2227, + "or": 0x2228, + "cap": 0x2229, + "cup": 0x222A, + "int": 0x222B, + "there4": 0x2234, + "sim": 0x223C, + "cong": 0x2245, + "asymp": 0x2248, + "ne": 0x2260, + "equiv": 0x2261, + "le": 0x2264, + "ge": 0x2265, + "sub": 0x2282, + "sup": 0x2283, + "nsub": 0x2284, + "sube": 0x2286, + "supe": 0x2287, + "oplus": 0x2295, + "otimes": 0x2297, + "perp": 0x22A5, + "sdot": 0x22C5, + "lceil": 0x2308, + "rceil": 0x2309, + "lfloor": 0x230A, + "rfloor": 0x230B, + "lang": 0x2329, + "rang": 0x232A, + "loz": 0x25CA, + "spades": 0x2660, + "clubs": 0x2663, + "hearts": 0x2665, + "diams": 0x2666 + }; } } \ No newline at end of file diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 421737553d4..80cd6c7f8ad 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3268,6 +3268,10 @@ namespace ts { return node.kind === SyntaxKind.JsxSpreadAttribute; } + export function isJsxAttribute(node: Node): node is JsxAttribute { + return node.kind === SyntaxKind.JsxAttribute; + } + // Clauses export function isCaseOrDefaultClause(node: Node): node is CaseOrDefaultClause { From 186f5c8bca792659aabc69c21d9253a6c18256f3 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 1 Mar 2016 15:26:29 -0800 Subject: [PATCH 7/7] PR Feedback --- src/compiler/transformers/jsx.ts | 42 +++++++++++++++----------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index 924cfbfdb90..c5085da5295 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -71,35 +71,31 @@ namespace ts { function visitJsxOpeningLikeElement(node: JsxOpeningLikeElement, children: JsxChild[]) { const tagName = getTagName(node); let objectProperties: Expression; - if (node.attributes.length === 0) { + const attrs = node.attributes; + if (attrs.length === 0) { // When there are no attributes, React wants "null" objectProperties = createNull(); } else { + // Map spans of JsxAttribute nodes into object literals and spans + // of JsxSpreadAttribute nodes into expressions. + const segments = flatten( + spanMap(attrs, isJsxSpreadAttribute, (attrs, isSpread) => isSpread + ? map(attrs, transformJsxSpreadAttributeToExpression) + : createObjectLiteral(map(attrs, transformJsxAttributeToObjectLiteralElement)) + ) + ); + + if (isJsxSpreadAttribute(attrs[0])) { + // We must always emit at least one object literal before a spread + // argument. + segments.unshift(createObjectLiteral()); + } + // Either emit one big object literal (no spread attribs), or // a call to React.__spread - const attrs = node.attributes; - if (!forEach(attrs, isJsxSpreadAttribute)) { - objectProperties = createObjectLiteral(map(node.attributes, transformJsxAttributeToObjectLiteralElement)); - } - else { - objectProperties = createJsxSpread(compilerOptions.reactNamespace, - concatenate( - // We must always emit at least one object literal before a spread - // argument. - isJsxSpreadAttribute(attrs[0]) ? [createObjectLiteral()] : undefined, - - // Map spans of JsxAttribute nodes into object literals and spans - // of JsxSpreadAttribute nodes into expressions. - flatten( - spanMap(attrs, isJsxSpreadAttribute, (attrs, isSpread) => isSpread - ? map(attrs, transformJsxSpreadAttributeToExpression) - : createObjectLiteral(map(attrs, transformJsxAttributeToObjectLiteralElement)) - ) - ) - ) - ); - } + objectProperties = singleOrUndefined(segments) + || createJsxSpread(compilerOptions.reactNamespace, segments); } return createJsxCreateElement(