diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 81d3fb8bcd8..b885c2d3f50 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -422,6 +422,17 @@ namespace ts { return result; } + export function some(array: T[], predicate?: (value: T) => boolean): boolean { + if (array) { + for (const v of array) { + if (!predicate || predicate(v)) { + return true; + } + } + } + return false; + } + export function concatenate(array1: T[], array2: T[]): T[] { if (!array2 || !array2.length) return array1; if (!array1 || !array1.length) return array2; @@ -1201,7 +1212,7 @@ namespace ts { /** * Returns the path except for its basename. Eg: - * + * * /path/to/file.ext -> /path/to */ export function getDirectoryPath(path: Path): Path; diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 5a95600d089..18f93d0601b 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2206,7 +2206,7 @@ namespace ts { * @param visitor: Optional callback used to visit any custom prologue directives. */ export function addPrologueDirectives(target: Statement[], source: Statement[], ensureUseStrict?: boolean, visitor?: (node: Node) => VisitResult): number { - Debug.assert(target.length === 0, "PrologueDirectives should be at the first statement in the target statements array"); + Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); let foundUseStrict = false; let statementOffset = 0; const numStatements = source.length; @@ -2219,16 +2219,20 @@ namespace ts { target.push(statement); } else { - if (ensureUseStrict && !foundUseStrict) { - target.push(startOnNewLine(createStatement(createLiteral("use strict")))); - foundUseStrict = true; - } - if (getEmitFlags(statement) & EmitFlags.CustomPrologue) { - target.push(visitor ? visitNode(statement, visitor, isStatement) : statement); - } - else { - break; - } + break; + } + statementOffset++; + } + if (ensureUseStrict && !foundUseStrict) { + target.push(startOnNewLine(createStatement(createLiteral("use strict")))); + } + while (statementOffset < numStatements) { + const statement = source[statementOffset]; + if (getEmitFlags(statement) & EmitFlags.CustomPrologue) { + target.push(visitor ? visitNode(statement, visitor, isStatement) : statement); + } + else { + break; } statementOffset++; } diff --git a/src/compiler/transformers/module/es6.ts b/src/compiler/transformers/module/es6.ts index 09a2890727c..9eac37bee27 100644 --- a/src/compiler/transformers/module/es6.ts +++ b/src/compiler/transformers/module/es6.ts @@ -5,10 +5,6 @@ namespace ts { export function transformES6Module(context: TransformationContext) { const compilerOptions = context.getCompilerOptions(); - const resolver = context.getEmitResolver(); - - let currentSourceFile: SourceFile; - return transformSourceFile; function transformSourceFile(node: SourceFile) { @@ -17,128 +13,31 @@ namespace ts { } if (isExternalModule(node) || compilerOptions.isolatedModules) { - currentSourceFile = node; return visitEachChild(node, visitor, context); } + return node; } function visitor(node: Node): VisitResult { switch (node.kind) { - case SyntaxKind.ImportDeclaration: - return visitImportDeclaration(node); case SyntaxKind.ImportEqualsDeclaration: return visitImportEqualsDeclaration(node); - case SyntaxKind.ImportClause: - return visitImportClause(node); - case SyntaxKind.NamedImports: - case SyntaxKind.NamespaceImport: - return visitNamedBindings(node); - case SyntaxKind.ImportSpecifier: - return visitImportSpecifier(node); case SyntaxKind.ExportAssignment: return visitExportAssignment(node); - case SyntaxKind.ExportDeclaration: - return visitExportDeclaration(node); - case SyntaxKind.NamedExports: - return visitNamedExports(node); - case SyntaxKind.ExportSpecifier: - return visitExportSpecifier(node); } return node; } - function visitExportAssignment(node: ExportAssignment): ExportAssignment { - if (node.isExportEquals) { - return undefined; // do not emit export equals for ES6 - } - const original = getOriginalNode(node); - return nodeIsSynthesized(original) || resolver.isValueAliasDeclaration(original) ? node : undefined; + function visitImportEqualsDeclaration(node: ImportEqualsDeclaration): VisitResult { + // Elide `import=` as it is not legal with --module ES6 + return undefined; } - function visitExportDeclaration(node: ExportDeclaration): ExportDeclaration { - if (!node.exportClause) { - return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; - } - if (!resolver.isValueAliasDeclaration(node)) { - return undefined; - } - const newExportClause = visitNode(node.exportClause, visitor, isNamedExports, /*optional*/ true); - if (node.exportClause === newExportClause) { - return node; - } - return newExportClause - ? createExportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - newExportClause, - node.moduleSpecifier) - : undefined; - } - - function visitNamedExports(node: NamedExports): NamedExports { - const newExports = visitNodes(node.elements, visitor, isExportSpecifier); - if (node.elements === newExports) { - return node; - } - return newExports.length ? createNamedExports(newExports) : undefined; - } - - function visitExportSpecifier(node: ExportSpecifier): ExportSpecifier { - return resolver.isValueAliasDeclaration(node) ? node : undefined; - } - - function visitImportEqualsDeclaration(node: ImportEqualsDeclaration): ImportEqualsDeclaration { - return !isExternalModuleImportEqualsDeclaration(node) || resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - - function visitImportDeclaration(node: ImportDeclaration) { - if (node.importClause) { - const newImportClause = visitNode(node.importClause, visitor, isImportClause); - if (!newImportClause.name && !newImportClause.namedBindings) { - return undefined; - } - else if (newImportClause !== node.importClause) { - return createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - newImportClause, - node.moduleSpecifier); - } - } - return node; - } - - function visitImportClause(node: ImportClause): ImportClause { - let newDefaultImport = node.name; - if (!resolver.isReferencedAliasDeclaration(node)) { - newDefaultImport = undefined; - } - const newNamedBindings = visitNode(node.namedBindings, visitor, isNamedImportBindings, /*optional*/ true); - return newDefaultImport !== node.name || newNamedBindings !== node.namedBindings - ? createImportClause(newDefaultImport, newNamedBindings) - : node; - } - - function visitNamedBindings(node: NamedImportBindings): VisitResult { - if (node.kind === SyntaxKind.NamespaceImport) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; - } - else { - const newNamedImportElements = visitNodes((node).elements, visitor, isImportSpecifier); - if (!newNamedImportElements || newNamedImportElements.length == 0) { - return undefined; - } - if (newNamedImportElements === (node).elements) { - return node; - } - return createNamedImports(newNamedImportElements); - } - } - - function visitImportSpecifier(node: ImportSpecifier) { - return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + function visitExportAssignment(node: ExportAssignment): VisitResult { + // Elide `export=` as it is not legal with --module ES6 + return node.isExportEquals ? undefined : node; } } } \ No newline at end of file diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 516ed5433b8..94852616037 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -59,7 +59,7 @@ namespace ts { currentSourceFile = node; // Collect information about the external module. - ({ externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues } = collectExternalModuleInfo(node, resolver)); + ({ externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues } = collectExternalModuleInfo(node)); // Perform the transformation. const transformModule = transformModuleDelegates[moduleKind] || transformModuleDelegates[ModuleKind.None]; @@ -228,7 +228,7 @@ namespace ts { } function addExportEqualsIfNeeded(statements: Statement[], emitAsReturn: boolean) { - if (exportEquals && resolver.isValueAliasDeclaration(exportEquals)) { + if (exportEquals) { if (emitAsReturn) { const statement = createReturn( exportEquals.expression, @@ -461,23 +461,21 @@ namespace ts { ); } for (const specifier of node.exportClause.elements) { - if (resolver.isValueAliasDeclaration(specifier)) { - const exportedValue = createPropertyAccess( - generatedName, - specifier.propertyName || specifier.name - ); - statements.push( - createStatement( - createExportAssignment(specifier.name, exportedValue), - /*location*/ specifier - ) - ); - } + const exportedValue = createPropertyAccess( + generatedName, + specifier.propertyName || specifier.name + ); + statements.push( + createStatement( + createExportAssignment(specifier.name, exportedValue), + /*location*/ specifier + ) + ); } return singleOrMany(statements); } - else if (resolver.moduleExportsSomeValue(node.moduleSpecifier)) { + else { // export * from "mod"; return createStatement( createCall( @@ -495,15 +493,14 @@ namespace ts { } function visitExportAssignment(node: ExportAssignment): VisitResult { - if (!node.isExportEquals) { - if (nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - const statements: Statement[] = []; - addExportDefault(statements, node.expression, /*location*/ node); - return statements; - } + if (node.isExportEquals) { + // Elide as `export=` is handled in addExportEqualsIfNeeded + return undefined; } - return undefined; + const statements: Statement[] = []; + addExportDefault(statements, node.expression, /*location*/ node); + return statements; } function addExportDefault(statements: Statement[], expression: Expression, location: TextRange): void { @@ -568,7 +565,7 @@ namespace ts { } function collectExportMembers(names: Identifier[], node: Node): Identifier[] { - if (isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node) && isDeclaration(node)) { + if (isAliasSymbolDeclaration(node) && isDeclaration(node)) { const name = node.name; if (isIdentifier(name)) { names.push(name); diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 303c0e1bb96..0bb188eb390 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -91,7 +91,7 @@ namespace ts { Debug.assert(!exportFunctionForFile); // Collect information about the external module and dependency groups. - ({ externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues } = collectExternalModuleInfo(node, resolver)); + ({ externalImports, exportSpecifiers, exportEquals, hasExportStarsToExportValues } = collectExternalModuleInfo(node)); // Make sure that the name of the 'exports' function does not conflict with // existing identifiers. @@ -573,28 +573,23 @@ namespace ts { } function visitExportSpecifier(specifier: ExportSpecifier): Statement { - if (resolver.getReferencedValueDeclaration(specifier.propertyName || specifier.name) - || resolver.isValueAliasDeclaration(specifier)) { - recordExportName(specifier.name); - return createExportStatement( - specifier.name, - specifier.propertyName || specifier.name - ); - } - return undefined; + recordExportName(specifier.name); + return createExportStatement( + specifier.name, + specifier.propertyName || specifier.name + ); } function visitExportAssignment(node: ExportAssignment): Statement { - if (!node.isExportEquals) { - if (nodeIsSynthesized(node) || resolver.isValueAliasDeclaration(node)) { - return createExportStatement( - createLiteral("default"), - node.expression - ); - } + if (node.isExportEquals) { + // Elide `export=` as it is illegal in a SystemJS module. + return undefined; } - return undefined; + return createExportStatement( + createLiteral("default"), + node.expression + ); } /** diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 2c146c91bc3..70a6a191d33 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -147,6 +147,35 @@ namespace ts { return node; } + /** + * Specialized visitor that visits the immediate children of a SourceFile. + * + * @param node The node to visit. + */ + function sourceElementVisitor(node: Node): VisitResult { + return saveStateAndInvoke(node, sourceElementVisitorWorker); + } + + /** + * Specialized visitor that visits the immediate children of a SourceFile. + * + * @param node The node to visit. + */ + function sourceElementVisitorWorker(node: Node): VisitResult { + switch (node.kind) { + case SyntaxKind.ImportDeclaration: + return visitImportDeclaration(node); + case SyntaxKind.ImportEqualsDeclaration: + return visitImportEqualsDeclaration(node); + case SyntaxKind.ExportAssignment: + return visitExportAssignment(node); + case SyntaxKind.ExportDeclaration: + return visitExportDeclaration(node); + default: + return visitorWorker(node); + } + } + /** * Specialized visitor that visits the immediate children of a namespace. * @@ -462,7 +491,7 @@ namespace ts { statements.push(externalHelpersModuleImport); currentSourceFileExternalHelpersModuleName = externalHelpersModuleName; - addRange(statements, visitNodes(node.statements, visitor, isStatement, statementOffset)); + addRange(statements, visitNodes(node.statements, sourceElementVisitor, isStatement, statementOffset)); addRange(statements, endLexicalEnvironment()); currentSourceFileExternalHelpersModuleName = undefined; @@ -470,7 +499,7 @@ namespace ts { node.externalHelpersModuleName = externalHelpersModuleName; } else { - node = visitEachChild(node, visitor, context); + node = visitEachChild(node, sourceElementVisitor, context); } setEmitFlags(node, EmitFlags.EmitEmitHelpers | getEmitFlags(node)); @@ -2998,6 +3027,133 @@ namespace ts { } } + /** + * Visits an import declaration, eliding it if it is not referenced. + * + * @param node The import declaration node. + */ + function visitImportDeclaration(node: ImportDeclaration): VisitResult { + if (!node.importClause) { + // Do not elide a side-effect only import declaration. + // import "foo"; + return node; + } + + // Elide the declaration if the import clause was elided. + const importClause = visitNode(node.importClause, visitImportClause, isImportClause, /*optional*/ true); + return importClause + ? updateImportDeclaration( + node, + /*decorators*/ undefined, + /*modifiers*/ undefined, + importClause, + node.moduleSpecifier) + : undefined; + } + + /** + * Visits an import clause, eliding it if it is not referenced. + * + * @param node The import clause node. + */ + function visitImportClause(node: ImportClause): VisitResult { + // Elide the import clause if we elide both its name and its named bindings. + const name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; + const namedBindings = visitNode(node.namedBindings, visitNamedImportBindings, isNamedImportBindings, /*optional*/ true); + return (name || namedBindings) ? updateImportClause(node, name, namedBindings) : undefined; + } + + /** + * Visits named import bindings, eliding it if it is not referenced. + * + * @param node The named import bindings node. + */ + function visitNamedImportBindings(node: NamedImportBindings): VisitResult { + if (node.kind === SyntaxKind.NamespaceImport) { + // Elide a namespace import if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + else { + // Elide named imports if all of its import specifiers are elided. + const elements = visitNodes(node.elements, visitImportSpecifier, isImportSpecifier); + return some(elements) ? updateNamedImports(node, elements) : undefined; + } + } + + /** + * Visits an import specifier, eliding it if it is not referenced. + * + * @param node The import specifier node. + */ + function visitImportSpecifier(node: ImportSpecifier): VisitResult { + // Elide an import specifier if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) ? node : undefined; + } + + /** + * Visits an export assignment, eliding it if it does not contain a clause that resolves + * to a value. + * + * @param node The export assignment node. + */ + function visitExportAssignment(node: ExportAssignment): VisitResult { + // Elide the export assignment if it does not reference a value. + return resolver.isValueAliasDeclaration(node) + ? visitEachChild(node, visitor, context) + : undefined; + } + + /** + * Visits an export declaration, eliding it if it does not contain a clause that resolves + * to a value. + * + * @param node The export declaration node. + */ + function visitExportDeclaration(node: ExportDeclaration): VisitResult { + if (!node.exportClause) { + // Elide a star export if the module it references does not export a value. + return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + } + + if (!resolver.isValueAliasDeclaration(node)) { + // Elide the export declaration if it does not export a value. + return undefined; + } + + // Elide the export declaration if all of its named exports are elided. + const exportClause = visitNode(node.exportClause, visitNamedExports, isNamedExports, /*optional*/ true); + return exportClause + ? updateExportDeclaration( + node, + /*decorators*/ undefined, + /*modifiers*/ undefined, + exportClause, + node.moduleSpecifier) + : undefined; + } + + /** + * Visits named exports, eliding it if it does not contain an export specifier that + * resolves to a value. + * + * @param node The named exports node. + */ + function visitNamedExports(node: NamedExports): VisitResult { + // Elide the named exports if all of its export specifiers were elided. + const elements = visitNodes(node.elements, visitExportSpecifier, isExportSpecifier); + return some(elements) ? updateNamedExports(node, elements) : undefined; + } + + /** + * Visits an export specifier, eliding it if it does not resolve to a value. + * + * @param node The export specifier node. + */ + function visitExportSpecifier(node: ExportSpecifier): VisitResult { + // Elide an export specifier if it does not reference a value. + return resolver.isValueAliasDeclaration(node) ? node : undefined; + } + /** * Determines whether to emit an import equals declaration. * @@ -3019,7 +3175,10 @@ namespace ts { */ function visitImportEqualsDeclaration(node: ImportEqualsDeclaration): VisitResult { if (isExternalModuleImportEqualsDeclaration(node)) { - return visitEachChild(node, visitor, context); + // Elide external module `import=` if it is not referenced. + return resolver.isReferencedAliasDeclaration(node) + ? visitEachChild(node, visitor, context) + : undefined; } if (!shouldEmitImportEqualsDeclaration(node)) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index e788bcca2aa..e1a12850ab3 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3506,7 +3506,7 @@ namespace ts { return positionIsSynthesized(range.pos) ? -1 : skipTrivia(sourceFile.text, range.pos); } - export function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver) { + export function collectExternalModuleInfo(sourceFile: SourceFile) { const externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[] = []; const exportSpecifiers = createMap(); let exportEquals: ExportAssignment = undefined; @@ -3514,19 +3514,16 @@ namespace ts { for (const node of sourceFile.statements) { switch (node.kind) { case SyntaxKind.ImportDeclaration: - if (!(node).importClause || - resolver.isReferencedAliasDeclaration((node).importClause, /*checkChildren*/ true)) { - // import "mod" - // import x from "mod" where x is referenced - // import * as x from "mod" where x is referenced - // import { x, y } from "mod" where at least one import is referenced - externalImports.push(node); - } + // import "mod" + // import x from "mod" + // import * as x from "mod" + // import { x, y } from "mod" + externalImports.push(node); break; case SyntaxKind.ImportEqualsDeclaration: - if ((node).moduleReference.kind === SyntaxKind.ExternalModuleReference && resolver.isReferencedAliasDeclaration(node)) { - // import x = require("mod") where x is referenced + if ((node).moduleReference.kind === SyntaxKind.ExternalModuleReference) { + // import x = require("mod") externalImports.push(node); } break; @@ -3535,13 +3532,11 @@ namespace ts { if ((node).moduleSpecifier) { if (!(node).exportClause) { // export * from "mod" - if (resolver.moduleExportsSomeValue((node).moduleSpecifier)) { - externalImports.push(node); - hasExportStarsToExportValues = true; - } + externalImports.push(node); + hasExportStarsToExportValues = true; } - else if (resolver.isValueAliasDeclaration(node)) { - // export { x, y } from "mod" where at least one export is a value symbol + else { + // export { x, y } from "mod" externalImports.push(node); } } diff --git a/tests/baselines/reference/declareModifierOnImport1.js b/tests/baselines/reference/declareModifierOnImport1.js index 510407b4deb..3dc3601d470 100644 --- a/tests/baselines/reference/declareModifierOnImport1.js +++ b/tests/baselines/reference/declareModifierOnImport1.js @@ -2,3 +2,4 @@ declare import a = b; //// [declareModifierOnImport1.js] +var a = b; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js index d62cfbc2872..0a0e028b696 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js @@ -16,7 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] "use strict"; -var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; +var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1.default; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js index c19f68463fa..5f2cb4e97e0 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js @@ -19,7 +19,6 @@ define(["require", "exports"], function (require, exports) { //// [client.js] define(["require", "exports", "server"], function (require, exports, server_1) { "use strict"; - var nameSpaceBinding = server_1; exports.x = server_1.default; }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js index 20abd2e6132..60bdc654842 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js @@ -18,7 +18,7 @@ var a = (function () { exports.a = a; //// [client.js] "use strict"; -var server_1 = require("./server"), nameSpaceBinding = server_1; +var nameSpaceBinding = require("./server"); exports.x = new nameSpaceBinding.a(); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js index 5a2f1f35290..8752157eddd 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js @@ -23,7 +23,6 @@ define(["require", "exports"], function (require, exports) { //// [client.js] define(["require", "exports", "server"], function (require, exports, server_1) { "use strict"; - var nameSpaceBinding = server_1; exports.x = new server_1.default(); }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js index 2639291d854..9d11e154755 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js @@ -13,7 +13,7 @@ var x: number = nameSpaceBinding.a; exports.a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] "use strict"; -var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"), nameSpaceBinding = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1; +var nameSpaceBinding = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js index f417a086df7..e16ebf99957 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js @@ -13,7 +13,7 @@ export var x: number = nameSpaceBinding.a; exports.a = 10; //// [client.js] "use strict"; -var server_1 = require("./server"), nameSpaceBinding = server_1; +var nameSpaceBinding = require("./server"); exports.x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/importDeclWithDeclareModifier.js b/tests/baselines/reference/importDeclWithDeclareModifier.js index e5267678a49..7c3d3782934 100644 --- a/tests/baselines/reference/importDeclWithDeclareModifier.js +++ b/tests/baselines/reference/importDeclWithDeclareModifier.js @@ -9,4 +9,5 @@ var b: a; //// [importDeclWithDeclareModifier.js] "use strict"; +exports.a = x.c; var b; diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js index c7570e81192..1ceb1bcd146 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js +++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.js @@ -1 +1,2 @@ +"use strict"; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js index c7570e81192..1ceb1bcd146 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js +++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.js @@ -1 +1,2 @@ +"use strict"; //# sourceMappingURL=file.js.map \ No newline at end of file diff --git a/tests/baselines/reference/typeAliasDeclarationEmit.js b/tests/baselines/reference/typeAliasDeclarationEmit.js index 6e82fe4b07d..1f72e1d1b00 100644 --- a/tests/baselines/reference/typeAliasDeclarationEmit.js +++ b/tests/baselines/reference/typeAliasDeclarationEmit.js @@ -6,6 +6,7 @@ export type CallbackArray = () => T; //// [typeAliasDeclarationEmit.js] define(["require", "exports"], function (require, exports) { + "use strict"; }); diff --git a/tests/baselines/reference/typeAliasDeclarationEmit2.js b/tests/baselines/reference/typeAliasDeclarationEmit2.js index 4bb1bd3efd9..b94eb56a2a2 100644 --- a/tests/baselines/reference/typeAliasDeclarationEmit2.js +++ b/tests/baselines/reference/typeAliasDeclarationEmit2.js @@ -4,6 +4,7 @@ export type A = { value: a }; //// [typeAliasDeclarationEmit2.js] define(["require", "exports"], function (require, exports) { + "use strict"; });