From 213146dfd0b540a48dadb1b7006c65d0b35a0b8d Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 31 Oct 2017 17:22:34 -0700 Subject: [PATCH 01/26] Integrate importStar and importDefault helpers --- src/compiler/program.ts | 1 + src/compiler/transformers/module/es2015.ts | 14 +++---- src/compiler/transformers/module/module.ts | 43 +++++++++++++++++++++- src/compiler/transformers/utilities.ts | 1 + src/compiler/types.ts | 2 + src/compiler/visitor.ts | 2 + 6 files changed, 54 insertions(+), 9 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index e00e803b4890c..91de1197aef44 100755 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1593,6 +1593,7 @@ namespace ts { // synthesize 'import "tslib"' declaration const externalHelpersModuleReference = createLiteral(externalHelpersModuleNameText); const importDecl = createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined); + importDecl.transformFlags |= TransformFlags.NeverApplyImportHelper; externalHelpersModuleReference.parent = importDecl; importDecl.parent = file; imports = [externalHelpersModuleReference]; diff --git a/src/compiler/transformers/module/es2015.ts b/src/compiler/transformers/module/es2015.ts index 3951d08109da7..c583ccf277afc 100644 --- a/src/compiler/transformers/module/es2015.ts +++ b/src/compiler/transformers/module/es2015.ts @@ -25,14 +25,14 @@ namespace ts { if (externalHelpersModuleName) { const statements: Statement[] = []; const statementOffset = addPrologue(statements, node.statements); - append(statements, - createImportDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - createImportClause(/*name*/ undefined, createNamespaceImport(externalHelpersModuleName)), - createLiteral(externalHelpersModuleNameText) - ) + const tslibImport = createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createImportClause(/*name*/ undefined, createNamespaceImport(externalHelpersModuleName)), + createLiteral(externalHelpersModuleNameText) ); + tslibImport.transformFlags |= TransformFlags.NeverApplyImportHelper; + append(statements, tslibImport); addRange(statements, visitNodes(node.statements, visitor, isStatement, statementOffset)); return updateSourceFileNode( diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index f60e50ea36587..c8513ed530e7d 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -660,6 +660,22 @@ namespace ts { return createCall(createPropertyAccess(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]); } + + function getCommonjsImportExpressionForImport(node: ImportDeclaration) { + if (node.transformFlags & TransformFlags.NeverApplyImportHelper) { + return createRequireCall(node); + } + if (getNamespaceDeclarationNode(node)) { + context.requestEmitHelper(commonjsImportStarHelper); + return createCall(getHelperName("__importStar"), /*typeArguments*/ undefined, [createRequireCall(node)]); + } + if (isDefaultImport(node)) { + context.requestEmitHelper(commonjsImportDefaultHelper); + return createCall(getHelperName("__importDefault"), /*typeArguments*/ undefined, [createRequireCall(node)]); + } + return createRequireCall(node); + } + /** * Visits an ImportDeclaration node. * @@ -681,7 +697,7 @@ namespace ts { createVariableDeclaration( getSynthesizedClone(namespaceDeclaration.name), /*type*/ undefined, - createRequireCall(node) + getCommonjsImportExpressionForImport(node) ) ); } @@ -694,7 +710,7 @@ namespace ts { createVariableDeclaration( getGeneratedNameForNode(node), /*type*/ undefined, - createRequireCall(node) + getCommonjsImportExpressionForImport(node) ) ); @@ -1671,4 +1687,27 @@ namespace ts { text: ` var __syncRequire = typeof module === "object" && typeof module.exports === "object";` }; + + // emit helper for import star + const commonjsImportStarHelper: EmitHelper = { + name: "typescript:commonjsimportstar", + scoped: false, + text: ` +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +}` + }; + + const commonjsImportDefaultHelper: EmitHelper = { + name: "typescript:commonjsimportdefault", + scoped: false, + text: ` +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}` + }; } diff --git a/src/compiler/transformers/utilities.ts b/src/compiler/transformers/utilities.ts index a012c9be7db9a..ef53781028af6 100644 --- a/src/compiler/transformers/utilities.ts +++ b/src/compiler/transformers/utilities.ts @@ -143,6 +143,7 @@ namespace ts { createLiteral(externalHelpersModuleNameText)); if (externalHelpersImportDeclaration) { + externalHelpersImportDeclaration.transformFlags |= TransformFlags.NeverApplyImportHelper; externalImports.unshift(externalHelpersImportDeclaration); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b4e84ae6a759a..3065ec0243134 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4266,6 +4266,7 @@ namespace ts { ContainsYield = 1 << 24, ContainsHoistedDeclarationOrCompletion = 1 << 25, ContainsDynamicImport = 1 << 26, + NeverApplyImportHelper = 1 << 27, // Indicates the node should never be wrapped with an import star helper (because, for example, it import tslib itself) // Please leave this as 1 << 29. // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system. @@ -4305,6 +4306,7 @@ namespace ts { // - Additional bitmasks TypeScriptClassSyntaxMask = ContainsParameterPropertyAssignments | ContainsPropertyInitializer | ContainsDecorators, ES2015FunctionSyntaxMask = ContainsCapturedLexicalThis | ContainsDefaultValueAssignments, + StickyFlags = NeverApplyImportHelper, // Flags which once set are retained by `aggregateTransformFlags` instead of overwritten } export interface SourceMapRange extends TextRange { diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 0428d2d2d2e06..fc6511c32dea0 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -1466,7 +1466,9 @@ namespace ts { * Aggregates the TransformFlags for a Node and its subtree. */ export function aggregateTransformFlags(node: T): T { + const stickyFlags = node.transformFlags & TransformFlags.StickyFlags; aggregateTransformFlagsForNode(node); + node.transformFlags |= stickyFlags; return node; } From b5a7ef95ff88a63263213bf7864f6039680ef587 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 31 Oct 2017 17:42:48 -0700 Subject: [PATCH 02/26] Accept baselines --- tests/baselines/reference/APISample_jsdoc.js | 9 ++++++- tests/baselines/reference/APISample_linter.js | 9 ++++++- .../reference/APISample_transform.js | 9 ++++++- .../baselines/reference/APISample_watcher.js | 9 ++++++- .../allowImportClausesToMergeWithTypes.js | 10 ++++++-- .../allowSyntheticDefaultImports1.js | 5 +++- .../allowSyntheticDefaultImports4.js | 5 +++- .../reference/ambientDeclarationsPatterns.js | 5 +++- tests/baselines/reference/ambientShorthand.js | 14 +++++++++-- .../reference/ambientShorthand_reExport.js | 9 ++++++- .../declarationEmitTypeofDefaultExport.js | 9 ++++++- .../baselines/reference/decoratorMetadata.js | 5 +++- ...dataWithImportDeclarationNameCollision4.js | 2 +- ...dataWithImportDeclarationNameCollision5.js | 2 +- ...dataWithImportDeclarationNameCollision6.js | 2 +- ...dataWithImportDeclarationNameCollision7.js | 2 +- .../defaultExportInAwaitExpression01.js | 2 +- .../defaultExportInAwaitExpression02.js | 5 +++- .../reference/defaultExportsCannotMerge01.js | 5 +++- .../reference/defaultExportsCannotMerge02.js | 5 +++- .../reference/defaultExportsCannotMerge03.js | 5 +++- .../duplicatePackage_referenceTypes.js | 9 ++++++- .../reference/duplicatePackage_subModule.js | 9 ++++++- tests/baselines/reference/emptyModuleName.js | 9 ++++++- .../reference/es6ExportEqualsInterop.js | 25 ++++++++++++------- .../reference/es6ImportDefaultBindingDts.js | 5 +++- ...ultBindingFollowedWithNamedImport1InEs5.js | 15 ++++++----- ...ndingFollowedWithNamedImport1WithExport.js | 15 ++++++----- ...faultBindingFollowedWithNamedImportDts1.js | 15 ++++++----- ...ndingFollowedWithNamespaceBinding1InEs5.js | 5 +++- ...tBindingFollowedWithNamespaceBindingDts.js | 9 ++++++- ...indingFollowedWithNamespaceBindingInEs5.js | 9 ++++++- ...gFollowedWithNamespaceBindingWithExport.js | 9 ++++++- .../es6ImportDefaultBindingMergeErrors.js | 5 +++- .../reference/es6ImportNameSpaceImport.js | 9 ++++++- .../reference/es6ImportNameSpaceImportDts.js | 9 ++++++- .../es6ImportNameSpaceImportInEs5.js | 9 ++++++- .../reference/exportAndImport-es3.js | 5 +++- .../reference/exportAndImport-es5.js | 5 +++- .../reference/exportDefaultAbstractClass.js | 5 +++- .../reference/exportDefaultProperty.js | 11 +++++--- .../reference/exportDefaultProperty2.js | 5 +++- .../reference/exportEqualsDefaultProperty.js | 5 +++- tests/baselines/reference/exportStar.js | 5 +++- .../reference/exportStarFromEmptyModule.js | 9 ++++++- .../reference/exportsAndImports4-es6.js | 18 ++++++++++--- .../baselines/reference/exportsAndImports4.js | 18 ++++++++++--- ...sAndImportsWithContextualKeywordNames02.js | 9 ++++++- .../exportsAndImportsWithUnderscores1.js | 5 +++- .../exportsAndImportsWithUnderscores2.js | 5 +++- .../exportsAndImportsWithUnderscores3.js | 5 +++- .../reference/extendsUntypedModule.js | 5 +++- .../externalModuleImmutableBindings.js | 9 ++++++- .../reference/importWithTrailingSlash.js | 14 ++++++++--- .../reference/importsImplicitlyReadonly.js | 9 ++++++- .../inferredIndexerOnNamespaceImport.js | 9 ++++++- ...nvalidSyntaxNamespaceImportWithCommonjs.js | 9 ++++++- .../isolatedModulesImportExportElision.js | 9 ++++++- .../reference/isolatedModulesReExportType.js | 9 ++++++- .../reference/jsxImportInAttribute.js | 5 +++- tests/baselines/reference/jsxViaImport.2.js | 5 +++- .../reference/mergedDeclarations7.js | 9 ++++++- .../reference/multipleDefaultExports01.js | 5 +++- .../reference/multipleDefaultExports02.js | 5 +++- tests/baselines/reference/narrowedImports.js | 14 +++++++++-- .../reference/noCrashOnImportShadowing.js | 18 +++++++++++-- .../node/main.js | 9 ++++++- .../node/main.js | 9 ++++++- .../node/main.js | 9 ++++++- .../node/main.js | 9 ++++++- .../node/main.js | 9 ++++++- .../node/importHigher/root.js | 9 ++++++- .../node/maxDepthExceeded/built/root.js | 9 ++++++- .../node/maxDepthIncreased/root.js | 11 ++++++-- .../reference/reExportDefaultExport.js | 5 +++- .../reactNamespaceImportPresevation.js | 9 ++++++- .../requireAsFunctionInExternalModule.js | 5 +++- .../transformNestedGeneratorsWithTry.js | 9 ++++++- ...ata when transpile with CommonJS option.js | 9 ++++++- ...spile with CommonJS option.oldTranspile.js | 9 ++++++- .../baselines/reference/tsxDynamicTagName5.js | 9 ++++++- .../baselines/reference/tsxDynamicTagName7.js | 9 ++++++- .../baselines/reference/tsxDynamicTagName8.js | 9 ++++++- .../baselines/reference/tsxDynamicTagName9.js | 9 ++++++- .../reference/tsxExternalModuleEmit1.js | 18 +++++++++++-- .../reference/tsxExternalModuleEmit2.js | 5 +++- .../baselines/reference/umd-augmentation-1.js | 9 ++++++- .../baselines/reference/umd-augmentation-3.js | 9 ++++++- tests/baselines/reference/umd3.js | 9 ++++++- tests/baselines/reference/umd4.js | 9 ++++++- tests/baselines/reference/umd5.js | 9 ++++++- .../reference/untypedModuleImport.js | 14 +++++++++-- .../reference/untypedModuleImport_allowJs.js | 5 +++- tests/baselines/reference/unusedImports11.js | 14 +++++++++-- 94 files changed, 658 insertions(+), 137 deletions(-) diff --git a/tests/baselines/reference/APISample_jsdoc.js b/tests/baselines/reference/APISample_jsdoc.js index c74e188f38b22..5f80ff6c98520 100644 --- a/tests/baselines/reference/APISample_jsdoc.js +++ b/tests/baselines/reference/APISample_jsdoc.js @@ -121,8 +121,15 @@ function getSomeOtherTags(node: ts.Node) { * https://github.com/vega/ts-json-schema-generator * Please log a "breaking change" issue for any API breaking change affecting this issue */ +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var ts = require("typescript"); +var ts = __importStar(require("typescript")); // excerpted from https://github.com/YousefED/typescript-json-schema // (converted from a method and modified; for example, `this: any` to compensate, among other changes) function parseCommentsIntoDefinition(symbol, definition, otherAnnotations) { diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 51b208c39c902..bb371bb350665 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -70,8 +70,15 @@ fileNames.forEach(fileName => { at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter * Please log a "breaking change" issue for any API breaking change affecting this issue */ +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var ts = require("typescript"); +var ts = __importStar(require("typescript")); function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 47f63f56e704b..d0333fbe76c15 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -22,8 +22,15 @@ console.log(JSON.stringify(result)); at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function * Please log a "breaking change" issue for any API breaking change affecting this issue */ +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var ts = require("typescript"); +var ts = __importStar(require("typescript")); var source = "let x: string = 'string'"; var result = ts.transpile(source, { module: ts.ModuleKind.CommonJS }); console.log(JSON.stringify(result)); diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index f4d03f8f62fe3..1f5b1f60fb801 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -116,8 +116,15 @@ watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }); at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#incremental-build-support-using-the-language-services * Please log a "breaking change" issue for any API breaking change affecting this issue */ +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var ts = require("typescript"); +var ts = __importStar(require("typescript")); function watch(rootFileNames, options) { var files = {}; // initialize the list of files diff --git a/tests/baselines/reference/allowImportClausesToMergeWithTypes.js b/tests/baselines/reference/allowImportClausesToMergeWithTypes.js index 1679fa103723f..226c8b606d499 100644 --- a/tests/baselines/reference/allowImportClausesToMergeWithTypes.js +++ b/tests/baselines/reference/allowImportClausesToMergeWithTypes.js @@ -34,16 +34,22 @@ exports.zzz = 123; exports["default"] = exports.zzz; //// [a.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var b_1 = require("./b"); +var b_1 = __importDefault(require("./b")); exports["default"] = b_1["default"]; var x = { x: "" }; b_1["default"]; //// [index.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; var x = { x: "" }; zzz; -var b_1 = require("./b"); +var b_1 = __importDefault(require("./b")); b_1["default"]; var y = x; diff --git a/tests/baselines/reference/allowSyntheticDefaultImports1.js b/tests/baselines/reference/allowSyntheticDefaultImports1.js index fee1d13770630..d639f5c63190e 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports1.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports1.js @@ -21,6 +21,9 @@ var Foo = /** @class */ (function () { exports.Foo = Foo; //// [a.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var b_1 = require("./b"); +var b_1 = __importDefault(require("./b")); exports.x = new b_1["default"].Foo(); diff --git a/tests/baselines/reference/allowSyntheticDefaultImports4.js b/tests/baselines/reference/allowSyntheticDefaultImports4.js index 762c032b81287..a6903832b0c0c 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports4.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports4.js @@ -13,6 +13,9 @@ export var x = new Foo(); //// [a.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var b_1 = require("./b"); +var b_1 = __importDefault(require("./b")); exports.x = new b_1["default"](); diff --git a/tests/baselines/reference/ambientDeclarationsPatterns.js b/tests/baselines/reference/ambientDeclarationsPatterns.js index 84088d11d4eb4..e03dfe3dbb2be 100644 --- a/tests/baselines/reference/ambientDeclarationsPatterns.js +++ b/tests/baselines/reference/ambientDeclarationsPatterns.js @@ -34,6 +34,9 @@ foo(fileText); //// [user.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; /// var foobarbaz_1 = require("foobarbaz"); @@ -41,5 +44,5 @@ foobarbaz_1.foo(foobarbaz_1.baz); var foosball_1 = require("foosball"); foobarbaz_1.foo(foosball_1.foos); // Works with relative file name -var file_text_1 = require("./file!text"); +var file_text_1 = __importDefault(require("./file!text")); foobarbaz_1.foo(file_text_1["default"]); diff --git a/tests/baselines/reference/ambientShorthand.js b/tests/baselines/reference/ambientShorthand.js index a7513e7eb585a..071655638b746 100644 --- a/tests/baselines/reference/ambientShorthand.js +++ b/tests/baselines/reference/ambientShorthand.js @@ -15,9 +15,19 @@ foo(bar, baz, boom); //// [user.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; /// -var jquery_1 = require("jquery"); -var baz = require("fs"); +var jquery_1 = __importDefault(require("jquery")); +var baz = __importStar(require("fs")); var boom = require("jquery"); jquery_1["default"](jquery_1.bar, baz, boom); diff --git a/tests/baselines/reference/ambientShorthand_reExport.js b/tests/baselines/reference/ambientShorthand_reExport.js index 6842d0f75541f..3337af5d8e007 100644 --- a/tests/baselines/reference/ambientShorthand_reExport.js +++ b/tests/baselines/reference/ambientShorthand_reExport.js @@ -30,8 +30,15 @@ exports.__esModule = true; __export(require("jquery")); //// [reExportUser.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; var reExportX_1 = require("./reExportX"); -var $ = require("./reExportAll"); +var $ = __importStar(require("./reExportAll")); // '$' is not callable, it is an object. reExportX_1.x($); diff --git a/tests/baselines/reference/declarationEmitTypeofDefaultExport.js b/tests/baselines/reference/declarationEmitTypeofDefaultExport.js index c4a105ca8b9c4..b00ba90aef436 100644 --- a/tests/baselines/reference/declarationEmitTypeofDefaultExport.js +++ b/tests/baselines/reference/declarationEmitTypeofDefaultExport.js @@ -20,8 +20,15 @@ exports["default"] = C; ; //// [b.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var a = require("./a"); +var a = __importStar(require("./a")); exports["default"] = a["default"]; diff --git a/tests/baselines/reference/decoratorMetadata.js b/tests/baselines/reference/decoratorMetadata.js index 4e411154ec1fc..6929d11b8a4be 100644 --- a/tests/baselines/reference/decoratorMetadata.js +++ b/tests/baselines/reference/decoratorMetadata.js @@ -38,8 +38,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} Object.defineProperty(exports, "__esModule", { value: true }); -var service_1 = require("./service"); +var service_1 = __importDefault(require("./service")); var MyComponent = /** @class */ (function () { function MyComponent(Service) { this.Service = Service; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js index bec7400996e00..f48fd79adca0b 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js @@ -37,7 +37,7 @@ exports.db = db; //// [service.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var db_1 = require("./db"); // error no default export +var db_1 = __importDefault(require("./db")); // error no default export function someDecorator(target) { return target; } diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js index 1985fe396df19..79809058d3876 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js @@ -37,7 +37,7 @@ exports.default = db; //// [service.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var db_1 = require("./db"); +var db_1 = __importDefault(require("./db")); function someDecorator(target) { return target; } diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js index c7f9529973fe6..7967ed7e2e626 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js @@ -37,7 +37,7 @@ exports.default = db; //// [service.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var db_1 = require("./db"); +var db_1 = __importDefault(require("./db")); function someDecorator(target) { return target; } diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js index fa96fb3229ebd..a20a12f7c0a35 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js @@ -37,7 +37,7 @@ exports.default = db; //// [service.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var db_1 = require("./db"); +var db_1 = __importDefault(require("./db")); function someDecorator(target) { return target; } diff --git a/tests/baselines/reference/defaultExportInAwaitExpression01.js b/tests/baselines/reference/defaultExportInAwaitExpression01.js index 6a31461fe3cf2..ae6c5e7fe0e7f 100644 --- a/tests/baselines/reference/defaultExportInAwaitExpression01.js +++ b/tests/baselines/reference/defaultExportInAwaitExpression01.js @@ -47,7 +47,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - const a_1 = require("./a"); + const a_1 = __importDefault(require("./a")); (function () { return __awaiter(this, void 0, void 0, function* () { const value = yield a_1.default; diff --git a/tests/baselines/reference/defaultExportInAwaitExpression02.js b/tests/baselines/reference/defaultExportInAwaitExpression02.js index 565cfb416175c..b777f84ec40a8 100644 --- a/tests/baselines/reference/defaultExportInAwaitExpression02.js +++ b/tests/baselines/reference/defaultExportInAwaitExpression02.js @@ -27,8 +27,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} Object.defineProperty(exports, "__esModule", { value: true }); -const a_1 = require("./a"); +const a_1 = __importDefault(require("./a")); (function () { return __awaiter(this, void 0, void 0, function* () { const value = yield a_1.default; diff --git a/tests/baselines/reference/defaultExportsCannotMerge01.js b/tests/baselines/reference/defaultExportsCannotMerge01.js index 9c433ce3a2b11..47fba6627d24b 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge01.js +++ b/tests/baselines/reference/defaultExportsCannotMerge01.js @@ -42,8 +42,11 @@ exports.default = Decl; })(Decl = exports.Decl || (exports.Decl = {})); //// [m2.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} Object.defineProperty(exports, "__esModule", { value: true }); -var m1_1 = require("m1"); +var m1_1 = __importDefault(require("m1")); m1_1.default(); var x; var y; diff --git a/tests/baselines/reference/defaultExportsCannotMerge02.js b/tests/baselines/reference/defaultExportsCannotMerge02.js index 98bbe7b0d08e4..bcf5cb9dabc23 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge02.js +++ b/tests/baselines/reference/defaultExportsCannotMerge02.js @@ -35,8 +35,11 @@ var Decl = /** @class */ (function () { exports.default = Decl; //// [m2.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} Object.defineProperty(exports, "__esModule", { value: true }); -var m1_1 = require("m1"); +var m1_1 = __importDefault(require("m1")); m1_1.default(); var x; var y; diff --git a/tests/baselines/reference/defaultExportsCannotMerge03.js b/tests/baselines/reference/defaultExportsCannotMerge03.js index 8aa10e6eab1f5..3a627b38e8376 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge03.js +++ b/tests/baselines/reference/defaultExportsCannotMerge03.js @@ -35,8 +35,11 @@ var Decl = /** @class */ (function () { exports.default = Decl; //// [m2.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} Object.defineProperty(exports, "__esModule", { value: true }); -var m1_1 = require("m1"); +var m1_1 = __importDefault(require("m1")); m1_1.default(); var x; var y; diff --git a/tests/baselines/reference/duplicatePackage_referenceTypes.js b/tests/baselines/reference/duplicatePackage_referenceTypes.js index 2abd8090e0703..9bc7919c7bb62 100644 --- a/tests/baselines/reference/duplicatePackage_referenceTypes.js +++ b/tests/baselines/reference/duplicatePackage_referenceTypes.js @@ -26,6 +26,13 @@ let foo: Foo = a.foo; //// [index.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var a = require("a"); +var a = __importStar(require("a")); var foo = a.foo; diff --git a/tests/baselines/reference/duplicatePackage_subModule.js b/tests/baselines/reference/duplicatePackage_subModule.js index 0a5793a79a2c7..e2c0c8d134089 100644 --- a/tests/baselines/reference/duplicatePackage_subModule.js +++ b/tests/baselines/reference/duplicatePackage_subModule.js @@ -29,6 +29,13 @@ const o: Foo = a.o; //// [index.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var a = require("a"); +var a = __importStar(require("a")); var o = a.o; diff --git a/tests/baselines/reference/emptyModuleName.js b/tests/baselines/reference/emptyModuleName.js index 121ae413662b7..37bc645a01c46 100644 --- a/tests/baselines/reference/emptyModuleName.js +++ b/tests/baselines/reference/emptyModuleName.js @@ -15,8 +15,15 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var A = require(""); +var A = __importStar(require("")); var B = /** @class */ (function (_super) { __extends(B, _super); function B() { diff --git a/tests/baselines/reference/es6ExportEqualsInterop.js b/tests/baselines/reference/es6ExportEqualsInterop.js index 13908a29e2d6b..9ebb28988e493 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.js +++ b/tests/baselines/reference/es6ExportEqualsInterop.js @@ -212,6 +212,13 @@ export * from "class-module"; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; var z2 = require("variable"); var z3 = require("interface-variable"); @@ -232,15 +239,15 @@ z7.a; z8.a; z9.a; z0.a; -var y2 = require("variable"); -var y3 = require("interface-variable"); -var y4 = require("module"); -var y5 = require("interface-module"); -var y6 = require("variable-module"); -var y7 = require("function"); -var y8 = require("function-module"); -var y9 = require("class"); -var y0 = require("class-module"); +var y2 = __importStar(require("variable")); +var y3 = __importStar(require("interface-variable")); +var y4 = __importStar(require("module")); +var y5 = __importStar(require("interface-module")); +var y6 = __importStar(require("variable-module")); +var y7 = __importStar(require("function")); +var y8 = __importStar(require("function-module")); +var y9 = __importStar(require("class")); +var y0 = __importStar(require("class-module")); y1.a; y2.a; y3.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingDts.js index 5011e3144fd16..06b7a32434e77 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.js @@ -21,8 +21,11 @@ var c = /** @class */ (function () { exports.default = c; //// [client.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} Object.defineProperty(exports, "__esModule", { value: true }); -var server_1 = require("./server"); +var server_1 = __importDefault(require("./server")); exports.x = new server_1.default(); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js index 46e52a43135f1..51aeb42c0f3bc 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js @@ -26,18 +26,21 @@ var a = 10; exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} Object.defineProperty(exports, "__esModule", { value: true }); -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6.default; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js index 02c093987d4fa..a8153a8f40147 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js @@ -26,18 +26,21 @@ var a = 10; exports.default = a; //// [client.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} Object.defineProperty(exports, "__esModule", { value: true }); -var server_1 = require("./server"); +var server_1 = __importDefault(require("./server")); exports.x1 = server_1.default; -var server_2 = require("./server"); +var server_2 = __importDefault(require("./server")); exports.x1 = server_2.default; -var server_3 = require("./server"); +var server_3 = __importDefault(require("./server")); exports.x1 = server_3.default; -var server_4 = require("./server"); +var server_4 = __importDefault(require("./server")); exports.x1 = server_4.default; -var server_5 = require("./server"); +var server_5 = __importDefault(require("./server")); exports.x1 = server_5.default; -var server_6 = require("./server"); +var server_6 = __importDefault(require("./server")); exports.x1 = server_6.default; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js index 3c8b211981950..eb4050a94de57 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js @@ -29,18 +29,21 @@ var a = /** @class */ (function () { exports.default = a; //// [client.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} Object.defineProperty(exports, "__esModule", { value: true }); -var server_1 = require("./server"); +var server_1 = __importDefault(require("./server")); exports.x1 = new server_1.default(); -var server_2 = require("./server"); +var server_2 = __importDefault(require("./server")); exports.x2 = new server_2.default(); -var server_3 = require("./server"); +var server_3 = __importDefault(require("./server")); exports.x3 = new server_3.default(); -var server_4 = require("./server"); +var server_4 = __importDefault(require("./server")); exports.x4 = new server_4.default(); -var server_5 = require("./server"); +var server_5 = __importDefault(require("./server")); exports.x5 = new server_5.default(); -var server_6 = require("./server"); +var server_6 = __importDefault(require("./server")); exports.x6 = new server_6.default(); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js index a6217abb784ed..287e65cffde22 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js @@ -15,8 +15,11 @@ var a = 10; exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} Object.defineProperty(exports, "__esModule", { value: true }); -var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); +var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0")); var x = es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1.default; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js index 47b02ccd40a37..73c663bc453d1 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js @@ -18,8 +18,15 @@ var a = /** @class */ (function () { exports.a = a; //// [client.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var nameSpaceBinding = require("./server"); +var nameSpaceBinding = __importStar(require("./server")); exports.x = new nameSpaceBinding.a(); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js index 5586054319ad0..8222772e34b78 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js @@ -13,8 +13,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -var nameSpaceBinding = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); +var nameSpaceBinding = __importStar(require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0")); var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js index ded9e2811a270..7ddcfb2e25bbd 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js @@ -13,8 +13,15 @@ exports.__esModule = true; exports.a = 10; //// [client.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var nameSpaceBinding = require("./server"); +var nameSpaceBinding = __importStar(require("./server")); exports.x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js index 85f3d34cd6781..a0e16ecf9a436 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js +++ b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js @@ -22,7 +22,10 @@ var a = 10; exports.default = a; //// [es6ImportDefaultBindingMergeErrors_1.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} Object.defineProperty(exports, "__esModule", { value: true }); -var es6ImportDefaultBindingMergeErrors_0_1 = require("./es6ImportDefaultBindingMergeErrors_0"); +var es6ImportDefaultBindingMergeErrors_0_1 = __importDefault(require("./es6ImportDefaultBindingMergeErrors_0")); var x = es6ImportDefaultBindingMergeErrors_0_1.default; var defaultBinding2 = "hello world"; diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.js b/tests/baselines/reference/es6ImportNameSpaceImport.js index c9013259e8ead..dd960f87275f4 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImport.js +++ b/tests/baselines/reference/es6ImportNameSpaceImport.js @@ -15,8 +15,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; //// [es6ImportNameSpaceImport_1.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -const nameSpaceBinding = require("./es6ImportNameSpaceImport_0"); +const nameSpaceBinding = __importStar(require("./es6ImportNameSpaceImport_0")); var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportDts.js b/tests/baselines/reference/es6ImportNameSpaceImportDts.js index e39402c36332c..16cb65242d399 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportDts.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportDts.js @@ -20,8 +20,15 @@ exports.c = c; ; //// [client.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var nameSpaceBinding = require("./server"); +var nameSpaceBinding = __importStar(require("./server")); exports.x = new nameSpaceBinding.c(); diff --git a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js index 1eced8142cb8d..b1f968a01f565 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js @@ -15,8 +15,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; //// [es6ImportNameSpaceImportInEs5_1.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -var nameSpaceBinding = require("./es6ImportNameSpaceImportInEs5_0"); +var nameSpaceBinding = __importStar(require("./es6ImportNameSpaceImportInEs5_0")); var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/exportAndImport-es3.js b/tests/baselines/reference/exportAndImport-es3.js index 48b3e94a2f218..bd4675d93fc82 100644 --- a/tests/baselines/reference/exportAndImport-es3.js +++ b/tests/baselines/reference/exportAndImport-es3.js @@ -19,8 +19,11 @@ function f1() { exports["default"] = f1; //// [m2.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var m1_1 = require("./m1"); +var m1_1 = __importDefault(require("./m1")); function f2() { m1_1["default"](); } diff --git a/tests/baselines/reference/exportAndImport-es5.js b/tests/baselines/reference/exportAndImport-es5.js index c329b650d6e55..1763fdf0a397c 100644 --- a/tests/baselines/reference/exportAndImport-es5.js +++ b/tests/baselines/reference/exportAndImport-es5.js @@ -19,8 +19,11 @@ function f1() { exports.default = f1; //// [m2.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} Object.defineProperty(exports, "__esModule", { value: true }); -var m1_1 = require("./m1"); +var m1_1 = __importDefault(require("./m1")); function f2() { m1_1.default(); } diff --git a/tests/baselines/reference/exportDefaultAbstractClass.js b/tests/baselines/reference/exportDefaultAbstractClass.js index 821a68f4699bc..5b2dde6c06def 100644 --- a/tests/baselines/reference/exportDefaultAbstractClass.js +++ b/tests/baselines/reference/exportDefaultAbstractClass.js @@ -51,8 +51,11 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var a_1 = require("./a"); +var a_1 = __importDefault(require("./a")); var C = /** @class */ (function (_super) { __extends(C, _super); function C() { diff --git a/tests/baselines/reference/exportDefaultProperty.js b/tests/baselines/reference/exportDefaultProperty.js index c8950a20e13dd..75e16fb9e4f88 100644 --- a/tests/baselines/reference/exportDefaultProperty.js +++ b/tests/baselines/reference/exportDefaultProperty.js @@ -63,14 +63,17 @@ exports.__esModule = true; exports["default"] = "foo".length; //// [index.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; /// -var foobar_1 = require("foobar"); +var foobar_1 = __importDefault(require("foobar")); var X = foobar_1["default"].X; -var foobarx_1 = require("foobarx"); +var foobarx_1 = __importDefault(require("foobarx")); var x = X; var x2 = foobarx_1["default"]; -var a_1 = require("./a"); +var a_1 = __importDefault(require("./a")); var b = new a_1["default"](a_1["default"].b); -var b_1 = require("./b"); +var b_1 = __importDefault(require("./b")); b_1["default"] + 1; diff --git a/tests/baselines/reference/exportDefaultProperty2.js b/tests/baselines/reference/exportDefaultProperty2.js index 2721220c07644..5c7f95f08d972 100644 --- a/tests/baselines/reference/exportDefaultProperty2.js +++ b/tests/baselines/reference/exportDefaultProperty2.js @@ -29,6 +29,9 @@ var C = /** @class */ (function () { exports["default"] = C.B; //// [b.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var a_1 = require("./a"); +var a_1 = __importDefault(require("./a")); var x = { c: a_1["default"] }; diff --git a/tests/baselines/reference/exportEqualsDefaultProperty.js b/tests/baselines/reference/exportEqualsDefaultProperty.js index 3e7fc4d12afc4..013f0b059d9df 100644 --- a/tests/baselines/reference/exportEqualsDefaultProperty.js +++ b/tests/baselines/reference/exportEqualsDefaultProperty.js @@ -22,6 +22,9 @@ var x = { module.exports = x; //// [imp.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var exp_1 = require("./exp"); +var exp_1 = __importDefault(require("./exp")); exp_1["default"].toExponential(2); diff --git a/tests/baselines/reference/exportStar.js b/tests/baselines/reference/exportStar.js index 36818f8ae9b76..2b357f8a997f2 100644 --- a/tests/baselines/reference/exportStar.js +++ b/tests/baselines/reference/exportStar.js @@ -59,8 +59,11 @@ __export(require("./t2")); __export(require("./t3")); //// [main.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} Object.defineProperty(exports, "__esModule", { value: true }); -var t4_1 = require("./t4"); +var t4_1 = __importDefault(require("./t4")); t4_1.default; t4_1.x; t4_1.y; diff --git a/tests/baselines/reference/exportStarFromEmptyModule.js b/tests/baselines/reference/exportStarFromEmptyModule.js index 2730778930d62..c4434f780b8b2 100644 --- a/tests/baselines/reference/exportStarFromEmptyModule.js +++ b/tests/baselines/reference/exportStarFromEmptyModule.js @@ -49,8 +49,15 @@ var A = /** @class */ (function () { exports.A = A; //// [exportStarFromEmptyModule_module4.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -var X = require("./exportStarFromEmptyModule_module3"); +var X = __importStar(require("./exportStarFromEmptyModule_module3")); var s; X.A.q; X.A.r; // Error diff --git a/tests/baselines/reference/exportsAndImports4-es6.js b/tests/baselines/reference/exportsAndImports4-es6.js index ee35571942f6c..1de9968869ede 100644 --- a/tests/baselines/reference/exportsAndImports4-es6.js +++ b/tests/baselines/reference/exportsAndImports4-es6.js @@ -44,25 +44,35 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = "hello"; //// [t3.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); const a = require("./t1"); exports.a = a; a.default; -const t1_1 = require("./t1"); +const t1_1 = __importDefault(require("./t1")); exports.b = t1_1.default; t1_1.default; -const c = require("./t1"); +const c = __importStar(require("./t1")); exports.c = c; c.default; const t1_2 = require("./t1"); exports.d = t1_2.default; t1_2.default; -const t1_3 = require("./t1"), e2 = t1_3; +const t1_3 = __importStar(require("./t1")), e2 = t1_3; exports.e1 = t1_3.default; exports.e2 = e2; t1_3.default; e2.default; -const t1_4 = require("./t1"); +const t1_4 = __importDefault(require("./t1")); exports.f1 = t1_4.default; exports.f2 = t1_4.default; t1_4.default; diff --git a/tests/baselines/reference/exportsAndImports4.js b/tests/baselines/reference/exportsAndImports4.js index efb93eeebf62e..d63f7da9c0438 100644 --- a/tests/baselines/reference/exportsAndImports4.js +++ b/tests/baselines/reference/exportsAndImports4.js @@ -44,25 +44,35 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = "hello"; //// [t3.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); var a = require("./t1"); exports.a = a; a.default; -var t1_1 = require("./t1"); +var t1_1 = __importDefault(require("./t1")); exports.b = t1_1.default; t1_1.default; -var c = require("./t1"); +var c = __importStar(require("./t1")); exports.c = c; c.default; var t1_2 = require("./t1"); exports.d = t1_2.default; t1_2.default; -var t1_3 = require("./t1"), e2 = t1_3; +var t1_3 = __importStar(require("./t1")), e2 = t1_3; exports.e1 = t1_3.default; exports.e2 = e2; t1_3.default; e2.default; -var t1_4 = require("./t1"); +var t1_4 = __importDefault(require("./t1")); exports.f1 = t1_4.default; exports.f2 = t1_4.default; t1_4.default; diff --git a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js index cf1976e5b03f2..4b9a0c49d422f 100644 --- a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js +++ b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js @@ -24,8 +24,15 @@ exports.return = as; exports.as = as; //// [t2.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -var as = require("./t1"); +var as = __importStar(require("./t1")); var x = as.as; var y = as.return; //// [t3.js] diff --git a/tests/baselines/reference/exportsAndImportsWithUnderscores1.js b/tests/baselines/reference/exportsAndImportsWithUnderscores1.js index 284537252fe70..6312c6e868bb1 100644 --- a/tests/baselines/reference/exportsAndImportsWithUnderscores1.js +++ b/tests/baselines/reference/exportsAndImportsWithUnderscores1.js @@ -24,6 +24,9 @@ exports["default"] = R = { }; //// [m2.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var m1_1 = require("./m1"); +var m1_1 = __importDefault(require("./m1")); var __ = m1_1["default"].__, _ = m1_1["default"]._, ___ = m1_1["default"].___; diff --git a/tests/baselines/reference/exportsAndImportsWithUnderscores2.js b/tests/baselines/reference/exportsAndImportsWithUnderscores2.js index 90cbc11b95b10..1c9821cbf6589 100644 --- a/tests/baselines/reference/exportsAndImportsWithUnderscores2.js +++ b/tests/baselines/reference/exportsAndImportsWithUnderscores2.js @@ -22,6 +22,9 @@ exports["default"] = R = { }; //// [m2.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var m1_1 = require("./m1"); +var m1_1 = __importDefault(require("./m1")); var __esmodule = m1_1["default"].__esmodule, __proto__ = m1_1["default"].__proto__; diff --git a/tests/baselines/reference/exportsAndImportsWithUnderscores3.js b/tests/baselines/reference/exportsAndImportsWithUnderscores3.js index 0aead5f1f8bbc..249e715afd47e 100644 --- a/tests/baselines/reference/exportsAndImportsWithUnderscores3.js +++ b/tests/baselines/reference/exportsAndImportsWithUnderscores3.js @@ -24,6 +24,9 @@ exports["default"] = R = { }; //// [m2.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var m1_1 = require("./m1"); +var m1_1 = __importDefault(require("./m1")); var ___ = m1_1["default"].___, ___hello = m1_1["default"].___hello, _hi = m1_1["default"]._hi; diff --git a/tests/baselines/reference/extendsUntypedModule.js b/tests/baselines/reference/extendsUntypedModule.js index f56c2add0fd93..404048ab70596 100644 --- a/tests/baselines/reference/extendsUntypedModule.js +++ b/tests/baselines/reference/extendsUntypedModule.js @@ -26,8 +26,11 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var foo_1 = require("foo"); +var foo_1 = __importDefault(require("foo")); var A = /** @class */ (function (_super) { __extends(A, _super); function A() { diff --git a/tests/baselines/reference/externalModuleImmutableBindings.js b/tests/baselines/reference/externalModuleImmutableBindings.js index d6f5913f5d1d3..a1588372b7229 100644 --- a/tests/baselines/reference/externalModuleImmutableBindings.js +++ b/tests/baselines/reference/externalModuleImmutableBindings.js @@ -56,9 +56,16 @@ exports.__esModule = true; exports.x = 1; //// [f2.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; // all mutations below are illegal and should be fixed -var stuff = require("./f1"); +var stuff = __importStar(require("./f1")); var n = 'baz'; stuff.x = 0; stuff['x'] = 1; diff --git a/tests/baselines/reference/importWithTrailingSlash.js b/tests/baselines/reference/importWithTrailingSlash.js index 9df01dcee66fd..a762935b10a07 100644 --- a/tests/baselines/reference/importWithTrailingSlash.js +++ b/tests/baselines/reference/importWithTrailingSlash.js @@ -29,15 +29,21 @@ exports.__esModule = true; exports["default"] = { aIndex: 0 }; //// [test.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var _1 = require("."); -var _2 = require("./"); +var _1 = __importDefault(require(".")); +var _2 = __importDefault(require("./")); _1["default"].a; _2["default"].aIndex; //// [test.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var __1 = require(".."); -var _1 = require("../"); +var __1 = __importDefault(require("..")); +var _1 = __importDefault(require("../")); __1["default"].a; _1["default"].aIndex; diff --git a/tests/baselines/reference/importsImplicitlyReadonly.js b/tests/baselines/reference/importsImplicitlyReadonly.js index 724b8c14e5322..ba77fbb6affbf 100644 --- a/tests/baselines/reference/importsImplicitlyReadonly.js +++ b/tests/baselines/reference/importsImplicitlyReadonly.js @@ -28,9 +28,16 @@ var y = 1; exports.y = y; //// [b.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; var a_1 = require("./a"); -var a1 = require("./a"); +var a1 = __importStar(require("./a")); var a2 = require("./a"); var a3 = a1; a_1.x = 1; // Error diff --git a/tests/baselines/reference/inferredIndexerOnNamespaceImport.js b/tests/baselines/reference/inferredIndexerOnNamespaceImport.js index 10fbc0890b7dc..14e08e51b01ed 100644 --- a/tests/baselines/reference/inferredIndexerOnNamespaceImport.js +++ b/tests/baselines/reference/inferredIndexerOnNamespaceImport.js @@ -20,8 +20,15 @@ exports.x = 3; exports.y = 5; //// [bar.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var foo = require("./foo"); +var foo = __importStar(require("./foo")); function f(map) { // ... } diff --git a/tests/baselines/reference/invalidSyntaxNamespaceImportWithCommonjs.js b/tests/baselines/reference/invalidSyntaxNamespaceImportWithCommonjs.js index 29b8c50c4c555..fb88b6dc9a762 100644 --- a/tests/baselines/reference/invalidSyntaxNamespaceImportWithCommonjs.js +++ b/tests/baselines/reference/invalidSyntaxNamespaceImportWithCommonjs.js @@ -17,7 +17,14 @@ var C = /** @class */ (function () { exports.C = C; //// [1.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var from = require(); +var from = __importStar(require()); from; "./0"; diff --git a/tests/baselines/reference/isolatedModulesImportExportElision.js b/tests/baselines/reference/isolatedModulesImportExportElision.js index 7c5fac47706e1..db9b0408ddad2 100644 --- a/tests/baselines/reference/isolatedModulesImportExportElision.js +++ b/tests/baselines/reference/isolatedModulesImportExportElision.js @@ -24,10 +24,17 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); var module_1 = require("module"); var module_2 = require("module"); -var ns = require("module"); +var ns = __importStar(require("module")); var C = /** @class */ (function (_super) { __extends(C, _super); function C() { diff --git a/tests/baselines/reference/isolatedModulesReExportType.js b/tests/baselines/reference/isolatedModulesReExportType.js index f057395fc3039..d26218689354e 100644 --- a/tests/baselines/reference/isolatedModulesReExportType.js +++ b/tests/baselines/reference/isolatedModulesReExportType.js @@ -58,10 +58,17 @@ var C = /** @class */ (function () { exports.C = C; //// [user.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; // OK, has a value side var exportValue_1 = require("./exportValue"); exports.C = exportValue_1.C; // OK, even though the namespace it exports is only types. -var NS = require("./exportT"); +var NS = __importStar(require("./exportT")); exports.NS = NS; diff --git a/tests/baselines/reference/jsxImportInAttribute.js b/tests/baselines/reference/jsxImportInAttribute.js index b249d88a6c2b4..e15934bd4a3a2 100644 --- a/tests/baselines/reference/jsxImportInAttribute.js +++ b/tests/baselines/reference/jsxImportInAttribute.js @@ -15,8 +15,11 @@ let x = Test; // emit test_1.default //// [consumer.jsx] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; /// -var Test_1 = require("Test"); +var Test_1 = __importDefault(require("Test")); var x = Test_1["default"]; // emit test_1.default ; // ? diff --git a/tests/baselines/reference/jsxViaImport.2.js b/tests/baselines/reference/jsxViaImport.2.js index ba6bde70086b1..2f3f11248ec8b 100644 --- a/tests/baselines/reference/jsxViaImport.2.js +++ b/tests/baselines/reference/jsxViaImport.2.js @@ -34,9 +34,12 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; /// -var BaseComponent_1 = require("BaseComponent"); +var BaseComponent_1 = __importDefault(require("BaseComponent")); var TestComponent = /** @class */ (function (_super) { __extends(TestComponent, _super); function TestComponent() { diff --git a/tests/baselines/reference/mergedDeclarations7.js b/tests/baselines/reference/mergedDeclarations7.js index 8fa3f2d0731f5..4120307021335 100644 --- a/tests/baselines/reference/mergedDeclarations7.js +++ b/tests/baselines/reference/mergedDeclarations7.js @@ -24,6 +24,13 @@ let p: Passport = passport.use(); //// [test.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var passport = require("passport"); +var passport = __importStar(require("passport")); var p = passport.use(); diff --git a/tests/baselines/reference/multipleDefaultExports01.js b/tests/baselines/reference/multipleDefaultExports01.js index 0156ff8c309c9..cd1a7b33ca737 100644 --- a/tests/baselines/reference/multipleDefaultExports01.js +++ b/tests/baselines/reference/multipleDefaultExports01.js @@ -33,6 +33,9 @@ var x = 10; exports.default = x; //// [m2.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} Object.defineProperty(exports, "__esModule", { value: true }); -var m1_1 = require("./m1"); +var m1_1 = __importDefault(require("./m1")); m1_1.default(); diff --git a/tests/baselines/reference/multipleDefaultExports02.js b/tests/baselines/reference/multipleDefaultExports02.js index e2827120da2e6..f4c964e82c29f 100644 --- a/tests/baselines/reference/multipleDefaultExports02.js +++ b/tests/baselines/reference/multipleDefaultExports02.js @@ -25,6 +25,9 @@ function bar() { exports.default = bar; //// [m2.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} Object.defineProperty(exports, "__esModule", { value: true }); -var m1_1 = require("./m1"); +var m1_1 = __importDefault(require("./m1")); m1_1.default(); diff --git a/tests/baselines/reference/narrowedImports.js b/tests/baselines/reference/narrowedImports.js index 5dba68e84e5be..8aad58fa1afe3 100644 --- a/tests/baselines/reference/narrowedImports.js +++ b/tests/baselines/reference/narrowedImports.js @@ -26,9 +26,19 @@ if (b1) x = b1; //// [x.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var a_1 = require("./a"); -var b0 = require("./b"); +var a_1 = __importDefault(require("./a")); +var b0 = __importStar(require("./b")); var b1 = require("./b"); var x; if (a_1["default"]) diff --git a/tests/baselines/reference/noCrashOnImportShadowing.js b/tests/baselines/reference/noCrashOnImportShadowing.js index 7ca2116954d6f..0d1b26b807e8c 100644 --- a/tests/baselines/reference/noCrashOnImportShadowing.js +++ b/tests/baselines/reference/noCrashOnImportShadowing.js @@ -32,15 +32,29 @@ exports.__esModule = true; exports.zzz = 123; //// [a.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var B = require("./b"); +var B = __importStar(require("./b")); var x = { x: "" }; B.zzz; //// [index.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; var x = { x: "" }; B.zzz; -var OriginalB = require("./b"); +var OriginalB = __importStar(require("./b")); OriginalB.zzz; var y = x; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js index 24bd0b20bc424..d81cea1e0fb6d 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js @@ -8,8 +8,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -var ng = require("angular2/core"); +var ng = __importStar(require("angular2/core")); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js index 24bd0b20bc424..d81cea1e0fb6d 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js @@ -8,8 +8,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -var ng = require("angular2/core"); +var ng = __importStar(require("angular2/core")); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js index 24bd0b20bc424..d81cea1e0fb6d 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js @@ -8,8 +8,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -var ng = require("angular2/core"); +var ng = __importStar(require("angular2/core")); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js index 24bd0b20bc424..d81cea1e0fb6d 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js @@ -8,8 +8,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -var ng = require("angular2/core"); +var ng = __importStar(require("angular2/core")); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js index 24bd0b20bc424..d81cea1e0fb6d 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js @@ -8,8 +8,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -var ng = require("angular2/core"); +var ng = __importStar(require("angular2/core")); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js b/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js index 4fc36cd0222e6..0268860bddbd6 100644 --- a/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js +++ b/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js @@ -1,6 +1,13 @@ "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var m1 = require("m1"); +var m1 = __importStar(require("m1")); m1.f1("test"); m1.f2.a = 10; m1.f2.person.age = "10"; // Error: Should be number (if direct import of m2 made the m3 module visible). diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/built/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/built/root.js index 5137083683789..6cb0099e9ea40 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/built/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/built/root.js @@ -1,6 +1,13 @@ "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var m1 = require("m1"); +var m1 = __importStar(require("m1")); m1.f1("test"); m1.f2.a = "10"; // Error: Should be number m1.rel = 42; // Error: Should be boolean diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js index 50feab5d27f86..35a15cf85a9dd 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js @@ -1,7 +1,14 @@ "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var m1 = require("m1"); -var m4 = require("m4"); +var m1 = __importStar(require("m1")); +var m4 = __importStar(require("m4")); m1.f1("test"); m1.f2.a = 10; m1.f2.person.age = "10"; // Should error if loaded the .js files correctly diff --git a/tests/baselines/reference/reExportDefaultExport.js b/tests/baselines/reference/reExportDefaultExport.js index ef9386da32a63..e066eecf960fe 100644 --- a/tests/baselines/reference/reExportDefaultExport.js +++ b/tests/baselines/reference/reExportDefaultExport.js @@ -22,8 +22,11 @@ exports.default = f; exports.f = f; //// [m2.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} Object.defineProperty(exports, "__esModule", { value: true }); -var m1_1 = require("./m1"); +var m1_1 = __importDefault(require("./m1")); var m1_2 = require("./m1"); m1_2.f(); m1_1.default(); diff --git a/tests/baselines/reference/reactNamespaceImportPresevation.js b/tests/baselines/reference/reactNamespaceImportPresevation.js index a3e9ac800fee4..fe1eccb411140 100644 --- a/tests/baselines/reference/reactNamespaceImportPresevation.js +++ b/tests/baselines/reference/reactNamespaceImportPresevation.js @@ -15,6 +15,13 @@ declare var foo: any; //// [test.jsx] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var myReactLib = require("my-React-Lib"); // should not be elided +var myReactLib = __importStar(require("my-React-Lib")); // should not be elided ; diff --git a/tests/baselines/reference/requireAsFunctionInExternalModule.js b/tests/baselines/reference/requireAsFunctionInExternalModule.js index f4eac77052a0b..3408015a0ccfc 100644 --- a/tests/baselines/reference/requireAsFunctionInExternalModule.js +++ b/tests/baselines/reference/requireAsFunctionInExternalModule.js @@ -25,8 +25,11 @@ function has(a) { return true; } exports.has = has; //// [m.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var c_1 = require("./c"); +var c_1 = __importDefault(require("./c")); function hello() { } exports.hello = hello; if (c_1.has('ember-debug')) { diff --git a/tests/baselines/reference/transformNestedGeneratorsWithTry.js b/tests/baselines/reference/transformNestedGeneratorsWithTry.js index 28f405e47b9cd..536cb8edea6e9 100644 --- a/tests/baselines/reference/transformNestedGeneratorsWithTry.js +++ b/tests/baselines/reference/transformNestedGeneratorsWithTry.js @@ -59,9 +59,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); // https://github.com/Microsoft/TypeScript/issues/11177 -var Bluebird = require("bluebird"); +var Bluebird = __importStar(require("bluebird")); function a() { return __awaiter(this, void 0, Bluebird, function () { var b, error_1; diff --git a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js index 2b52d660f4e54..a004d6bdeba15 100644 --- a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js +++ b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js @@ -8,8 +8,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -var ng = require("angular2/core"); +var ng = __importStar(require("angular2/core")); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.oldTranspile.js b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.oldTranspile.js index 2b52d660f4e54..a004d6bdeba15 100644 --- a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.oldTranspile.js +++ b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.oldTranspile.js @@ -8,8 +8,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -var ng = require("angular2/core"); +var ng = __importStar(require("angular2/core")); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/tsxDynamicTagName5.js b/tests/baselines/reference/tsxDynamicTagName5.js index 3014c8857de1a..52e3239f08cdf 100644 --- a/tests/baselines/reference/tsxDynamicTagName5.js +++ b/tests/baselines/reference/tsxDynamicTagName5.js @@ -30,8 +30,15 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var React = require("react"); +var React = __importStar(require("react")); var Text = /** @class */ (function (_super) { __extends(Text, _super); function Text() { diff --git a/tests/baselines/reference/tsxDynamicTagName7.js b/tests/baselines/reference/tsxDynamicTagName7.js index 1a845130b4d5d..c89e586533553 100644 --- a/tests/baselines/reference/tsxDynamicTagName7.js +++ b/tests/baselines/reference/tsxDynamicTagName7.js @@ -30,8 +30,15 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var React = require("react"); +var React = __importStar(require("react")); var Text = /** @class */ (function (_super) { __extends(Text, _super); function Text() { diff --git a/tests/baselines/reference/tsxDynamicTagName8.js b/tests/baselines/reference/tsxDynamicTagName8.js index b35c1b88bcffb..7f481a93b6564 100644 --- a/tests/baselines/reference/tsxDynamicTagName8.js +++ b/tests/baselines/reference/tsxDynamicTagName8.js @@ -30,8 +30,15 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var React = require("react"); +var React = __importStar(require("react")); var Text = /** @class */ (function (_super) { __extends(Text, _super); function Text() { diff --git a/tests/baselines/reference/tsxDynamicTagName9.js b/tests/baselines/reference/tsxDynamicTagName9.js index 113629006f6e8..3824f2eff3009 100644 --- a/tests/baselines/reference/tsxDynamicTagName9.js +++ b/tests/baselines/reference/tsxDynamicTagName9.js @@ -30,8 +30,15 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var React = require("react"); +var React = __importStar(require("react")); var Text = /** @class */ (function (_super) { __extends(Text, _super); function Text() { diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.js b/tests/baselines/reference/tsxExternalModuleEmit1.js index 941da1971d554..5c04923b62340 100644 --- a/tests/baselines/reference/tsxExternalModuleEmit1.js +++ b/tests/baselines/reference/tsxExternalModuleEmit1.js @@ -42,8 +42,15 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var React = require("react"); +var React = __importStar(require("react")); var Button = /** @class */ (function (_super) { __extends(Button, _super); function Button() { @@ -67,8 +74,15 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var React = require("react"); +var React = __importStar(require("react")); // Should see var button_1 = require('./button') here var button_1 = require("./button"); var App = /** @class */ (function (_super) { diff --git a/tests/baselines/reference/tsxExternalModuleEmit2.js b/tests/baselines/reference/tsxExternalModuleEmit2.js index adf5ed2aaa633..974373f54f84f 100644 --- a/tests/baselines/reference/tsxExternalModuleEmit2.js +++ b/tests/baselines/reference/tsxExternalModuleEmit2.js @@ -26,8 +26,11 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { } return t; }; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var mod_1 = require("mod"); +var mod_1 = __importDefault(require("mod")); // Should see mod_1['default'] in emit here React.createElement(Foo, { handler: mod_1["default"] }); // Should see mod_1['default'] in emit here diff --git a/tests/baselines/reference/umd-augmentation-1.js b/tests/baselines/reference/umd-augmentation-1.js index e7f7ae5bad5f3..4a4e69942115c 100644 --- a/tests/baselines/reference/umd-augmentation-1.js +++ b/tests/baselines/reference/umd-augmentation-1.js @@ -40,9 +40,16 @@ var t = p.x; //// [b.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; /// -var m = require("math2d"); +var m = __importStar(require("math2d")); var v = new m.Vector(3, 2); var magnitude = m.getLength(v); var p = v.translate(5, 5); diff --git a/tests/baselines/reference/umd-augmentation-3.js b/tests/baselines/reference/umd-augmentation-3.js index f0fb1fe0f4270..cba8335c7ab8d 100644 --- a/tests/baselines/reference/umd-augmentation-3.js +++ b/tests/baselines/reference/umd-augmentation-3.js @@ -46,9 +46,16 @@ var t = p.x; //// [b.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; /// -var m = require("math2d"); +var m = __importStar(require("math2d")); var v = new m.Vector(3, 2); var magnitude = m.getLength(v); var p = v.translate(5, 5); diff --git a/tests/baselines/reference/umd3.js b/tests/baselines/reference/umd3.js index 59b0e0ef2c29e..175ece3c28b45 100644 --- a/tests/baselines/reference/umd3.js +++ b/tests/baselines/reference/umd3.js @@ -15,8 +15,15 @@ let y: number = x.n; //// [a.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var Foo = require("./foo"); +var Foo = __importStar(require("./foo")); Foo.fn(); var x; var y = x.n; diff --git a/tests/baselines/reference/umd4.js b/tests/baselines/reference/umd4.js index 2f17ee04858c1..ddab566bf8bdd 100644 --- a/tests/baselines/reference/umd4.js +++ b/tests/baselines/reference/umd4.js @@ -15,8 +15,15 @@ let y: number = x.n; //// [a.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var Bar = require("./foo"); +var Bar = __importStar(require("./foo")); Bar.fn(); var x; var y = x.n; diff --git a/tests/baselines/reference/umd5.js b/tests/baselines/reference/umd5.js index 868243d4fd074..b73d3a9b053ed 100644 --- a/tests/baselines/reference/umd5.js +++ b/tests/baselines/reference/umd5.js @@ -17,8 +17,15 @@ let z = Foo; //// [a.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var Bar = require("./foo"); +var Bar = __importStar(require("./foo")); Bar.fn(); var x; var y = x.n; diff --git a/tests/baselines/reference/untypedModuleImport.js b/tests/baselines/reference/untypedModuleImport.js index 90fb9ab5f4386..4f379c0269312 100644 --- a/tests/baselines/reference/untypedModuleImport.js +++ b/tests/baselines/reference/untypedModuleImport.js @@ -23,8 +23,15 @@ foo(bar()); //// [a.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; -var foo = require("foo"); +var foo = __importStar(require("foo")); foo.bar(); //// [b.js] "use strict"; @@ -33,8 +40,11 @@ var foo = require("foo"); foo(); //// [c.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var foo_1 = require("foo"); +var foo_1 = __importDefault(require("foo")); require("./a"); require("./b"); foo_1["default"](foo_1.bar()); diff --git a/tests/baselines/reference/untypedModuleImport_allowJs.js b/tests/baselines/reference/untypedModuleImport_allowJs.js index 5d60df6687c4b..c9d56f4b065b7 100644 --- a/tests/baselines/reference/untypedModuleImport_allowJs.js +++ b/tests/baselines/reference/untypedModuleImport_allowJs.js @@ -12,6 +12,9 @@ foo.bar(); //// [a.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} exports.__esModule = true; -var foo_1 = require("foo"); +var foo_1 = __importDefault(require("foo")); foo_1["default"].bar(); diff --git a/tests/baselines/reference/unusedImports11.js b/tests/baselines/reference/unusedImports11.js index 198dc10e75823..31d6ac2e5e7ac 100644 --- a/tests/baselines/reference/unusedImports11.js +++ b/tests/baselines/reference/unusedImports11.js @@ -29,10 +29,20 @@ exports.Member = Member; exports["default"] = Member; //// [a.js] "use strict"; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; var b_1 = require("./b"); -var b_2 = require("./b"); -var ns = require("./b"); +var b_2 = __importDefault(require("./b")); +var ns = __importStar(require("./b")); var r = require("./b"); new b_1.Member(); new b_2["default"](); From 8abc9070cf579df2d2b11400c48753d355460171 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 1 Nov 2017 16:44:00 -0700 Subject: [PATCH 03/26] Support dynamic imports, write helpers for umd module (and amd is possible) kinds --- src/compiler/transformers/module/module.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index c8513ed530e7d..7c2555e6f4801 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -148,7 +148,7 @@ namespace ts { // Create an updated SourceFile: // // define(moduleName?, ["module1", "module2"], function ... - return updateSourceFileNode(node, + const updated = updateSourceFileNode(node, setTextRange( createNodeArray([ createStatement( @@ -192,6 +192,9 @@ namespace ts { /*location*/ node.statements ) ); + + addEmitHelpers(updated, context.readEmitHelpers()); + return updated; } /** @@ -296,7 +299,7 @@ namespace ts { // } // })(function ...) - return updateSourceFileNode( + const updated = updateSourceFileNode( node, setTextRange( createNodeArray([ @@ -328,6 +331,9 @@ namespace ts { /*location*/ node.statements ) ); + + addEmitHelpers(updated, context.readEmitHelpers()); + return updated; } /** @@ -627,7 +633,8 @@ namespace ts { // We have to wrap require in then callback so that require is done in asynchronously // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately const promiseResolveCall = createCall(createPropertyAccess(createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []); - const requireCall = createCall(createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); + context.requestEmitHelper(commonjsImportStarHelper); + const requireCall = createCall(getHelperName("__importStar"), /*typeArguments*/ undefined, [createCall(createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : [])]); let func: FunctionExpression | ArrowFunction; if (languageVersion >= ScriptTarget.ES2015) { From 2d0c8d32fc651958ac774a74441bd243e9b14417 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 1 Nov 2017 16:44:14 -0700 Subject: [PATCH 04/26] Accept baselines --- .../reference/asyncImportNestedYield.js | 11 +++++++-- .../defaultExportInAwaitExpression01.js | 3 +++ .../dynamicImportInDefaultExportExpression.js | 9 +++++++- .../dynamicImportWithNestedThis_es2015.js | 9 +++++++- .../dynamicImportWithNestedThis_es5.js | 9 +++++++- .../importCallExpressionAsyncES3CJS.js | 17 ++++++++++---- .../importCallExpressionAsyncES3UMD.js | 17 ++++++++++---- .../importCallExpressionAsyncES5CJS.js | 17 ++++++++++---- .../importCallExpressionAsyncES5UMD.js | 17 ++++++++++---- .../importCallExpressionAsyncES6CJS.js | 17 ++++++++++---- .../importCallExpressionAsyncES6UMD.js | 17 ++++++++++---- .../importCallExpressionCheckReturntype1.js | 13 ++++++++--- .../importCallExpressionDeclarationEmit1.js | 17 ++++++++++---- .../reference/importCallExpressionES5CJS.js | 19 ++++++++++----- .../reference/importCallExpressionES5UMD.js | 19 ++++++++++----- .../reference/importCallExpressionES6CJS.js | 19 ++++++++++----- .../reference/importCallExpressionES6UMD.js | 19 ++++++++++----- .../importCallExpressionGrammarError.js | 17 ++++++++++---- .../reference/importCallExpressionInCJS1.js | 15 ++++++++---- .../reference/importCallExpressionInCJS2.js | 11 +++++++-- .../reference/importCallExpressionInCJS3.js | 9 +++++++- .../reference/importCallExpressionInCJS4.js | 9 +++++++- .../reference/importCallExpressionInCJS5.js | 19 ++++++++++----- .../importCallExpressionInExportEqualsCJS.js | 9 +++++++- .../importCallExpressionInExportEqualsUMD.js | 9 +++++++- .../importCallExpressionInScriptContext1.js | 9 +++++++- .../importCallExpressionInScriptContext2.js | 9 +++++++- .../reference/importCallExpressionInUMD1.js | 15 ++++++++---- .../reference/importCallExpressionInUMD2.js | 9 +++++++- .../reference/importCallExpressionInUMD3.js | 9 +++++++- .../reference/importCallExpressionInUMD4.js | 19 ++++++++++----- .../importCallExpressionNestedCJS.js | 9 +++++++- .../importCallExpressionNestedCJS2.js | 11 +++++++-- .../importCallExpressionNestedUMD.js | 9 +++++++- .../importCallExpressionNestedUMD2.js | 11 +++++++-- ...portCallExpressionNoModuleKindSpecified.js | 13 ++++++++--- .../importCallExpressionReturnPromiseOfAny.js | 23 ++++++++++++------- ...llExpressionSpecifierNotStringTypeError.js | 17 ++++++++++---- .../importCallExpressionWithTypeArgument.js | 11 +++++++-- 39 files changed, 395 insertions(+), 126 deletions(-) diff --git a/tests/baselines/reference/asyncImportNestedYield.js b/tests/baselines/reference/asyncImportNestedYield.js index 0dd76a13ace8c..d9be2db1c88b9 100644 --- a/tests/baselines/reference/asyncImportNestedYield.js +++ b/tests/baselines/reference/asyncImportNestedYield.js @@ -43,14 +43,21 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} function foo() { return __asyncGenerator(this, arguments, function foo_1() { return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, "foo"]; - case 1: return [4 /*yield*/, __await.apply(void 0, [Promise.resolve().then(function () { return require(_a.sent()); })])]; + case 1: return [4 /*yield*/, __await.apply(void 0, [Promise.resolve().then(function () { return __importStar(require(_a.sent())); })])]; case 2: - Promise.resolve().then(function () { return require((_a.sent())["default"]); }); + Promise.resolve().then(function () { return __importStar(require((_a.sent())["default"])); }); return [2 /*return*/]; } }); diff --git a/tests/baselines/reference/defaultExportInAwaitExpression01.js b/tests/baselines/reference/defaultExportInAwaitExpression01.js index ae6c5e7fe0e7f..26b2cd6abf857 100644 --- a/tests/baselines/reference/defaultExportInAwaitExpression01.js +++ b/tests/baselines/reference/defaultExportInAwaitExpression01.js @@ -36,6 +36,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); diff --git a/tests/baselines/reference/dynamicImportInDefaultExportExpression.js b/tests/baselines/reference/dynamicImportInDefaultExportExpression.js index 75e5e0d57a22e..f1752e777e378 100644 --- a/tests/baselines/reference/dynamicImportInDefaultExportExpression.js +++ b/tests/baselines/reference/dynamicImportInDefaultExportExpression.js @@ -7,9 +7,16 @@ export default { //// [dynamicImportInDefaultExportExpression.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} exports.__esModule = true; exports["default"] = { getInstance: function () { - return Promise.resolve().then(function () { return require('./foo2'); }); + return Promise.resolve().then(function () { return __importStar(require('./foo2')); }); } }; diff --git a/tests/baselines/reference/dynamicImportWithNestedThis_es2015.js b/tests/baselines/reference/dynamicImportWithNestedThis_es2015.js index 4f79e0caec1c2..0deaa048fb05d 100644 --- a/tests/baselines/reference/dynamicImportWithNestedThis_es2015.js +++ b/tests/baselines/reference/dynamicImportWithNestedThis_es2015.js @@ -12,6 +12,13 @@ const c = new C(); c.dynamic(); //// [dynamicImportWithNestedThis_es2015.js] +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -29,7 +36,7 @@ c.dynamic(); this._path = './other'; } dynamic() { - return _a = this._path, __syncRequire ? Promise.resolve().then(() => require(_a)) : new Promise((resolve_1, reject_1) => { require([_a], resolve_1, reject_1); }); + return _a = this._path, __syncRequire ? Promise.resolve().then(() => __importStar(require(_a))) : new Promise((resolve_1, reject_1) => { require([_a], resolve_1, reject_1); }); var _a; } } diff --git a/tests/baselines/reference/dynamicImportWithNestedThis_es5.js b/tests/baselines/reference/dynamicImportWithNestedThis_es5.js index fcfde9e9887f1..c6f56a3983c5b 100644 --- a/tests/baselines/reference/dynamicImportWithNestedThis_es5.js +++ b/tests/baselines/reference/dynamicImportWithNestedThis_es5.js @@ -12,6 +12,13 @@ const c = new C(); c.dynamic(); //// [dynamicImportWithNestedThis_es5.js] +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -30,7 +37,7 @@ c.dynamic(); } C.prototype.dynamic = function () { var _this = this; - return _a = this._path, __syncRequire ? Promise.resolve().then(function () { return require(_a); }) : new Promise(function (resolve_1, reject_1) { require([_a], resolve_1, reject_1); }); + return _a = this._path, __syncRequire ? Promise.resolve().then(function () { return __importStar(require(_a)); }) : new Promise(function (resolve_1, reject_1) { require([_a], resolve_1, reject_1); }); var _a; }; return C; diff --git a/tests/baselines/reference/importCallExpressionAsyncES3CJS.js b/tests/baselines/reference/importCallExpressionAsyncES3CJS.js index 8c3c0d1da6fc4..f40edc796e917 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES3CJS.js +++ b/tests/baselines/reference/importCallExpressionAsyncES3CJS.js @@ -65,6 +65,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} var _this = this; exports.__esModule = true; function fn() { @@ -72,7 +79,7 @@ function fn() { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // ONE + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // ONE case 1: req = _a.sent() // ONE ; @@ -90,7 +97,7 @@ var cl1 = /** @class */ (function () { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // TWO + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // TWO case 1: req = _a.sent() // TWO ; @@ -107,7 +114,7 @@ exports.obj = { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // THREE + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // THREE case 1: req = _a.sent() // THREE ; @@ -124,7 +131,7 @@ var cl2 = /** @class */ (function () { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // FOUR + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // FOUR case 1: req = _a.sent() // FOUR ; @@ -141,7 +148,7 @@ exports.l = function () { return __awaiter(_this, void 0, void 0, function () { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // FIVE + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // FIVE case 1: req = _a.sent() // FIVE ; diff --git a/tests/baselines/reference/importCallExpressionAsyncES3UMD.js b/tests/baselines/reference/importCallExpressionAsyncES3UMD.js index fce2af411e035..4f60f1e1b73a6 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES3UMD.js +++ b/tests/baselines/reference/importCallExpressionAsyncES3UMD.js @@ -64,6 +64,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -82,7 +89,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); })]; // ONE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); })]; // ONE case 1: req = _a.sent() // ONE ; @@ -100,7 +107,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); })]; // TWO + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); })]; // TWO case 1: req = _a.sent() // TWO ; @@ -117,7 +124,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); })]; // THREE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); })]; // THREE case 1: req = _a.sent() // THREE ; @@ -134,7 +141,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); })]; // FOUR + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); })]; // FOUR case 1: req = _a.sent() // FOUR ; @@ -151,7 +158,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); })]; // FIVE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); })]; // FIVE case 1: req = _a.sent() // FIVE ; diff --git a/tests/baselines/reference/importCallExpressionAsyncES5CJS.js b/tests/baselines/reference/importCallExpressionAsyncES5CJS.js index 87499670f3a27..8e9bfb0363334 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES5CJS.js +++ b/tests/baselines/reference/importCallExpressionAsyncES5CJS.js @@ -65,6 +65,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} var _this = this; Object.defineProperty(exports, "__esModule", { value: true }); function fn() { @@ -72,7 +79,7 @@ function fn() { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // ONE + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // ONE case 1: req = _a.sent() // ONE ; @@ -90,7 +97,7 @@ var cl1 = /** @class */ (function () { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // TWO + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // TWO case 1: req = _a.sent() // TWO ; @@ -107,7 +114,7 @@ exports.obj = { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // THREE + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // THREE case 1: req = _a.sent() // THREE ; @@ -124,7 +131,7 @@ var cl2 = /** @class */ (function () { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // FOUR + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // FOUR case 1: req = _a.sent() // FOUR ; @@ -141,7 +148,7 @@ exports.l = function () { return __awaiter(_this, void 0, void 0, function () { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // FIVE + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // FIVE case 1: req = _a.sent() // FIVE ; diff --git a/tests/baselines/reference/importCallExpressionAsyncES5UMD.js b/tests/baselines/reference/importCallExpressionAsyncES5UMD.js index a3b3e74db6bb4..202c74a81eda4 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES5UMD.js +++ b/tests/baselines/reference/importCallExpressionAsyncES5UMD.js @@ -64,6 +64,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -82,7 +89,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); })]; // ONE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); })]; // ONE case 1: req = _a.sent() // ONE ; @@ -100,7 +107,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); })]; // TWO + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); })]; // TWO case 1: req = _a.sent() // TWO ; @@ -117,7 +124,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); })]; // THREE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); })]; // THREE case 1: req = _a.sent() // THREE ; @@ -134,7 +141,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); })]; // FOUR + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); })]; // FOUR case 1: req = _a.sent() // FOUR ; @@ -151,7 +158,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); })]; // FIVE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); })]; // FIVE case 1: req = _a.sent() // FIVE ; diff --git a/tests/baselines/reference/importCallExpressionAsyncES6CJS.js b/tests/baselines/reference/importCallExpressionAsyncES6CJS.js index 20961f9633069..672fe1055962f 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES6CJS.js +++ b/tests/baselines/reference/importCallExpressionAsyncES6CJS.js @@ -38,36 +38,43 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); function fn() { return __awaiter(this, void 0, void 0, function* () { - const req = yield Promise.resolve().then(() => require('./test')); // ONE + const req = yield Promise.resolve().then(() => __importStar(require('./test'))); // ONE }); } exports.fn = fn; class cl1 { m() { return __awaiter(this, void 0, void 0, function* () { - const req = yield Promise.resolve().then(() => require('./test')); // TWO + const req = yield Promise.resolve().then(() => __importStar(require('./test'))); // TWO }); } } exports.cl1 = cl1; exports.obj = { m: () => __awaiter(this, void 0, void 0, function* () { - const req = yield Promise.resolve().then(() => require('./test')); // THREE + const req = yield Promise.resolve().then(() => __importStar(require('./test'))); // THREE }) }; class cl2 { constructor() { this.p = { m: () => __awaiter(this, void 0, void 0, function* () { - const req = yield Promise.resolve().then(() => require('./test')); // FOUR + const req = yield Promise.resolve().then(() => __importStar(require('./test'))); // FOUR }) }; } } exports.cl2 = cl2; exports.l = () => __awaiter(this, void 0, void 0, function* () { - const req = yield Promise.resolve().then(() => require('./test')); // FIVE + const req = yield Promise.resolve().then(() => __importStar(require('./test'))); // FIVE }); diff --git a/tests/baselines/reference/importCallExpressionAsyncES6UMD.js b/tests/baselines/reference/importCallExpressionAsyncES6UMD.js index 1d4aff0267060..b0e543159bfb6 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES6UMD.js +++ b/tests/baselines/reference/importCallExpressionAsyncES6UMD.js @@ -37,6 +37,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -51,34 +58,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge Object.defineProperty(exports, "__esModule", { value: true }); function fn() { return __awaiter(this, void 0, void 0, function* () { - const req = yield __syncRequire ? Promise.resolve().then(() => require('./test')) : new Promise((resolve_1, reject_1) => { require(['./test'], resolve_1, reject_1); }); // ONE + const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_1, reject_1) => { require(['./test'], resolve_1, reject_1); }); // ONE }); } exports.fn = fn; class cl1 { m() { return __awaiter(this, void 0, void 0, function* () { - const req = yield __syncRequire ? Promise.resolve().then(() => require('./test')) : new Promise((resolve_2, reject_2) => { require(['./test'], resolve_2, reject_2); }); // TWO + const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_2, reject_2) => { require(['./test'], resolve_2, reject_2); }); // TWO }); } } exports.cl1 = cl1; exports.obj = { m: () => __awaiter(this, void 0, void 0, function* () { - const req = yield __syncRequire ? Promise.resolve().then(() => require('./test')) : new Promise((resolve_3, reject_3) => { require(['./test'], resolve_3, reject_3); }); // THREE + const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_3, reject_3) => { require(['./test'], resolve_3, reject_3); }); // THREE }) }; class cl2 { constructor() { this.p = { m: () => __awaiter(this, void 0, void 0, function* () { - const req = yield __syncRequire ? Promise.resolve().then(() => require('./test')) : new Promise((resolve_4, reject_4) => { require(['./test'], resolve_4, reject_4); }); // FOUR + const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_4, reject_4) => { require(['./test'], resolve_4, reject_4); }); // FOUR }) }; } } exports.cl2 = cl2; exports.l = () => __awaiter(this, void 0, void 0, function* () { - const req = yield __syncRequire ? Promise.resolve().then(() => require('./test')) : new Promise((resolve_5, reject_5) => { require(['./test'], resolve_5, reject_5); }); // FIVE + const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_5, reject_5) => { require(['./test'], resolve_5, reject_5); }); // FIVE }); }); diff --git a/tests/baselines/reference/importCallExpressionCheckReturntype1.js b/tests/baselines/reference/importCallExpressionCheckReturntype1.js index 3cc4893ff6720..efe4b134e5ede 100644 --- a/tests/baselines/reference/importCallExpressionCheckReturntype1.js +++ b/tests/baselines/reference/importCallExpressionCheckReturntype1.js @@ -29,7 +29,14 @@ class C { exports.C = C; //// [1.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -let p1 = Promise.resolve().then(() => require("./defaultPath")); -let p2 = Promise.resolve().then(() => require("./defaultPath")); -let p3 = Promise.resolve().then(() => require("./defaultPath")); +let p1 = Promise.resolve().then(() => __importStar(require("./defaultPath"))); +let p2 = Promise.resolve().then(() => __importStar(require("./defaultPath"))); +let p3 = Promise.resolve().then(() => __importStar(require("./defaultPath"))); diff --git a/tests/baselines/reference/importCallExpressionDeclarationEmit1.js b/tests/baselines/reference/importCallExpressionDeclarationEmit1.js index 721d85abe717a..30104863134f9 100644 --- a/tests/baselines/reference/importCallExpressionDeclarationEmit1.js +++ b/tests/baselines/reference/importCallExpressionDeclarationEmit1.js @@ -15,12 +15,19 @@ function returnDynamicLoad(path: string) { } //// [importCallExpressionDeclarationEmit1.js] -Promise.resolve().then(() => require(getSpecifier())); -var p0 = Promise.resolve().then(() => require(`${directory}\${moduleFile}`)); -var p1 = Promise.resolve().then(() => require(getSpecifier())); -const p2 = Promise.resolve().then(() => require(whatToLoad ? getSpecifier() : "defaulPath")); +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} +Promise.resolve().then(() => __importStar(require(getSpecifier()))); +var p0 = Promise.resolve().then(() => __importStar(require(`${directory}\${moduleFile}`))); +var p1 = Promise.resolve().then(() => __importStar(require(getSpecifier()))); +const p2 = Promise.resolve().then(() => __importStar(require(whatToLoad ? getSpecifier() : "defaulPath"))); function returnDynamicLoad(path) { - return Promise.resolve().then(() => require(path)); + return Promise.resolve().then(() => __importStar(require(path))); } diff --git a/tests/baselines/reference/importCallExpressionES5CJS.js b/tests/baselines/reference/importCallExpressionES5CJS.js index 521044a10ceb7..c63d8b002ed71 100644 --- a/tests/baselines/reference/importCallExpressionES5CJS.js +++ b/tests/baselines/reference/importCallExpressionES5CJS.js @@ -35,21 +35,28 @@ function foo() { return "foo"; } exports.foo = foo; //// [1.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -Promise.resolve().then(function () { return require("./0"); }); -var p1 = Promise.resolve().then(function () { return require("./0"); }); +Promise.resolve().then(function () { return __importStar(require("./0")); }); +var p1 = Promise.resolve().then(function () { return __importStar(require("./0")); }); p1.then(function (zero) { return zero.foo(); }); -exports.p2 = Promise.resolve().then(function () { return require("./0"); }); +exports.p2 = Promise.resolve().then(function () { return __importStar(require("./0")); }); function foo() { - var p2 = Promise.resolve().then(function () { return require("./0"); }); + var p2 = Promise.resolve().then(function () { return __importStar(require("./0")); }); } var C = /** @class */ (function () { function C() { } C.prototype.method = function () { - var loadAsync = Promise.resolve().then(function () { return require("./0"); }); + var loadAsync = Promise.resolve().then(function () { return __importStar(require("./0")); }); }; return C; }()); @@ -57,7 +64,7 @@ var D = /** @class */ (function () { function D() { } D.prototype.method = function () { - var loadAsync = Promise.resolve().then(function () { return require("./0"); }); + var loadAsync = Promise.resolve().then(function () { return __importStar(require("./0")); }); }; return D; }()); diff --git a/tests/baselines/reference/importCallExpressionES5UMD.js b/tests/baselines/reference/importCallExpressionES5UMD.js index 0ca61909ddc0c..fa2a4ca46617b 100644 --- a/tests/baselines/reference/importCallExpressionES5UMD.js +++ b/tests/baselines/reference/importCallExpressionES5UMD.js @@ -44,6 +44,13 @@ export class D { exports.foo = foo; }); //// [1.js] +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -56,20 +63,20 @@ export class D { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; Object.defineProperty(exports, "__esModule", { value: true }); - __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }); - var p1 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }); + __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }); + var p1 = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }); p1.then(function (zero) { return zero.foo(); }); - exports.p2 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }); + exports.p2 = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }); function foo() { - var p2 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }); + var p2 = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }); } var C = /** @class */ (function () { function C() { } C.prototype.method = function () { - var loadAsync = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_5, reject_5) { require(["./0"], resolve_5, reject_5); }); + var loadAsync = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_5, reject_5) { require(["./0"], resolve_5, reject_5); }); }; return C; }()); @@ -77,7 +84,7 @@ export class D { function D() { } D.prototype.method = function () { - var loadAsync = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_6, reject_6) { require(["./0"], resolve_6, reject_6); }); + var loadAsync = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_6, reject_6) { require(["./0"], resolve_6, reject_6); }); }; return D; }()); diff --git a/tests/baselines/reference/importCallExpressionES6CJS.js b/tests/baselines/reference/importCallExpressionES6CJS.js index a1d8108bdeac4..d106d9eb8d322 100644 --- a/tests/baselines/reference/importCallExpressionES6CJS.js +++ b/tests/baselines/reference/importCallExpressionES6CJS.js @@ -35,24 +35,31 @@ function foo() { return "foo"; } exports.foo = foo; //// [1.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -Promise.resolve().then(() => require("./0")); -var p1 = Promise.resolve().then(() => require("./0")); +Promise.resolve().then(() => __importStar(require("./0"))); +var p1 = Promise.resolve().then(() => __importStar(require("./0"))); p1.then(zero => { return zero.foo(); }); -exports.p2 = Promise.resolve().then(() => require("./0")); +exports.p2 = Promise.resolve().then(() => __importStar(require("./0"))); function foo() { - const p2 = Promise.resolve().then(() => require("./0")); + const p2 = Promise.resolve().then(() => __importStar(require("./0"))); } class C { method() { - const loadAsync = Promise.resolve().then(() => require("./0")); + const loadAsync = Promise.resolve().then(() => __importStar(require("./0"))); } } class D { method() { - const loadAsync = Promise.resolve().then(() => require("./0")); + const loadAsync = Promise.resolve().then(() => __importStar(require("./0"))); } } exports.D = D; diff --git a/tests/baselines/reference/importCallExpressionES6UMD.js b/tests/baselines/reference/importCallExpressionES6UMD.js index 750a1a7cc0c8c..c1618ddd62d97 100644 --- a/tests/baselines/reference/importCallExpressionES6UMD.js +++ b/tests/baselines/reference/importCallExpressionES6UMD.js @@ -44,6 +44,13 @@ export class D { exports.foo = foo; }); //// [1.js] +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -56,23 +63,23 @@ export class D { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; Object.defineProperty(exports, "__esModule", { value: true }); - __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); - var p1 = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); + __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); + var p1 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); p1.then(zero => { return zero.foo(); }); - exports.p2 = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }); + exports.p2 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }); function foo() { - const p2 = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); + const p2 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); } class C { method() { - const loadAsync = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }); + const loadAsync = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }); } } class D { method() { - const loadAsync = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_6, reject_6) => { require(["./0"], resolve_6, reject_6); }); + const loadAsync = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_6, reject_6) => { require(["./0"], resolve_6, reject_6); }); } } exports.D = D; diff --git a/tests/baselines/reference/importCallExpressionGrammarError.js b/tests/baselines/reference/importCallExpressionGrammarError.js index 435eab35d4ea5..559b67b479487 100644 --- a/tests/baselines/reference/importCallExpressionGrammarError.js +++ b/tests/baselines/reference/importCallExpressionGrammarError.js @@ -11,9 +11,16 @@ const p3 = import(,); const p4 = import("pathToModule", "secondModule"); //// [importCallExpressionGrammarError.js] +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} var a = ["./0"]; -Promise.resolve().then(() => require(...["PathModule"])); -var p1 = Promise.resolve().then(() => require(...a)); -const p2 = Promise.resolve().then(() => require()); -const p3 = Promise.resolve().then(() => require()); -const p4 = Promise.resolve().then(() => require("pathToModule")); +Promise.resolve().then(() => __importStar(require(...["PathModule"]))); +var p1 = Promise.resolve().then(() => __importStar(require(...a))); +const p2 = Promise.resolve().then(() => __importStar(require())); +const p3 = Promise.resolve().then(() => __importStar(require())); +const p4 = Promise.resolve().then(() => __importStar(require("pathToModule"))); diff --git a/tests/baselines/reference/importCallExpressionInCJS1.js b/tests/baselines/reference/importCallExpressionInCJS1.js index c814f5e567133..2f1a32abe0bb5 100644 --- a/tests/baselines/reference/importCallExpressionInCJS1.js +++ b/tests/baselines/reference/importCallExpressionInCJS1.js @@ -23,13 +23,20 @@ function foo() { return "foo"; } exports.foo = foo; //// [1.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -Promise.resolve().then(() => require("./0")); -var p1 = Promise.resolve().then(() => require("./0")); +Promise.resolve().then(() => __importStar(require("./0"))); +var p1 = Promise.resolve().then(() => __importStar(require("./0"))); p1.then(zero => { return zero.foo(); }); -exports.p2 = Promise.resolve().then(() => require("./0")); +exports.p2 = Promise.resolve().then(() => __importStar(require("./0"))); function foo() { - const p2 = Promise.resolve().then(() => require("./0")); + const p2 = Promise.resolve().then(() => __importStar(require("./0"))); } diff --git a/tests/baselines/reference/importCallExpressionInCJS2.js b/tests/baselines/reference/importCallExpressionInCJS2.js index fb559cb11937a..76eea19f18c12 100644 --- a/tests/baselines/reference/importCallExpressionInCJS2.js +++ b/tests/baselines/reference/importCallExpressionInCJS2.js @@ -29,12 +29,19 @@ Object.defineProperty(exports, "__esModule", { value: true }); function backup() { return "backup"; } exports.backup = backup; //// [2.js] +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} async function compute(promise) { let j = await promise; if (!j) { - j = await Promise.resolve().then(() => require("./1")); + j = await Promise.resolve().then(() => __importStar(require("./1"))); return j.backup(); } return j.foo(); } -compute(Promise.resolve().then(() => require("./0"))); +compute(Promise.resolve().then(() => __importStar(require("./0")))); diff --git a/tests/baselines/reference/importCallExpressionInCJS3.js b/tests/baselines/reference/importCallExpressionInCJS3.js index 616fbc9c3f9f5..74e1eb50a296f 100644 --- a/tests/baselines/reference/importCallExpressionInCJS3.js +++ b/tests/baselines/reference/importCallExpressionInCJS3.js @@ -24,6 +24,13 @@ class B { } exports.B = B; //// [2.js] +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} // We use Promise for now as there is no way to specify shape of module object function foo(x) { x.then(value => { @@ -31,4 +38,4 @@ function foo(x) { b.print(); }); } -foo(Promise.resolve().then(() => require("./0"))); +foo(Promise.resolve().then(() => __importStar(require("./0")))); diff --git a/tests/baselines/reference/importCallExpressionInCJS4.js b/tests/baselines/reference/importCallExpressionInCJS4.js index b88295110b83a..ca1d27a7885c9 100644 --- a/tests/baselines/reference/importCallExpressionInCJS4.js +++ b/tests/baselines/reference/importCallExpressionInCJS4.js @@ -21,8 +21,15 @@ class B { } exports.B = B; //// [2.js] +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} async function foo() { - class C extends (await Promise.resolve().then(() => require("./0"))).B { + class C extends (await Promise.resolve().then(() => __importStar(require("./0")))).B { } var c = new C(); c.print(); diff --git a/tests/baselines/reference/importCallExpressionInCJS5.js b/tests/baselines/reference/importCallExpressionInCJS5.js index b32b0e52c50f7..810529833a78e 100644 --- a/tests/baselines/reference/importCallExpressionInCJS5.js +++ b/tests/baselines/reference/importCallExpressionInCJS5.js @@ -56,33 +56,40 @@ function backup() { return "backup"; } exports.backup = backup; //// [2.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); class C { constructor() { - this.myModule = Promise.resolve().then(() => require("./0")); + this.myModule = Promise.resolve().then(() => __importStar(require("./0"))); } method() { - const loadAsync = Promise.resolve().then(() => require("./0")); + const loadAsync = Promise.resolve().then(() => __importStar(require("./0"))); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { console.log(err); - let one = await Promise.resolve().then(() => require("./1")); + let one = await Promise.resolve().then(() => __importStar(require("./1"))); console.log(one.backup()); }); } } class D { constructor() { - this.myModule = Promise.resolve().then(() => require("./0")); + this.myModule = Promise.resolve().then(() => __importStar(require("./0"))); } method() { - const loadAsync = Promise.resolve().then(() => require("./0")); + const loadAsync = Promise.resolve().then(() => __importStar(require("./0"))); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { console.log(err); - let one = await Promise.resolve().then(() => require("./1")); + let one = await Promise.resolve().then(() => __importStar(require("./1"))); console.log(one.backup()); }); } diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsCJS.js b/tests/baselines/reference/importCallExpressionInExportEqualsCJS.js index 72e3a0ec0af9b..2abd57802313d 100644 --- a/tests/baselines/reference/importCallExpressionInExportEqualsCJS.js +++ b/tests/baselines/reference/importCallExpressionInExportEqualsCJS.js @@ -13,6 +13,13 @@ export = async function() { module.exports = 42; //// [index.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} module.exports = async function () { - const something = await Promise.resolve().then(() => require("./something")); + const something = await Promise.resolve().then(() => __importStar(require("./something"))); }; diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsUMD.js b/tests/baselines/reference/importCallExpressionInExportEqualsUMD.js index 5f70891b09e8e..356230e0d686c 100644 --- a/tests/baselines/reference/importCallExpressionInExportEqualsUMD.js +++ b/tests/baselines/reference/importCallExpressionInExportEqualsUMD.js @@ -22,6 +22,13 @@ export = async function() { return 42; }); //// [index.js] +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -34,6 +41,6 @@ export = async function() { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; return async function () { - const something = await (__syncRequire ? Promise.resolve().then(() => require("./something")) : new Promise((resolve_1, reject_1) => { require(["./something"], resolve_1, reject_1); })); + const something = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./something"))) : new Promise((resolve_1, reject_1) => { require(["./something"], resolve_1, reject_1); })); }; }); diff --git a/tests/baselines/reference/importCallExpressionInScriptContext1.js b/tests/baselines/reference/importCallExpressionInScriptContext1.js index 53c6118f61bf1..4d93fb0504a51 100644 --- a/tests/baselines/reference/importCallExpressionInScriptContext1.js +++ b/tests/baselines/reference/importCallExpressionInScriptContext1.js @@ -13,5 +13,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); function foo() { return "foo"; } exports.foo = foo; //// [1.js] -var p1 = Promise.resolve().then(() => require("./0")); +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} +var p1 = Promise.resolve().then(() => __importStar(require("./0"))); function arguments() { } // this is allow as the file doesn't have implicit "use strict" diff --git a/tests/baselines/reference/importCallExpressionInScriptContext2.js b/tests/baselines/reference/importCallExpressionInScriptContext2.js index 4a0d4a1bf5a98..11579c83e1d0f 100644 --- a/tests/baselines/reference/importCallExpressionInScriptContext2.js +++ b/tests/baselines/reference/importCallExpressionInScriptContext2.js @@ -15,5 +15,12 @@ function foo() { return "foo"; } exports.foo = foo; //// [1.js] "use strict"; -var p1 = Promise.resolve().then(() => require("./0")); +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} +var p1 = Promise.resolve().then(() => __importStar(require("./0"))); function arguments() { } diff --git a/tests/baselines/reference/importCallExpressionInUMD1.js b/tests/baselines/reference/importCallExpressionInUMD1.js index 597e68e2d6f71..73e0de92a0c14 100644 --- a/tests/baselines/reference/importCallExpressionInUMD1.js +++ b/tests/baselines/reference/importCallExpressionInUMD1.js @@ -32,6 +32,13 @@ function foo() { exports.foo = foo; }); //// [1.js] +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -44,13 +51,13 @@ function foo() { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; Object.defineProperty(exports, "__esModule", { value: true }); - __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); - var p1 = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); + __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); + var p1 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); p1.then(zero => { return zero.foo(); }); - exports.p2 = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }); + exports.p2 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }); function foo() { - const p2 = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); + const p2 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); } }); diff --git a/tests/baselines/reference/importCallExpressionInUMD2.js b/tests/baselines/reference/importCallExpressionInUMD2.js index 516800968c13d..fd13b20751fbc 100644 --- a/tests/baselines/reference/importCallExpressionInUMD2.js +++ b/tests/baselines/reference/importCallExpressionInUMD2.js @@ -34,6 +34,13 @@ foo(import("./0")); exports.B = B; }); //// [2.js] +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -52,5 +59,5 @@ foo(import("./0")); b.print(); }); } - foo(__syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); })); + foo(__syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); })); }); diff --git a/tests/baselines/reference/importCallExpressionInUMD3.js b/tests/baselines/reference/importCallExpressionInUMD3.js index 57d200ca70ca3..3922f3e91a343 100644 --- a/tests/baselines/reference/importCallExpressionInUMD3.js +++ b/tests/baselines/reference/importCallExpressionInUMD3.js @@ -31,6 +31,13 @@ foo(); exports.B = B; }); //// [2.js] +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -43,7 +50,7 @@ foo(); "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; async function foo() { - class C extends (await (__syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }))).B { + class C extends (await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }))).B { } var c = new C(); c.print(); diff --git a/tests/baselines/reference/importCallExpressionInUMD4.js b/tests/baselines/reference/importCallExpressionInUMD4.js index 70a574f03028e..bead30e49c1a7 100644 --- a/tests/baselines/reference/importCallExpressionInUMD4.js +++ b/tests/baselines/reference/importCallExpressionInUMD4.js @@ -75,6 +75,13 @@ export class D { exports.backup = backup; }); //// [2.js] +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -89,30 +96,30 @@ export class D { Object.defineProperty(exports, "__esModule", { value: true }); class C { constructor() { - this.myModule = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); + this.myModule = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); } method() { - const loadAsync = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); + const loadAsync = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { console.log(err); - let one = await (__syncRequire ? Promise.resolve().then(() => require("./1")) : new Promise((resolve_3, reject_3) => { require(["./1"], resolve_3, reject_3); })); + let one = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./1"))) : new Promise((resolve_3, reject_3) => { require(["./1"], resolve_3, reject_3); })); console.log(one.backup()); }); } } class D { constructor() { - this.myModule = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); + this.myModule = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); } method() { - const loadAsync = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }); + const loadAsync = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { console.log(err); - let one = await (__syncRequire ? Promise.resolve().then(() => require("./1")) : new Promise((resolve_6, reject_6) => { require(["./1"], resolve_6, reject_6); })); + let one = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./1"))) : new Promise((resolve_6, reject_6) => { require(["./1"], resolve_6, reject_6); })); console.log(one.backup()); }); } diff --git a/tests/baselines/reference/importCallExpressionNestedCJS.js b/tests/baselines/reference/importCallExpressionNestedCJS.js index 07c0f234bf7dc..d1f80c451651e 100644 --- a/tests/baselines/reference/importCallExpressionNestedCJS.js +++ b/tests/baselines/reference/importCallExpressionNestedCJS.js @@ -21,8 +21,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} function foo() { return __awaiter(this, void 0, void 0, function* () { - return yield Promise.resolve().then(() => require((yield Promise.resolve().then(() => require("./foo"))).default)); + return yield Promise.resolve().then(() => __importStar(require((yield Promise.resolve().then(() => __importStar(require("./foo")))).default))); }); } diff --git a/tests/baselines/reference/importCallExpressionNestedCJS2.js b/tests/baselines/reference/importCallExpressionNestedCJS2.js index c76044ec05c2e..fed0c6da28df6 100644 --- a/tests/baselines/reference/importCallExpressionNestedCJS2.js +++ b/tests/baselines/reference/importCallExpressionNestedCJS2.js @@ -48,12 +48,19 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} function foo() { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require("./foo"); })]; - case 1: return [4 /*yield*/, Promise.resolve().then(function () { return require((_a.sent()).default); })]; + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./foo")); })]; + case 1: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require((_a.sent()).default)); })]; case 2: return [2 /*return*/, _a.sent()]; } }); diff --git a/tests/baselines/reference/importCallExpressionNestedUMD.js b/tests/baselines/reference/importCallExpressionNestedUMD.js index 0b1d20af8a421..a428e406db1e5 100644 --- a/tests/baselines/reference/importCallExpressionNestedUMD.js +++ b/tests/baselines/reference/importCallExpressionNestedUMD.js @@ -31,6 +31,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -44,7 +51,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge var __syncRequire = typeof module === "object" && typeof module.exports === "object"; function foo() { return __awaiter(this, void 0, void 0, function* () { - return yield _a = (yield __syncRequire ? Promise.resolve().then(() => require("./foo")) : new Promise((resolve_1, reject_1) => { require(["./foo"], resolve_1, reject_1); })).default, __syncRequire ? Promise.resolve().then(() => require(_a)) : new Promise((resolve_2, reject_2) => { require([_a], resolve_2, reject_2); }); + return yield _a = (yield __syncRequire ? Promise.resolve().then(() => __importStar(require("./foo"))) : new Promise((resolve_1, reject_1) => { require(["./foo"], resolve_1, reject_1); })).default, __syncRequire ? Promise.resolve().then(() => __importStar(require(_a))) : new Promise((resolve_2, reject_2) => { require([_a], resolve_2, reject_2); }); var _a; }); } diff --git a/tests/baselines/reference/importCallExpressionNestedUMD2.js b/tests/baselines/reference/importCallExpressionNestedUMD2.js index 86fd0bfa8f1f8..71c90d074fcb0 100644 --- a/tests/baselines/reference/importCallExpressionNestedUMD2.js +++ b/tests/baselines/reference/importCallExpressionNestedUMD2.js @@ -58,6 +58,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -73,8 +80,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require("./foo"); }) : new Promise(function (resolve_1, reject_1) { require(["./foo"], resolve_1, reject_1); })]; - case 1: return [4 /*yield*/, (_b = (_a.sent()).default, __syncRequire ? Promise.resolve().then(function () { return require(_b); }) : new Promise(function (resolve_2, reject_2) { require([_b], resolve_2, reject_2); }))]; + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./foo")); }) : new Promise(function (resolve_1, reject_1) { require(["./foo"], resolve_1, reject_1); })]; + case 1: return [4 /*yield*/, (_b = (_a.sent()).default, __syncRequire ? Promise.resolve().then(function () { return __importStar(require(_b)); }) : new Promise(function (resolve_2, reject_2) { require([_b], resolve_2, reject_2); }))]; case 2: return [2 /*return*/, _a.sent()]; } var _b; diff --git a/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.js b/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.js index 3135a4066fd39..55a7fd66edf2e 100644 --- a/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.js +++ b/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.js @@ -79,13 +79,20 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} var C = /** @class */ (function () { function C() { - this.myModule = Promise.resolve().then(function () { return require("./0"); }); + this.myModule = Promise.resolve().then(function () { return __importStar(require("./0")); }); } C.prototype.method = function () { var _this = this; - var loadAsync = Promise.resolve().then(function () { return require("./0"); }); + var loadAsync = Promise.resolve().then(function () { return __importStar(require("./0")); }); this.myModule.then(function (Zero) { console.log(Zero.foo()); }, function (err) { return __awaiter(_this, void 0, void 0, function () { @@ -94,7 +101,7 @@ var C = /** @class */ (function () { switch (_a.label) { case 0: console.log(err); - return [4 /*yield*/, Promise.resolve().then(function () { return require("./1"); })]; + return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./1")); })]; case 1: one = _a.sent(); console.log(one.backup()); diff --git a/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.js b/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.js index 8c94510b6095b..61350800a2314 100644 --- a/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.js +++ b/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.js @@ -41,21 +41,28 @@ class C { exports.C = C; //// [1.js] "use strict"; +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} Object.defineProperty(exports, "__esModule", { value: true }); -Promise.resolve().then(() => require(`${directory}\${moduleFile}`)); -Promise.resolve().then(() => require(getSpecifier())); -var p1 = Promise.resolve().then(() => require(ValidSomeCondition() ? "./0" : "externalModule")); -var p1 = Promise.resolve().then(() => require(getSpecifier())); -var p11 = Promise.resolve().then(() => require(getSpecifier())); -const p2 = Promise.resolve().then(() => require(whatToLoad ? getSpecifier() : "defaulPath")); +Promise.resolve().then(() => __importStar(require(`${directory}\${moduleFile}`))); +Promise.resolve().then(() => __importStar(require(getSpecifier()))); +var p1 = Promise.resolve().then(() => __importStar(require(ValidSomeCondition() ? "./0" : "externalModule"))); +var p1 = Promise.resolve().then(() => __importStar(require(getSpecifier()))); +var p11 = Promise.resolve().then(() => __importStar(require(getSpecifier()))); +const p2 = Promise.resolve().then(() => __importStar(require(whatToLoad ? getSpecifier() : "defaulPath"))); p1.then(zero => { return zero.foo(); // ok, zero is any }); let j; -var p3 = Promise.resolve().then(() => require(j = getSpecifier())); +var p3 = Promise.resolve().then(() => __importStar(require(j = getSpecifier()))); function* loadModule(directories) { for (const directory of directories) { const path = `${directory}\moduleFile`; - Promise.resolve().then(() => require(yield path)); + Promise.resolve().then(() => __importStar(require(yield path))); } } diff --git a/tests/baselines/reference/importCallExpressionSpecifierNotStringTypeError.js b/tests/baselines/reference/importCallExpressionSpecifierNotStringTypeError.js index 5e2ace1c4017f..616002cc3932f 100644 --- a/tests/baselines/reference/importCallExpressionSpecifierNotStringTypeError.js +++ b/tests/baselines/reference/importCallExpressionSpecifierNotStringTypeError.js @@ -14,12 +14,19 @@ var p3 = import(["path1", "path2"]); var p4 = import(()=>"PathToModule"); //// [importCallExpressionSpecifierNotStringTypeError.js] +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} // Error specifier is not assignable to string -Promise.resolve().then(() => require(getSpecifier())); -var p1 = Promise.resolve().then(() => require(getSpecifier())); -const p2 = Promise.resolve().then(() => require(whatToLoad ? getSpecifier() : "defaulPath")); +Promise.resolve().then(() => __importStar(require(getSpecifier()))); +var p1 = Promise.resolve().then(() => __importStar(require(getSpecifier()))); +const p2 = Promise.resolve().then(() => __importStar(require(whatToLoad ? getSpecifier() : "defaulPath"))); p1.then(zero => { return zero.foo(); // ok, zero is any }); -var p3 = Promise.resolve().then(() => require(["path1", "path2"])); -var p4 = Promise.resolve().then(() => require(() => "PathToModule")); +var p3 = Promise.resolve().then(() => __importStar(require(["path1", "path2"]))); +var p4 = Promise.resolve().then(() => __importStar(require(() => "PathToModule"))); diff --git a/tests/baselines/reference/importCallExpressionWithTypeArgument.js b/tests/baselines/reference/importCallExpressionWithTypeArgument.js index 885992a798b73..6b2d9f397590b 100644 --- a/tests/baselines/reference/importCallExpressionWithTypeArgument.js +++ b/tests/baselines/reference/importCallExpressionWithTypeArgument.js @@ -15,5 +15,12 @@ function foo() { return "foo"; } exports.foo = foo; //// [1.js] "use strict"; -var p1 = Promise.resolve().then(() => require("./0")); // error -var p2 = Promise.resolve().then(() => require("./0")); // error +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} +var p1 = Promise.resolve().then(() => __importStar(require("./0"))); // error +var p2 = Promise.resolve().then(() => __importStar(require("./0"))); // error From a725916e09fbbc781a5690387fcb62ff2e7f1351 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 2 Nov 2017 12:43:35 -0700 Subject: [PATCH 05/26] Support AMD, use same helper initialization as is normal --- src/compiler/transformers/module/module.ts | 49 +++++++++++++------ tests/baselines/reference/APISample_jsdoc.js | 2 +- tests/baselines/reference/APISample_linter.js | 2 +- .../reference/APISample_transform.js | 2 +- .../baselines/reference/APISample_watcher.js | 2 +- .../allowImportClausesToMergeWithTypes.js | 4 +- .../allowSyntheticDefaultImports1.js | 2 +- .../allowSyntheticDefaultImports4.js | 2 +- .../reference/ambientDeclarationsPatterns.js | 2 +- tests/baselines/reference/ambientShorthand.js | 4 +- .../reference/ambientShorthand_reExport.js | 2 +- .../reference/amdDependencyCommentName4.js | 12 +++++ .../reference/asyncImportNestedYield.js | 2 +- .../reference/augmentExportEquals3.js | 8 +++ .../reference/augmentExportEquals3_1.js | 8 +++ .../reference/augmentExportEquals4.js | 8 +++ .../reference/augmentExportEquals4_1.js | 8 +++ .../reference/augmentExportEquals6.js | 8 +++ .../declarationEmitTypeofDefaultExport.js | 2 +- .../baselines/reference/decoratorMetadata.js | 2 +- .../defaultExportInAwaitExpression01.js | 2 +- .../defaultExportInAwaitExpression02.js | 2 +- .../reference/defaultExportsCannotMerge01.js | 2 +- .../reference/defaultExportsCannotMerge02.js | 2 +- .../reference/defaultExportsCannotMerge03.js | 2 +- .../duplicatePackage_referenceTypes.js | 2 +- .../reference/duplicatePackage_subModule.js | 2 +- .../dynamicImportInDefaultExportExpression.js | 2 +- .../dynamicImportWithNestedThis_es2015.js | 4 +- .../dynamicImportWithNestedThis_es5.js | 4 +- tests/baselines/reference/emptyModuleName.js | 2 +- .../reference/es6ExportEqualsInterop.js | 2 +- .../reference/es6ImportDefaultBindingAmd.js | 4 ++ .../reference/es6ImportDefaultBindingDts.js | 2 +- ...ultBindingFollowedWithNamedImport1InEs5.js | 2 +- ...ndingFollowedWithNamedImport1WithExport.js | 2 +- ...faultBindingFollowedWithNamedImportDts1.js | 2 +- ...ndingFollowedWithNamespaceBinding1InEs5.js | 2 +- ...FollowedWithNamespaceBinding1WithExport.js | 4 ++ ...tBindingFollowedWithNamespaceBindingDts.js | 2 +- ...BindingFollowedWithNamespaceBindingDts1.js | 4 ++ ...indingFollowedWithNamespaceBindingInEs5.js | 2 +- ...gFollowedWithNamespaceBindingWithExport.js | 2 +- .../es6ImportDefaultBindingMergeErrors.js | 2 +- .../es6ImportDefaultBindingWithExport.js | 4 ++ .../reference/es6ImportNameSpaceImport.js | 2 +- .../reference/es6ImportNameSpaceImportAmd.js | 8 +++ .../reference/es6ImportNameSpaceImportDts.js | 2 +- .../es6ImportNameSpaceImportInEs5.js | 2 +- .../es6ImportNameSpaceImportWithExport.js | 8 +++ .../reference/exportAndImport-es3-amd.js | 4 ++ .../reference/exportAndImport-es3.js | 2 +- .../reference/exportAndImport-es5-amd.js | 4 ++ .../reference/exportAndImport-es5.js | 2 +- .../reference/exportDefaultAbstractClass.js | 2 +- .../reference/exportDefaultProperty.js | 2 +- .../reference/exportDefaultProperty2.js | 2 +- .../reference/exportEqualsDefaultProperty.js | 2 +- tests/baselines/reference/exportStar-amd.js | 4 ++ tests/baselines/reference/exportStar.js | 2 +- .../reference/exportStarFromEmptyModule.js | 2 +- .../reference/exportsAndImports4-amd.js | 14 ++++++ .../reference/exportsAndImports4-es6.js | 4 +- .../baselines/reference/exportsAndImports4.js | 4 +- ...sAndImportsWithContextualKeywordNames02.js | 2 +- .../exportsAndImportsWithUnderscores1.js | 2 +- .../exportsAndImportsWithUnderscores2.js | 2 +- .../exportsAndImportsWithUnderscores3.js | 2 +- .../reference/extendsUntypedModule.js | 2 +- .../externalModuleImmutableBindings.js | 2 +- .../importCallExpressionAsyncES3AMD.js | 17 +++++-- .../importCallExpressionAsyncES3CJS.js | 2 +- .../importCallExpressionAsyncES3UMD.js | 12 ++--- .../importCallExpressionAsyncES5AMD.js | 17 +++++-- .../importCallExpressionAsyncES5CJS.js | 2 +- .../importCallExpressionAsyncES5UMD.js | 12 ++--- .../importCallExpressionAsyncES6AMD.js | 17 +++++-- .../importCallExpressionAsyncES6CJS.js | 2 +- .../importCallExpressionAsyncES6UMD.js | 12 ++--- .../importCallExpressionCheckReturntype1.js | 2 +- .../importCallExpressionDeclarationEmit1.js | 2 +- .../reference/importCallExpressionES5AMD.js | 19 ++++--- .../reference/importCallExpressionES5CJS.js | 2 +- .../reference/importCallExpressionES5UMD.js | 14 +++--- .../reference/importCallExpressionES6AMD.js | 19 ++++--- .../reference/importCallExpressionES6CJS.js | 2 +- .../reference/importCallExpressionES6UMD.js | 14 +++--- .../importCallExpressionGrammarError.js | 2 +- .../reference/importCallExpressionInAMD1.js | 15 ++++-- .../reference/importCallExpressionInAMD2.js | 9 +++- .../reference/importCallExpressionInAMD3.js | 9 +++- .../reference/importCallExpressionInAMD4.js | 19 ++++--- .../reference/importCallExpressionInCJS1.js | 2 +- .../reference/importCallExpressionInCJS2.js | 2 +- .../reference/importCallExpressionInCJS3.js | 2 +- .../reference/importCallExpressionInCJS4.js | 2 +- .../reference/importCallExpressionInCJS5.js | 2 +- .../importCallExpressionInExportEqualsAMD.js | 9 +++- .../importCallExpressionInExportEqualsCJS.js | 2 +- .../importCallExpressionInExportEqualsUMD.js | 4 +- .../importCallExpressionInScriptContext1.js | 2 +- .../importCallExpressionInScriptContext2.js | 2 +- .../reference/importCallExpressionInUMD1.js | 10 ++-- .../reference/importCallExpressionInUMD2.js | 4 +- .../reference/importCallExpressionInUMD3.js | 4 +- .../reference/importCallExpressionInUMD4.js | 14 +++--- .../importCallExpressionNestedAMD.js | 9 +++- .../importCallExpressionNestedAMD2.js | 11 ++++- .../importCallExpressionNestedCJS.js | 2 +- .../importCallExpressionNestedCJS2.js | 2 +- .../importCallExpressionNestedUMD.js | 4 +- .../importCallExpressionNestedUMD2.js | 6 +-- ...portCallExpressionNoModuleKindSpecified.js | 2 +- .../importCallExpressionReturnPromiseOfAny.js | 2 +- ...llExpressionSpecifierNotStringTypeError.js | 2 +- .../importCallExpressionWithTypeArgument.js | 2 +- .../reference/importWithTrailingSlash.js | 4 +- .../reference/importsImplicitlyReadonly.js | 2 +- .../inferredIndexerOnNamespaceImport.js | 2 +- ...nvalidSyntaxNamespaceImportWithCommonjs.js | 2 +- .../isolatedModulesImportExportElision.js | 2 +- .../reference/isolatedModulesReExportType.js | 2 +- .../reference/jsxImportInAttribute.js | 2 +- tests/baselines/reference/jsxViaImport.2.js | 2 +- .../reference/mergedDeclarations7.js | 2 +- .../reference/moduleMergeConstructor.js | 8 +++ .../reference/multipleDefaultExports01.js | 2 +- .../reference/multipleDefaultExports02.js | 2 +- tests/baselines/reference/narrowedImports.js | 4 +- .../reference/noCrashOnImportShadowing.js | 4 +- .../reference/outFilerootDirModuleNamesAmd.js | 5 ++ .../amd/main.js | 8 +++ .../node/main.js | 2 +- .../amd/main.js | 8 +++ .../node/main.js | 2 +- .../emitDecoratorMetadataSystemJS/amd/main.js | 8 +++ .../node/main.js | 2 +- .../amd/main.js | 8 +++ .../node/main.js | 2 +- .../amd/main.js | 8 +++ .../node/main.js | 2 +- .../amd/importHigher/root.js | 8 +++ .../node/importHigher/root.js | 2 +- .../amd/maxDepthExceeded/built/root.js | 8 +++ .../node/maxDepthExceeded/built/root.js | 2 +- .../amd/maxDepthIncreased/root.js | 9 ++++ .../node/maxDepthIncreased/root.js | 2 +- .../reference/reExportDefaultExport.js | 2 +- .../reactNamespaceImportPresevation.js | 2 +- .../requireAsFunctionInExternalModule.js | 2 +- .../transformNestedGeneratorsWithTry.js | 2 +- ...ata when transpile with CommonJS option.js | 2 +- ...spile with CommonJS option.oldTranspile.js | 2 +- .../tsconfigMapOptionsAreCaseInsensitive.js | 4 ++ .../baselines/reference/tsxDynamicTagName5.js | 2 +- .../baselines/reference/tsxDynamicTagName7.js | 2 +- .../baselines/reference/tsxDynamicTagName8.js | 2 +- .../baselines/reference/tsxDynamicTagName9.js | 2 +- .../reference/tsxElementResolution19.js | 8 +++ .../reference/tsxExternalModuleEmit1.js | 4 +- .../reference/tsxExternalModuleEmit2.js | 2 +- .../baselines/reference/umd-augmentation-1.js | 2 +- .../baselines/reference/umd-augmentation-3.js | 2 +- tests/baselines/reference/umd3.js | 2 +- tests/baselines/reference/umd4.js | 2 +- tests/baselines/reference/umd5.js | 2 +- .../reference/untypedModuleImport.js | 4 +- .../reference/untypedModuleImport_allowJs.js | 2 +- tests/baselines/reference/unusedImports11.js | 4 +- 169 files changed, 543 insertions(+), 242 deletions(-) diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 7c2555e6f4801..2c42562d67001 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -391,6 +391,18 @@ namespace ts { return { aliasedModuleNames, unaliasedModuleNames, importAliasNames }; } + function getAMDImportExpressionForImport(node: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration) { + if (isImportEqualsDeclaration(node) || isExportDeclaration(node) || !getExternalModuleNameLiteral(node, currentSourceFile, host, resolver, compilerOptions)) { + return undefined; + } + const name = getLocalNameForExternalImport(node, currentSourceFile); + const expr = getHelperExpressionForImport(node, name); + if (expr === name) { + return undefined; + } + return createStatement(createAssignment(name, expr)); + } + /** * Transforms a SourceFile into an AMD or UMD module body. * @@ -408,6 +420,9 @@ namespace ts { // Visit each statement of the module body. append(statements, visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, isStatement)); + if (moduleKind === ModuleKind.AMD) { + addRange(statements, mapDefined(currentModuleInfo.externalImports, getAMDImportExpressionForImport)); + } addRange(statements, visitNodes(node.statements, sourceElementVisitor, isStatement, statementOffset)); // Append the 'export =' statement if provided. @@ -623,7 +638,8 @@ namespace ts { } } - return createNew(createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); + context.requestEmitHelper(importStarHelper); + return createCall(createPropertyAccess(createNew(createIdentifier("Promise"), /*typeArguments*/ undefined, [func]), createIdentifier("then")), /*typeArguments*/ undefined, [getHelperName("__importStar")]); } function createImportCallExpressionCommonJS(arg: Expression | undefined, containsLexicalThis: boolean): Expression { @@ -633,7 +649,7 @@ namespace ts { // We have to wrap require in then callback so that require is done in asynchronously // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately const promiseResolveCall = createCall(createPropertyAccess(createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []); - context.requestEmitHelper(commonjsImportStarHelper); + context.requestEmitHelper(importStarHelper); const requireCall = createCall(getHelperName("__importStar"), /*typeArguments*/ undefined, [createCall(createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : [])]); let func: FunctionExpression | ArrowFunction; @@ -668,19 +684,19 @@ namespace ts { } - function getCommonjsImportExpressionForImport(node: ImportDeclaration) { + function getHelperExpressionForImport(node: ImportDeclaration, innerExpr: Expression) { if (node.transformFlags & TransformFlags.NeverApplyImportHelper) { - return createRequireCall(node); + return innerExpr; } if (getNamespaceDeclarationNode(node)) { - context.requestEmitHelper(commonjsImportStarHelper); - return createCall(getHelperName("__importStar"), /*typeArguments*/ undefined, [createRequireCall(node)]); + context.requestEmitHelper(importStarHelper); + return createCall(getHelperName("__importStar"), /*typeArguments*/ undefined, [innerExpr]); } if (isDefaultImport(node)) { - context.requestEmitHelper(commonjsImportDefaultHelper); - return createCall(getHelperName("__importDefault"), /*typeArguments*/ undefined, [createRequireCall(node)]); + context.requestEmitHelper(importDefaultHelper); + return createCall(getHelperName("__importDefault"), /*typeArguments*/ undefined, [innerExpr]); } - return createRequireCall(node); + return innerExpr; } /** @@ -704,7 +720,7 @@ namespace ts { createVariableDeclaration( getSynthesizedClone(namespaceDeclaration.name), /*type*/ undefined, - getCommonjsImportExpressionForImport(node) + getHelperExpressionForImport(node, createRequireCall(node)) ) ); } @@ -717,7 +733,7 @@ namespace ts { createVariableDeclaration( getGeneratedNameForNode(node), /*type*/ undefined, - getCommonjsImportExpressionForImport(node) + getHelperExpressionForImport(node, createRequireCall(node)) ) ); @@ -1695,12 +1711,12 @@ namespace ts { var __syncRequire = typeof module === "object" && typeof module.exports === "object";` }; - // emit helper for import star - const commonjsImportStarHelper: EmitHelper = { + // emit helper for `import * as Name from "foo"` + const importStarHelper: EmitHelper = { name: "typescript:commonjsimportstar", scoped: false, text: ` -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -1709,11 +1725,12 @@ function __importStar(mod) { }` }; - const commonjsImportDefaultHelper: EmitHelper = { + // emit helper for `import Name from "foo"` + const importDefaultHelper: EmitHelper = { name: "typescript:commonjsimportdefault", scoped: false, text: ` -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }` }; diff --git a/tests/baselines/reference/APISample_jsdoc.js b/tests/baselines/reference/APISample_jsdoc.js index 5f80ff6c98520..87adffc6f3566 100644 --- a/tests/baselines/reference/APISample_jsdoc.js +++ b/tests/baselines/reference/APISample_jsdoc.js @@ -121,7 +121,7 @@ function getSomeOtherTags(node: ts.Node) { * https://github.com/vega/ts-json-schema-generator * Please log a "breaking change" issue for any API breaking change affecting this issue */ -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index bb371bb350665..5aeea38f94636 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -70,7 +70,7 @@ fileNames.forEach(fileName => { at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter * Please log a "breaking change" issue for any API breaking change affecting this issue */ -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index d0333fbe76c15..3cdb106e3926a 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -22,7 +22,7 @@ console.log(JSON.stringify(result)); at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function * Please log a "breaking change" issue for any API breaking change affecting this issue */ -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 1f5b1f60fb801..7ac527aadaffe 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -116,7 +116,7 @@ watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }); at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#incremental-build-support-using-the-language-services * Please log a "breaking change" issue for any API breaking change affecting this issue */ -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/allowImportClausesToMergeWithTypes.js b/tests/baselines/reference/allowImportClausesToMergeWithTypes.js index 226c8b606d499..16c5490e1496d 100644 --- a/tests/baselines/reference/allowImportClausesToMergeWithTypes.js +++ b/tests/baselines/reference/allowImportClausesToMergeWithTypes.js @@ -34,7 +34,7 @@ exports.zzz = 123; exports["default"] = exports.zzz; //// [a.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; @@ -44,7 +44,7 @@ var x = { x: "" }; b_1["default"]; //// [index.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/allowSyntheticDefaultImports1.js b/tests/baselines/reference/allowSyntheticDefaultImports1.js index d639f5c63190e..3a4bce821b343 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports1.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports1.js @@ -21,7 +21,7 @@ var Foo = /** @class */ (function () { exports.Foo = Foo; //// [a.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/allowSyntheticDefaultImports4.js b/tests/baselines/reference/allowSyntheticDefaultImports4.js index a6903832b0c0c..8d35851c3607e 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports4.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports4.js @@ -13,7 +13,7 @@ export var x = new Foo(); //// [a.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/ambientDeclarationsPatterns.js b/tests/baselines/reference/ambientDeclarationsPatterns.js index e03dfe3dbb2be..9f2419e196656 100644 --- a/tests/baselines/reference/ambientDeclarationsPatterns.js +++ b/tests/baselines/reference/ambientDeclarationsPatterns.js @@ -34,7 +34,7 @@ foo(fileText); //// [user.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/ambientShorthand.js b/tests/baselines/reference/ambientShorthand.js index 071655638b746..88e9e1339b627 100644 --- a/tests/baselines/reference/ambientShorthand.js +++ b/tests/baselines/reference/ambientShorthand.js @@ -15,10 +15,10 @@ foo(bar, baz, boom); //// [user.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/ambientShorthand_reExport.js b/tests/baselines/reference/ambientShorthand_reExport.js index 3337af5d8e007..8f58967cf97c9 100644 --- a/tests/baselines/reference/ambientShorthand_reExport.js +++ b/tests/baselines/reference/ambientShorthand_reExport.js @@ -30,7 +30,7 @@ exports.__esModule = true; __export(require("jquery")); //// [reExportUser.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/amdDependencyCommentName4.js b/tests/baselines/reference/amdDependencyCommentName4.js index 6542aa14fa299..77f0d40f0f744 100644 --- a/tests/baselines/reference/amdDependencyCommentName4.js +++ b/tests/baselines/reference/amdDependencyCommentName4.js @@ -25,9 +25,21 @@ import "unaliasedModule2"; /// /// /// +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "aliasedModule5", "aliasedModule6", "aliasedModule1", "aliasedModule2", "aliasedModule3", "aliasedModule4", "unaliasedModule3", "unaliasedModule4", "unaliasedModule1", "unaliasedModule2"], function (require, exports, n1, n2, r1, aliasedModule2_1, aliasedModule3_1, ns) { "use strict"; exports.__esModule = true; + aliasedModule3_1 = __importDefault(aliasedModule3_1); + ns = __importStar(ns); r1; aliasedModule2_1.p1; aliasedModule3_1["default"]; diff --git a/tests/baselines/reference/asyncImportNestedYield.js b/tests/baselines/reference/asyncImportNestedYield.js index d9be2db1c88b9..f5f932aa42bc5 100644 --- a/tests/baselines/reference/asyncImportNestedYield.js +++ b/tests/baselines/reference/asyncImportNestedYield.js @@ -43,7 +43,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/augmentExportEquals3.js b/tests/baselines/reference/augmentExportEquals3.js index 3ff5f574488e4..35ac0e08929d9 100644 --- a/tests/baselines/reference/augmentExportEquals3.js +++ b/tests/baselines/reference/augmentExportEquals3.js @@ -39,9 +39,17 @@ define(["require", "exports", "./file1"], function (require, exports, x) { x.b = 1; }); //// [file3.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "./file1", "./file2"], function (require, exports, x) { "use strict"; exports.__esModule = true; + x = __importStar(x); var a; var b = x.b; }); diff --git a/tests/baselines/reference/augmentExportEquals3_1.js b/tests/baselines/reference/augmentExportEquals3_1.js index e91ca4498dd86..3856d3bea077c 100644 --- a/tests/baselines/reference/augmentExportEquals3_1.js +++ b/tests/baselines/reference/augmentExportEquals3_1.js @@ -34,9 +34,17 @@ define(["require", "exports", "file1"], function (require, exports, x) { x.b = 1; }); //// [file3.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "file1", "file2"], function (require, exports, x) { "use strict"; exports.__esModule = true; + x = __importStar(x); var a; var b = x.b; }); diff --git a/tests/baselines/reference/augmentExportEquals4.js b/tests/baselines/reference/augmentExportEquals4.js index be6c6859ba76e..293bcd1077788 100644 --- a/tests/baselines/reference/augmentExportEquals4.js +++ b/tests/baselines/reference/augmentExportEquals4.js @@ -43,9 +43,17 @@ define(["require", "exports", "./file1"], function (require, exports, x) { x.b = 1; }); //// [file3.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "./file1", "./file2"], function (require, exports, x) { "use strict"; exports.__esModule = true; + x = __importStar(x); var a; var b = x.b; }); diff --git a/tests/baselines/reference/augmentExportEquals4_1.js b/tests/baselines/reference/augmentExportEquals4_1.js index cd2f54599699e..97d17acf67a70 100644 --- a/tests/baselines/reference/augmentExportEquals4_1.js +++ b/tests/baselines/reference/augmentExportEquals4_1.js @@ -34,9 +34,17 @@ define(["require", "exports", "file1"], function (require, exports, x) { x.b = 1; }); //// [file3.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "file1", "file2"], function (require, exports, x) { "use strict"; exports.__esModule = true; + x = __importStar(x); var a; var b = x.b; }); diff --git a/tests/baselines/reference/augmentExportEquals6.js b/tests/baselines/reference/augmentExportEquals6.js index 99c6c1602bd76..86f302e1551f3 100644 --- a/tests/baselines/reference/augmentExportEquals6.js +++ b/tests/baselines/reference/augmentExportEquals6.js @@ -55,9 +55,17 @@ define(["require", "exports", "./file1"], function (require, exports, x) { x.B.b = 1; }); //// [file3.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "./file1", "./file2"], function (require, exports, x) { "use strict"; exports.__esModule = true; + x = __importStar(x); var a; var b = a.a; var c = x.B.b; diff --git a/tests/baselines/reference/declarationEmitTypeofDefaultExport.js b/tests/baselines/reference/declarationEmitTypeofDefaultExport.js index b00ba90aef436..cbc122907aad3 100644 --- a/tests/baselines/reference/declarationEmitTypeofDefaultExport.js +++ b/tests/baselines/reference/declarationEmitTypeofDefaultExport.js @@ -20,7 +20,7 @@ exports["default"] = C; ; //// [b.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/decoratorMetadata.js b/tests/baselines/reference/decoratorMetadata.js index 6929d11b8a4be..739ec70ec9e70 100644 --- a/tests/baselines/reference/decoratorMetadata.js +++ b/tests/baselines/reference/decoratorMetadata.js @@ -38,7 +38,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/defaultExportInAwaitExpression01.js b/tests/baselines/reference/defaultExportInAwaitExpression01.js index 26b2cd6abf857..557350c63ad04 100644 --- a/tests/baselines/reference/defaultExportInAwaitExpression01.js +++ b/tests/baselines/reference/defaultExportInAwaitExpression01.js @@ -36,7 +36,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } (function (factory) { diff --git a/tests/baselines/reference/defaultExportInAwaitExpression02.js b/tests/baselines/reference/defaultExportInAwaitExpression02.js index b777f84ec40a8..16c3d7eb0c889 100644 --- a/tests/baselines/reference/defaultExportInAwaitExpression02.js +++ b/tests/baselines/reference/defaultExportInAwaitExpression02.js @@ -27,7 +27,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/defaultExportsCannotMerge01.js b/tests/baselines/reference/defaultExportsCannotMerge01.js index 47fba6627d24b..32cd2eaec8258 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge01.js +++ b/tests/baselines/reference/defaultExportsCannotMerge01.js @@ -42,7 +42,7 @@ exports.default = Decl; })(Decl = exports.Decl || (exports.Decl = {})); //// [m2.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/defaultExportsCannotMerge02.js b/tests/baselines/reference/defaultExportsCannotMerge02.js index bcf5cb9dabc23..daa3b0fec2cdb 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge02.js +++ b/tests/baselines/reference/defaultExportsCannotMerge02.js @@ -35,7 +35,7 @@ var Decl = /** @class */ (function () { exports.default = Decl; //// [m2.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/defaultExportsCannotMerge03.js b/tests/baselines/reference/defaultExportsCannotMerge03.js index 3a627b38e8376..0cbe2b5b6e438 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge03.js +++ b/tests/baselines/reference/defaultExportsCannotMerge03.js @@ -35,7 +35,7 @@ var Decl = /** @class */ (function () { exports.default = Decl; //// [m2.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/duplicatePackage_referenceTypes.js b/tests/baselines/reference/duplicatePackage_referenceTypes.js index 9bc7919c7bb62..2b69262cab5fd 100644 --- a/tests/baselines/reference/duplicatePackage_referenceTypes.js +++ b/tests/baselines/reference/duplicatePackage_referenceTypes.js @@ -26,7 +26,7 @@ let foo: Foo = a.foo; //// [index.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/duplicatePackage_subModule.js b/tests/baselines/reference/duplicatePackage_subModule.js index e2c0c8d134089..7ec3d7fe5e3aa 100644 --- a/tests/baselines/reference/duplicatePackage_subModule.js +++ b/tests/baselines/reference/duplicatePackage_subModule.js @@ -29,7 +29,7 @@ const o: Foo = a.o; //// [index.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/dynamicImportInDefaultExportExpression.js b/tests/baselines/reference/dynamicImportInDefaultExportExpression.js index f1752e777e378..de5bd27c4741c 100644 --- a/tests/baselines/reference/dynamicImportInDefaultExportExpression.js +++ b/tests/baselines/reference/dynamicImportInDefaultExportExpression.js @@ -7,7 +7,7 @@ export default { //// [dynamicImportInDefaultExportExpression.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/dynamicImportWithNestedThis_es2015.js b/tests/baselines/reference/dynamicImportWithNestedThis_es2015.js index 0deaa048fb05d..afe7d78e172f4 100644 --- a/tests/baselines/reference/dynamicImportWithNestedThis_es2015.js +++ b/tests/baselines/reference/dynamicImportWithNestedThis_es2015.js @@ -12,7 +12,7 @@ const c = new C(); c.dynamic(); //// [dynamicImportWithNestedThis_es2015.js] -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -36,7 +36,7 @@ function __importStar(mod) { this._path = './other'; } dynamic() { - return _a = this._path, __syncRequire ? Promise.resolve().then(() => __importStar(require(_a))) : new Promise((resolve_1, reject_1) => { require([_a], resolve_1, reject_1); }); + return _a = this._path, __syncRequire ? Promise.resolve().then(() => __importStar(require(_a))) : new Promise((resolve_1, reject_1) => { require([_a], resolve_1, reject_1); }).then(__importStar); var _a; } } diff --git a/tests/baselines/reference/dynamicImportWithNestedThis_es5.js b/tests/baselines/reference/dynamicImportWithNestedThis_es5.js index c6f56a3983c5b..e0a5415bff2ed 100644 --- a/tests/baselines/reference/dynamicImportWithNestedThis_es5.js +++ b/tests/baselines/reference/dynamicImportWithNestedThis_es5.js @@ -12,7 +12,7 @@ const c = new C(); c.dynamic(); //// [dynamicImportWithNestedThis_es5.js] -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -37,7 +37,7 @@ function __importStar(mod) { } C.prototype.dynamic = function () { var _this = this; - return _a = this._path, __syncRequire ? Promise.resolve().then(function () { return __importStar(require(_a)); }) : new Promise(function (resolve_1, reject_1) { require([_a], resolve_1, reject_1); }); + return _a = this._path, __syncRequire ? Promise.resolve().then(function () { return __importStar(require(_a)); }) : new Promise(function (resolve_1, reject_1) { require([_a], resolve_1, reject_1); }).then(__importStar); var _a; }; return C; diff --git a/tests/baselines/reference/emptyModuleName.js b/tests/baselines/reference/emptyModuleName.js index 37bc645a01c46..1fbcd962354ac 100644 --- a/tests/baselines/reference/emptyModuleName.js +++ b/tests/baselines/reference/emptyModuleName.js @@ -15,7 +15,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/es6ExportEqualsInterop.js b/tests/baselines/reference/es6ExportEqualsInterop.js index 9ebb28988e493..224c631c9b3c3 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.js +++ b/tests/baselines/reference/es6ExportEqualsInterop.js @@ -212,7 +212,7 @@ export * from "class-module"; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/es6ImportDefaultBindingAmd.js b/tests/baselines/reference/es6ImportDefaultBindingAmd.js index d8a13efa2d6ab..dda8e9faeaf71 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingAmd.js +++ b/tests/baselines/reference/es6ImportDefaultBindingAmd.js @@ -18,9 +18,13 @@ define(["require", "exports"], function (require, exports) { exports.default = a; }); //// [es6ImportDefaultBindingAmd_1.js] +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} define(["require", "exports", "es6ImportDefaultBindingAmd_0"], function (require, exports, es6ImportDefaultBindingAmd_0_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); + es6ImportDefaultBindingAmd_0_1 = __importDefault(es6ImportDefaultBindingAmd_0_1); var x = es6ImportDefaultBindingAmd_0_1.default; }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingDts.js index 06b7a32434e77..734033042e2da 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.js @@ -21,7 +21,7 @@ var c = /** @class */ (function () { exports.default = c; //// [client.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js index 51aeb42c0f3bc..bcf7fcbb6c1c5 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js @@ -26,7 +26,7 @@ var a = 10; exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js index a8153a8f40147..a500ced22a65f 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js @@ -26,7 +26,7 @@ var a = 10; exports.default = a; //// [client.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js index eb4050a94de57..9c708def8ecf2 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js @@ -29,7 +29,7 @@ var a = /** @class */ (function () { exports.default = a; //// [client.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js index 287e65cffde22..8edd09287eb62 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js @@ -15,7 +15,7 @@ var a = 10; exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js index 2e5ce8ebc0bf4..13e839e7195a4 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js @@ -16,9 +16,13 @@ define(["require", "exports"], function (require, exports) { exports.default = a; }); //// [client.js] +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} define(["require", "exports", "server"], function (require, exports, server_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); + server_1 = __importDefault(server_1); exports.x = server_1.default; }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js index 73c663bc453d1..de4e3e4215188 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js @@ -18,7 +18,7 @@ var a = /** @class */ (function () { exports.a = a; //// [client.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js index 240e9a483cba4..cfc0a5aa4e688 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js @@ -20,9 +20,13 @@ define(["require", "exports"], function (require, exports) { exports.default = a; }); //// [client.js] +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} define(["require", "exports", "server"], function (require, exports, server_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); + server_1 = __importDefault(server_1); exports.x = new server_1.default(); }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js index 8222772e34b78..16dbd8837daf9 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js @@ -13,7 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js index 7ddcfb2e25bbd..981f1c8a68bb6 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js @@ -13,7 +13,7 @@ exports.__esModule = true; exports.a = 10; //// [client.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js index a0e16ecf9a436..bd07295b2e2c5 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js +++ b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js @@ -22,7 +22,7 @@ var a = 10; exports.default = a; //// [es6ImportDefaultBindingMergeErrors_1.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingWithExport.js index 38b391ac6d315..316b9ae60c595 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingWithExport.js @@ -17,9 +17,13 @@ define(["require", "exports"], function (require, exports) { exports.default = a; }); //// [client.js] +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} define(["require", "exports", "server"], function (require, exports, server_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); + server_1 = __importDefault(server_1); exports.x = server_1.default; }); diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.js b/tests/baselines/reference/es6ImportNameSpaceImport.js index dd960f87275f4..a852e65507dd9 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImport.js +++ b/tests/baselines/reference/es6ImportNameSpaceImport.js @@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; //// [es6ImportNameSpaceImport_1.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportAmd.js b/tests/baselines/reference/es6ImportNameSpaceImportAmd.js index 44a0635f7a2db..7904466bebcd6 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportAmd.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportAmd.js @@ -16,9 +16,17 @@ define(["require", "exports"], function (require, exports) { exports.a = 10; }); //// [es6ImportNameSpaceImportAmd_1.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "es6ImportNameSpaceImportAmd_0"], function (require, exports, nameSpaceBinding) { "use strict"; exports.__esModule = true; + nameSpaceBinding = __importStar(nameSpaceBinding); var x = nameSpaceBinding.a; }); diff --git a/tests/baselines/reference/es6ImportNameSpaceImportDts.js b/tests/baselines/reference/es6ImportNameSpaceImportDts.js index 16cb65242d399..ffe87da9a4a1a 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportDts.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportDts.js @@ -20,7 +20,7 @@ exports.c = c; ; //// [client.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js index b1f968a01f565..43d276562f2e0 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js @@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; //// [es6ImportNameSpaceImportInEs5_1.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportWithExport.js b/tests/baselines/reference/es6ImportNameSpaceImportWithExport.js index 57aa0cf0c05c3..be5d391d8b70e 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportWithExport.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportWithExport.js @@ -16,9 +16,17 @@ define(["require", "exports"], function (require, exports) { exports.a = 10; }); //// [client.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "server"], function (require, exports, nameSpaceBinding) { "use strict"; exports.__esModule = true; + nameSpaceBinding = __importStar(nameSpaceBinding); exports.x = nameSpaceBinding.a; }); diff --git a/tests/baselines/reference/exportAndImport-es3-amd.js b/tests/baselines/reference/exportAndImport-es3-amd.js index ff341f922b5f2..2d54be2853513 100644 --- a/tests/baselines/reference/exportAndImport-es3-amd.js +++ b/tests/baselines/reference/exportAndImport-es3-amd.js @@ -20,9 +20,13 @@ define(["require", "exports"], function (require, exports) { exports["default"] = f1; }); //// [m2.js] +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} define(["require", "exports", "./m1"], function (require, exports, m1_1) { "use strict"; exports.__esModule = true; + m1_1 = __importDefault(m1_1); function f2() { m1_1["default"](); } diff --git a/tests/baselines/reference/exportAndImport-es3.js b/tests/baselines/reference/exportAndImport-es3.js index bd4675d93fc82..3d2ccd549735b 100644 --- a/tests/baselines/reference/exportAndImport-es3.js +++ b/tests/baselines/reference/exportAndImport-es3.js @@ -19,7 +19,7 @@ function f1() { exports["default"] = f1; //// [m2.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/exportAndImport-es5-amd.js b/tests/baselines/reference/exportAndImport-es5-amd.js index d471d76da51a6..b7920b4f83981 100644 --- a/tests/baselines/reference/exportAndImport-es5-amd.js +++ b/tests/baselines/reference/exportAndImport-es5-amd.js @@ -20,9 +20,13 @@ define(["require", "exports"], function (require, exports) { exports.default = f1; }); //// [m2.js] +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} define(["require", "exports", "./m1"], function (require, exports, m1_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); + m1_1 = __importDefault(m1_1); function f2() { m1_1.default(); } diff --git a/tests/baselines/reference/exportAndImport-es5.js b/tests/baselines/reference/exportAndImport-es5.js index 1763fdf0a397c..8f2a6b4f93447 100644 --- a/tests/baselines/reference/exportAndImport-es5.js +++ b/tests/baselines/reference/exportAndImport-es5.js @@ -19,7 +19,7 @@ function f1() { exports.default = f1; //// [m2.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/exportDefaultAbstractClass.js b/tests/baselines/reference/exportDefaultAbstractClass.js index 5b2dde6c06def..5972c1e35d974 100644 --- a/tests/baselines/reference/exportDefaultAbstractClass.js +++ b/tests/baselines/reference/exportDefaultAbstractClass.js @@ -51,7 +51,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/exportDefaultProperty.js b/tests/baselines/reference/exportDefaultProperty.js index 75e16fb9e4f88..d49ca5efa87a1 100644 --- a/tests/baselines/reference/exportDefaultProperty.js +++ b/tests/baselines/reference/exportDefaultProperty.js @@ -63,7 +63,7 @@ exports.__esModule = true; exports["default"] = "foo".length; //// [index.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/exportDefaultProperty2.js b/tests/baselines/reference/exportDefaultProperty2.js index 5c7f95f08d972..32e33922222f1 100644 --- a/tests/baselines/reference/exportDefaultProperty2.js +++ b/tests/baselines/reference/exportDefaultProperty2.js @@ -29,7 +29,7 @@ var C = /** @class */ (function () { exports["default"] = C.B; //// [b.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/exportEqualsDefaultProperty.js b/tests/baselines/reference/exportEqualsDefaultProperty.js index 013f0b059d9df..ce4f745354fcf 100644 --- a/tests/baselines/reference/exportEqualsDefaultProperty.js +++ b/tests/baselines/reference/exportEqualsDefaultProperty.js @@ -22,7 +22,7 @@ var x = { module.exports = x; //// [imp.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/exportStar-amd.js b/tests/baselines/reference/exportStar-amd.js index 7658c470e5574..09ada4ba71f99 100644 --- a/tests/baselines/reference/exportStar-amd.js +++ b/tests/baselines/reference/exportStar-amd.js @@ -66,9 +66,13 @@ define(["require", "exports", "./t1", "./t2", "./t3"], function (require, export __export(t3_1); }); //// [main.js] +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} define(["require", "exports", "./t4"], function (require, exports, t4_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); + t4_1 = __importDefault(t4_1); t4_1.default; t4_1.x; t4_1.y; diff --git a/tests/baselines/reference/exportStar.js b/tests/baselines/reference/exportStar.js index 2b357f8a997f2..41ca38b5b671b 100644 --- a/tests/baselines/reference/exportStar.js +++ b/tests/baselines/reference/exportStar.js @@ -59,7 +59,7 @@ __export(require("./t2")); __export(require("./t3")); //// [main.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/exportStarFromEmptyModule.js b/tests/baselines/reference/exportStarFromEmptyModule.js index c4434f780b8b2..8e56d5eadc08a 100644 --- a/tests/baselines/reference/exportStarFromEmptyModule.js +++ b/tests/baselines/reference/exportStarFromEmptyModule.js @@ -49,7 +49,7 @@ var A = /** @class */ (function () { exports.A = A; //// [exportStarFromEmptyModule_module4.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/exportsAndImports4-amd.js b/tests/baselines/reference/exportsAndImports4-amd.js index 52a41a0a4512b..626fa152411ee 100644 --- a/tests/baselines/reference/exportsAndImports4-amd.js +++ b/tests/baselines/reference/exportsAndImports4-amd.js @@ -45,9 +45,23 @@ define(["require", "exports"], function (require, exports) { exports.default = "hello"; }); //// [t3.js] +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "./t1", "./t1", "./t1", "./t1", "./t1", "./t1"], function (require, exports, a, t1_1, c, t1_2, t1_3, t1_4) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); + t1_1 = __importDefault(t1_1); + c = __importStar(c); + t1_3 = __importStar(t1_3); + t1_4 = __importDefault(t1_4); exports.a = a; a.default; exports.b = t1_1.default; diff --git a/tests/baselines/reference/exportsAndImports4-es6.js b/tests/baselines/reference/exportsAndImports4-es6.js index 1de9968869ede..5b9f990397128 100644 --- a/tests/baselines/reference/exportsAndImports4-es6.js +++ b/tests/baselines/reference/exportsAndImports4-es6.js @@ -44,10 +44,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = "hello"; //// [t3.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/exportsAndImports4.js b/tests/baselines/reference/exportsAndImports4.js index d63f7da9c0438..6a17cd920d1b7 100644 --- a/tests/baselines/reference/exportsAndImports4.js +++ b/tests/baselines/reference/exportsAndImports4.js @@ -44,10 +44,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = "hello"; //// [t3.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js index 4b9a0c49d422f..bf1a99503a24b 100644 --- a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js +++ b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js @@ -24,7 +24,7 @@ exports.return = as; exports.as = as; //// [t2.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/exportsAndImportsWithUnderscores1.js b/tests/baselines/reference/exportsAndImportsWithUnderscores1.js index 6312c6e868bb1..d8bc66ee0718e 100644 --- a/tests/baselines/reference/exportsAndImportsWithUnderscores1.js +++ b/tests/baselines/reference/exportsAndImportsWithUnderscores1.js @@ -24,7 +24,7 @@ exports["default"] = R = { }; //// [m2.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/exportsAndImportsWithUnderscores2.js b/tests/baselines/reference/exportsAndImportsWithUnderscores2.js index 1c9821cbf6589..212d4f015780b 100644 --- a/tests/baselines/reference/exportsAndImportsWithUnderscores2.js +++ b/tests/baselines/reference/exportsAndImportsWithUnderscores2.js @@ -22,7 +22,7 @@ exports["default"] = R = { }; //// [m2.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/exportsAndImportsWithUnderscores3.js b/tests/baselines/reference/exportsAndImportsWithUnderscores3.js index 249e715afd47e..8004e17246cd7 100644 --- a/tests/baselines/reference/exportsAndImportsWithUnderscores3.js +++ b/tests/baselines/reference/exportsAndImportsWithUnderscores3.js @@ -24,7 +24,7 @@ exports["default"] = R = { }; //// [m2.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/extendsUntypedModule.js b/tests/baselines/reference/extendsUntypedModule.js index 404048ab70596..8f246cd524708 100644 --- a/tests/baselines/reference/extendsUntypedModule.js +++ b/tests/baselines/reference/extendsUntypedModule.js @@ -26,7 +26,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/externalModuleImmutableBindings.js b/tests/baselines/reference/externalModuleImmutableBindings.js index a1588372b7229..4547e37c3c009 100644 --- a/tests/baselines/reference/externalModuleImmutableBindings.js +++ b/tests/baselines/reference/externalModuleImmutableBindings.js @@ -56,7 +56,7 @@ exports.__esModule = true; exports.x = 1; //// [f2.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionAsyncES3AMD.js b/tests/baselines/reference/importCallExpressionAsyncES3AMD.js index 90465c0e6e483..6a9968279d66b 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES3AMD.js +++ b/tests/baselines/reference/importCallExpressionAsyncES3AMD.js @@ -64,6 +64,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports"], function (require, exports) { "use strict"; var _this = this; @@ -73,7 +80,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); })]; // ONE + case 0: return [4 /*yield*/, new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); }).then(__importStar)]; // ONE case 1: req = _a.sent() // ONE ; @@ -91,7 +98,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); })]; // TWO + case 0: return [4 /*yield*/, new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); }).then(__importStar)]; // TWO case 1: req = _a.sent() // TWO ; @@ -108,7 +115,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); })]; // THREE + case 0: return [4 /*yield*/, new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); }).then(__importStar)]; // THREE case 1: req = _a.sent() // THREE ; @@ -125,7 +132,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); })]; // FOUR + case 0: return [4 /*yield*/, new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); }).then(__importStar)]; // FOUR case 1: req = _a.sent() // FOUR ; @@ -142,7 +149,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); })]; // FIVE + case 0: return [4 /*yield*/, new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); }).then(__importStar)]; // FIVE case 1: req = _a.sent() // FIVE ; diff --git a/tests/baselines/reference/importCallExpressionAsyncES3CJS.js b/tests/baselines/reference/importCallExpressionAsyncES3CJS.js index f40edc796e917..ece5a1f2f54f7 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES3CJS.js +++ b/tests/baselines/reference/importCallExpressionAsyncES3CJS.js @@ -65,7 +65,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionAsyncES3UMD.js b/tests/baselines/reference/importCallExpressionAsyncES3UMD.js index 4f60f1e1b73a6..dfa16f9c4e206 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES3UMD.js +++ b/tests/baselines/reference/importCallExpressionAsyncES3UMD.js @@ -64,7 +64,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -89,7 +89,7 @@ function __importStar(mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); })]; // ONE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); }).then(__importStar)]; // ONE case 1: req = _a.sent() // ONE ; @@ -107,7 +107,7 @@ function __importStar(mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); })]; // TWO + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); }).then(__importStar)]; // TWO case 1: req = _a.sent() // TWO ; @@ -124,7 +124,7 @@ function __importStar(mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); })]; // THREE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); }).then(__importStar)]; // THREE case 1: req = _a.sent() // THREE ; @@ -141,7 +141,7 @@ function __importStar(mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); })]; // FOUR + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); }).then(__importStar)]; // FOUR case 1: req = _a.sent() // FOUR ; @@ -158,7 +158,7 @@ function __importStar(mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); })]; // FIVE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); }).then(__importStar)]; // FIVE case 1: req = _a.sent() // FIVE ; diff --git a/tests/baselines/reference/importCallExpressionAsyncES5AMD.js b/tests/baselines/reference/importCallExpressionAsyncES5AMD.js index 3bad6ffa1f551..188e21dfd6c79 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES5AMD.js +++ b/tests/baselines/reference/importCallExpressionAsyncES5AMD.js @@ -64,6 +64,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports"], function (require, exports) { "use strict"; var _this = this; @@ -73,7 +80,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); })]; // ONE + case 0: return [4 /*yield*/, new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); }).then(__importStar)]; // ONE case 1: req = _a.sent() // ONE ; @@ -91,7 +98,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); })]; // TWO + case 0: return [4 /*yield*/, new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); }).then(__importStar)]; // TWO case 1: req = _a.sent() // TWO ; @@ -108,7 +115,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); })]; // THREE + case 0: return [4 /*yield*/, new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); }).then(__importStar)]; // THREE case 1: req = _a.sent() // THREE ; @@ -125,7 +132,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); })]; // FOUR + case 0: return [4 /*yield*/, new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); }).then(__importStar)]; // FOUR case 1: req = _a.sent() // FOUR ; @@ -142,7 +149,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); })]; // FIVE + case 0: return [4 /*yield*/, new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); }).then(__importStar)]; // FIVE case 1: req = _a.sent() // FIVE ; diff --git a/tests/baselines/reference/importCallExpressionAsyncES5CJS.js b/tests/baselines/reference/importCallExpressionAsyncES5CJS.js index 8e9bfb0363334..5790620917e38 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES5CJS.js +++ b/tests/baselines/reference/importCallExpressionAsyncES5CJS.js @@ -65,7 +65,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionAsyncES5UMD.js b/tests/baselines/reference/importCallExpressionAsyncES5UMD.js index 202c74a81eda4..747a7e6d2f072 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES5UMD.js +++ b/tests/baselines/reference/importCallExpressionAsyncES5UMD.js @@ -64,7 +64,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -89,7 +89,7 @@ function __importStar(mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); })]; // ONE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); }).then(__importStar)]; // ONE case 1: req = _a.sent() // ONE ; @@ -107,7 +107,7 @@ function __importStar(mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); })]; // TWO + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); }).then(__importStar)]; // TWO case 1: req = _a.sent() // TWO ; @@ -124,7 +124,7 @@ function __importStar(mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); })]; // THREE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); }).then(__importStar)]; // THREE case 1: req = _a.sent() // THREE ; @@ -141,7 +141,7 @@ function __importStar(mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); })]; // FOUR + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); }).then(__importStar)]; // FOUR case 1: req = _a.sent() // FOUR ; @@ -158,7 +158,7 @@ function __importStar(mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); })]; // FIVE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); }).then(__importStar)]; // FIVE case 1: req = _a.sent() // FIVE ; diff --git a/tests/baselines/reference/importCallExpressionAsyncES6AMD.js b/tests/baselines/reference/importCallExpressionAsyncES6AMD.js index 7f86625bbfc67..62bc16549c1af 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES6AMD.js +++ b/tests/baselines/reference/importCallExpressionAsyncES6AMD.js @@ -37,39 +37,46 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function fn() { return __awaiter(this, void 0, void 0, function* () { - const req = yield new Promise((resolve_1, reject_1) => { require(['./test'], resolve_1, reject_1); }); // ONE + const req = yield new Promise((resolve_1, reject_1) => { require(['./test'], resolve_1, reject_1); }).then(__importStar); // ONE }); } exports.fn = fn; class cl1 { m() { return __awaiter(this, void 0, void 0, function* () { - const req = yield new Promise((resolve_2, reject_2) => { require(['./test'], resolve_2, reject_2); }); // TWO + const req = yield new Promise((resolve_2, reject_2) => { require(['./test'], resolve_2, reject_2); }).then(__importStar); // TWO }); } } exports.cl1 = cl1; exports.obj = { m: () => __awaiter(this, void 0, void 0, function* () { - const req = yield new Promise((resolve_3, reject_3) => { require(['./test'], resolve_3, reject_3); }); // THREE + const req = yield new Promise((resolve_3, reject_3) => { require(['./test'], resolve_3, reject_3); }).then(__importStar); // THREE }) }; class cl2 { constructor() { this.p = { m: () => __awaiter(this, void 0, void 0, function* () { - const req = yield new Promise((resolve_4, reject_4) => { require(['./test'], resolve_4, reject_4); }); // FOUR + const req = yield new Promise((resolve_4, reject_4) => { require(['./test'], resolve_4, reject_4); }).then(__importStar); // FOUR }) }; } } exports.cl2 = cl2; exports.l = () => __awaiter(this, void 0, void 0, function* () { - const req = yield new Promise((resolve_5, reject_5) => { require(['./test'], resolve_5, reject_5); }); // FIVE + const req = yield new Promise((resolve_5, reject_5) => { require(['./test'], resolve_5, reject_5); }).then(__importStar); // FIVE }); }); diff --git a/tests/baselines/reference/importCallExpressionAsyncES6CJS.js b/tests/baselines/reference/importCallExpressionAsyncES6CJS.js index 672fe1055962f..9464b8a483305 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES6CJS.js +++ b/tests/baselines/reference/importCallExpressionAsyncES6CJS.js @@ -38,7 +38,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionAsyncES6UMD.js b/tests/baselines/reference/importCallExpressionAsyncES6UMD.js index b0e543159bfb6..7c305b0709455 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES6UMD.js +++ b/tests/baselines/reference/importCallExpressionAsyncES6UMD.js @@ -37,7 +37,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -58,34 +58,34 @@ function __importStar(mod) { Object.defineProperty(exports, "__esModule", { value: true }); function fn() { return __awaiter(this, void 0, void 0, function* () { - const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_1, reject_1) => { require(['./test'], resolve_1, reject_1); }); // ONE + const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_1, reject_1) => { require(['./test'], resolve_1, reject_1); }).then(__importStar); // ONE }); } exports.fn = fn; class cl1 { m() { return __awaiter(this, void 0, void 0, function* () { - const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_2, reject_2) => { require(['./test'], resolve_2, reject_2); }); // TWO + const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_2, reject_2) => { require(['./test'], resolve_2, reject_2); }).then(__importStar); // TWO }); } } exports.cl1 = cl1; exports.obj = { m: () => __awaiter(this, void 0, void 0, function* () { - const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_3, reject_3) => { require(['./test'], resolve_3, reject_3); }); // THREE + const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_3, reject_3) => { require(['./test'], resolve_3, reject_3); }).then(__importStar); // THREE }) }; class cl2 { constructor() { this.p = { m: () => __awaiter(this, void 0, void 0, function* () { - const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_4, reject_4) => { require(['./test'], resolve_4, reject_4); }); // FOUR + const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_4, reject_4) => { require(['./test'], resolve_4, reject_4); }).then(__importStar); // FOUR }) }; } } exports.cl2 = cl2; exports.l = () => __awaiter(this, void 0, void 0, function* () { - const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_5, reject_5) => { require(['./test'], resolve_5, reject_5); }); // FIVE + const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_5, reject_5) => { require(['./test'], resolve_5, reject_5); }).then(__importStar); // FIVE }); }); diff --git a/tests/baselines/reference/importCallExpressionCheckReturntype1.js b/tests/baselines/reference/importCallExpressionCheckReturntype1.js index efe4b134e5ede..2c056ae9dc521 100644 --- a/tests/baselines/reference/importCallExpressionCheckReturntype1.js +++ b/tests/baselines/reference/importCallExpressionCheckReturntype1.js @@ -29,7 +29,7 @@ class C { exports.C = C; //// [1.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionDeclarationEmit1.js b/tests/baselines/reference/importCallExpressionDeclarationEmit1.js index 30104863134f9..978e2c7ed4124 100644 --- a/tests/baselines/reference/importCallExpressionDeclarationEmit1.js +++ b/tests/baselines/reference/importCallExpressionDeclarationEmit1.js @@ -15,7 +15,7 @@ function returnDynamicLoad(path: string) { } //// [importCallExpressionDeclarationEmit1.js] -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionES5AMD.js b/tests/baselines/reference/importCallExpressionES5AMD.js index eec2f378ac095..faf4bbd7c3597 100644 --- a/tests/baselines/reference/importCallExpressionES5AMD.js +++ b/tests/baselines/reference/importCallExpressionES5AMD.js @@ -36,23 +36,30 @@ define(["require", "exports"], function (require, exports) { exports.foo = foo; }); //// [1.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }); - var p1 = new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }); + new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }).then(__importStar); + var p1 = new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }).then(__importStar); p1.then(function (zero) { return zero.foo(); }); - exports.p2 = new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }); + exports.p2 = new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }).then(__importStar); function foo() { - var p2 = new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }); + var p2 = new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }).then(__importStar); } var C = /** @class */ (function () { function C() { } C.prototype.method = function () { - var loadAsync = new Promise(function (resolve_5, reject_5) { require(["./0"], resolve_5, reject_5); }); + var loadAsync = new Promise(function (resolve_5, reject_5) { require(["./0"], resolve_5, reject_5); }).then(__importStar); }; return C; }()); @@ -60,7 +67,7 @@ define(["require", "exports"], function (require, exports) { function D() { } D.prototype.method = function () { - var loadAsync = new Promise(function (resolve_6, reject_6) { require(["./0"], resolve_6, reject_6); }); + var loadAsync = new Promise(function (resolve_6, reject_6) { require(["./0"], resolve_6, reject_6); }).then(__importStar); }; return D; }()); diff --git a/tests/baselines/reference/importCallExpressionES5CJS.js b/tests/baselines/reference/importCallExpressionES5CJS.js index c63d8b002ed71..fd38badf5406f 100644 --- a/tests/baselines/reference/importCallExpressionES5CJS.js +++ b/tests/baselines/reference/importCallExpressionES5CJS.js @@ -35,7 +35,7 @@ function foo() { return "foo"; } exports.foo = foo; //// [1.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionES5UMD.js b/tests/baselines/reference/importCallExpressionES5UMD.js index fa2a4ca46617b..72e13639c912a 100644 --- a/tests/baselines/reference/importCallExpressionES5UMD.js +++ b/tests/baselines/reference/importCallExpressionES5UMD.js @@ -44,7 +44,7 @@ export class D { exports.foo = foo; }); //// [1.js] -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -63,20 +63,20 @@ function __importStar(mod) { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; Object.defineProperty(exports, "__esModule", { value: true }); - __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }); - var p1 = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }); + __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }).then(__importStar); + var p1 = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }).then(__importStar); p1.then(function (zero) { return zero.foo(); }); - exports.p2 = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }); + exports.p2 = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }).then(__importStar); function foo() { - var p2 = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }); + var p2 = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }).then(__importStar); } var C = /** @class */ (function () { function C() { } C.prototype.method = function () { - var loadAsync = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_5, reject_5) { require(["./0"], resolve_5, reject_5); }); + var loadAsync = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_5, reject_5) { require(["./0"], resolve_5, reject_5); }).then(__importStar); }; return C; }()); @@ -84,7 +84,7 @@ function __importStar(mod) { function D() { } D.prototype.method = function () { - var loadAsync = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_6, reject_6) { require(["./0"], resolve_6, reject_6); }); + var loadAsync = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_6, reject_6) { require(["./0"], resolve_6, reject_6); }).then(__importStar); }; return D; }()); diff --git a/tests/baselines/reference/importCallExpressionES6AMD.js b/tests/baselines/reference/importCallExpressionES6AMD.js index 1c5430c9f04b9..fdd95ca998605 100644 --- a/tests/baselines/reference/importCallExpressionES6AMD.js +++ b/tests/baselines/reference/importCallExpressionES6AMD.js @@ -36,26 +36,33 @@ define(["require", "exports"], function (require, exports) { exports.foo = foo; }); //// [1.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); - var p1 = new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); + new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar); + var p1 = new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }).then(__importStar); p1.then(zero => { return zero.foo(); }); - exports.p2 = new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }); + exports.p2 = new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }).then(__importStar); function foo() { - const p2 = new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); + const p2 = new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }).then(__importStar); } class C { method() { - const loadAsync = new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }); + const loadAsync = new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }).then(__importStar); } } class D { method() { - const loadAsync = new Promise((resolve_6, reject_6) => { require(["./0"], resolve_6, reject_6); }); + const loadAsync = new Promise((resolve_6, reject_6) => { require(["./0"], resolve_6, reject_6); }).then(__importStar); } } exports.D = D; diff --git a/tests/baselines/reference/importCallExpressionES6CJS.js b/tests/baselines/reference/importCallExpressionES6CJS.js index d106d9eb8d322..140e93a24ab17 100644 --- a/tests/baselines/reference/importCallExpressionES6CJS.js +++ b/tests/baselines/reference/importCallExpressionES6CJS.js @@ -35,7 +35,7 @@ function foo() { return "foo"; } exports.foo = foo; //// [1.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionES6UMD.js b/tests/baselines/reference/importCallExpressionES6UMD.js index c1618ddd62d97..ff31bd189c7ab 100644 --- a/tests/baselines/reference/importCallExpressionES6UMD.js +++ b/tests/baselines/reference/importCallExpressionES6UMD.js @@ -44,7 +44,7 @@ export class D { exports.foo = foo; }); //// [1.js] -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -63,23 +63,23 @@ function __importStar(mod) { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; Object.defineProperty(exports, "__esModule", { value: true }); - __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); - var p1 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); + __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar); + var p1 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }).then(__importStar); p1.then(zero => { return zero.foo(); }); - exports.p2 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }); + exports.p2 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }).then(__importStar); function foo() { - const p2 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); + const p2 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }).then(__importStar); } class C { method() { - const loadAsync = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }); + const loadAsync = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }).then(__importStar); } } class D { method() { - const loadAsync = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_6, reject_6) => { require(["./0"], resolve_6, reject_6); }); + const loadAsync = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_6, reject_6) => { require(["./0"], resolve_6, reject_6); }).then(__importStar); } } exports.D = D; diff --git a/tests/baselines/reference/importCallExpressionGrammarError.js b/tests/baselines/reference/importCallExpressionGrammarError.js index 559b67b479487..366b2b80ff1b7 100644 --- a/tests/baselines/reference/importCallExpressionGrammarError.js +++ b/tests/baselines/reference/importCallExpressionGrammarError.js @@ -11,7 +11,7 @@ const p3 = import(,); const p4 = import("pathToModule", "secondModule"); //// [importCallExpressionGrammarError.js] -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionInAMD1.js b/tests/baselines/reference/importCallExpressionInAMD1.js index 64e5aee2ddae5..26e84a57ccce8 100644 --- a/tests/baselines/reference/importCallExpressionInAMD1.js +++ b/tests/baselines/reference/importCallExpressionInAMD1.js @@ -24,16 +24,23 @@ define(["require", "exports"], function (require, exports) { exports.foo = foo; }); //// [1.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); - var p1 = new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); + new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar); + var p1 = new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }).then(__importStar); p1.then(zero => { return zero.foo(); }); - exports.p2 = new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }); + exports.p2 = new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }).then(__importStar); function foo() { - const p2 = new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); + const p2 = new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }).then(__importStar); } }); diff --git a/tests/baselines/reference/importCallExpressionInAMD2.js b/tests/baselines/reference/importCallExpressionInAMD2.js index 0d3f0e08d216e..19406c444b2a5 100644 --- a/tests/baselines/reference/importCallExpressionInAMD2.js +++ b/tests/baselines/reference/importCallExpressionInAMD2.js @@ -26,6 +26,13 @@ define(["require", "exports"], function (require, exports) { exports.B = B; }); //// [2.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports"], function (require, exports) { "use strict"; // We use Promise for now as there is no way to specify shape of module object @@ -35,5 +42,5 @@ define(["require", "exports"], function (require, exports) { b.print(); }); } - foo(new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); })); + foo(new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar)); }); diff --git a/tests/baselines/reference/importCallExpressionInAMD3.js b/tests/baselines/reference/importCallExpressionInAMD3.js index 07e7e92254189..537d68cd078e4 100644 --- a/tests/baselines/reference/importCallExpressionInAMD3.js +++ b/tests/baselines/reference/importCallExpressionInAMD3.js @@ -23,10 +23,17 @@ define(["require", "exports"], function (require, exports) { exports.B = B; }); //// [2.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports"], function (require, exports) { "use strict"; async function foo() { - class C extends (await new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); })).B { + class C extends (await new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar)).B { } var c = new C(); c.print(); diff --git a/tests/baselines/reference/importCallExpressionInAMD4.js b/tests/baselines/reference/importCallExpressionInAMD4.js index 2fe29e5ae065a..4a06bb82c8b54 100644 --- a/tests/baselines/reference/importCallExpressionInAMD4.js +++ b/tests/baselines/reference/importCallExpressionInAMD4.js @@ -59,35 +59,42 @@ define(["require", "exports"], function (require, exports) { exports.backup = backup; }); //// [2.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class C { constructor() { - this.myModule = new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); + this.myModule = new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar); } method() { - const loadAsync = new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); + const loadAsync = new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }).then(__importStar); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { console.log(err); - let one = await new Promise((resolve_3, reject_3) => { require(["./1"], resolve_3, reject_3); }); + let one = await new Promise((resolve_3, reject_3) => { require(["./1"], resolve_3, reject_3); }).then(__importStar); console.log(one.backup()); }); } } class D { constructor() { - this.myModule = new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); + this.myModule = new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }).then(__importStar); } method() { - const loadAsync = new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }); + const loadAsync = new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }).then(__importStar); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { console.log(err); - let one = await new Promise((resolve_6, reject_6) => { require(["./1"], resolve_6, reject_6); }); + let one = await new Promise((resolve_6, reject_6) => { require(["./1"], resolve_6, reject_6); }).then(__importStar); console.log(one.backup()); }); } diff --git a/tests/baselines/reference/importCallExpressionInCJS1.js b/tests/baselines/reference/importCallExpressionInCJS1.js index 2f1a32abe0bb5..355d2d869bc36 100644 --- a/tests/baselines/reference/importCallExpressionInCJS1.js +++ b/tests/baselines/reference/importCallExpressionInCJS1.js @@ -23,7 +23,7 @@ function foo() { return "foo"; } exports.foo = foo; //// [1.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionInCJS2.js b/tests/baselines/reference/importCallExpressionInCJS2.js index 76eea19f18c12..0a4d3c24b4103 100644 --- a/tests/baselines/reference/importCallExpressionInCJS2.js +++ b/tests/baselines/reference/importCallExpressionInCJS2.js @@ -29,7 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); function backup() { return "backup"; } exports.backup = backup; //// [2.js] -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionInCJS3.js b/tests/baselines/reference/importCallExpressionInCJS3.js index 74e1eb50a296f..70929e011014a 100644 --- a/tests/baselines/reference/importCallExpressionInCJS3.js +++ b/tests/baselines/reference/importCallExpressionInCJS3.js @@ -24,7 +24,7 @@ class B { } exports.B = B; //// [2.js] -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionInCJS4.js b/tests/baselines/reference/importCallExpressionInCJS4.js index ca1d27a7885c9..b1e98619cb6cd 100644 --- a/tests/baselines/reference/importCallExpressionInCJS4.js +++ b/tests/baselines/reference/importCallExpressionInCJS4.js @@ -21,7 +21,7 @@ class B { } exports.B = B; //// [2.js] -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionInCJS5.js b/tests/baselines/reference/importCallExpressionInCJS5.js index 810529833a78e..46a4687efa954 100644 --- a/tests/baselines/reference/importCallExpressionInCJS5.js +++ b/tests/baselines/reference/importCallExpressionInCJS5.js @@ -56,7 +56,7 @@ function backup() { return "backup"; } exports.backup = backup; //// [2.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsAMD.js b/tests/baselines/reference/importCallExpressionInExportEqualsAMD.js index 1fcef2bde3941..dab90d6baf75e 100644 --- a/tests/baselines/reference/importCallExpressionInExportEqualsAMD.js +++ b/tests/baselines/reference/importCallExpressionInExportEqualsAMD.js @@ -14,9 +14,16 @@ define(["require", "exports"], function (require, exports) { return 42; }); //// [index.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports"], function (require, exports) { "use strict"; return async function () { - const something = await new Promise((resolve_1, reject_1) => { require(["./something"], resolve_1, reject_1); }); + const something = await new Promise((resolve_1, reject_1) => { require(["./something"], resolve_1, reject_1); }).then(__importStar); }; }); diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsCJS.js b/tests/baselines/reference/importCallExpressionInExportEqualsCJS.js index 2abd57802313d..b76d8ae474b64 100644 --- a/tests/baselines/reference/importCallExpressionInExportEqualsCJS.js +++ b/tests/baselines/reference/importCallExpressionInExportEqualsCJS.js @@ -13,7 +13,7 @@ export = async function() { module.exports = 42; //// [index.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsUMD.js b/tests/baselines/reference/importCallExpressionInExportEqualsUMD.js index 356230e0d686c..0e04e4ef88f83 100644 --- a/tests/baselines/reference/importCallExpressionInExportEqualsUMD.js +++ b/tests/baselines/reference/importCallExpressionInExportEqualsUMD.js @@ -22,7 +22,7 @@ export = async function() { return 42; }); //// [index.js] -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -41,6 +41,6 @@ function __importStar(mod) { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; return async function () { - const something = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./something"))) : new Promise((resolve_1, reject_1) => { require(["./something"], resolve_1, reject_1); })); + const something = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./something"))) : new Promise((resolve_1, reject_1) => { require(["./something"], resolve_1, reject_1); }).then(__importStar)); }; }); diff --git a/tests/baselines/reference/importCallExpressionInScriptContext1.js b/tests/baselines/reference/importCallExpressionInScriptContext1.js index 4d93fb0504a51..a155ef32b7301 100644 --- a/tests/baselines/reference/importCallExpressionInScriptContext1.js +++ b/tests/baselines/reference/importCallExpressionInScriptContext1.js @@ -13,7 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); function foo() { return "foo"; } exports.foo = foo; //// [1.js] -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionInScriptContext2.js b/tests/baselines/reference/importCallExpressionInScriptContext2.js index 11579c83e1d0f..39f360ae27091 100644 --- a/tests/baselines/reference/importCallExpressionInScriptContext2.js +++ b/tests/baselines/reference/importCallExpressionInScriptContext2.js @@ -15,7 +15,7 @@ function foo() { return "foo"; } exports.foo = foo; //// [1.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionInUMD1.js b/tests/baselines/reference/importCallExpressionInUMD1.js index 73e0de92a0c14..1621aafa9108d 100644 --- a/tests/baselines/reference/importCallExpressionInUMD1.js +++ b/tests/baselines/reference/importCallExpressionInUMD1.js @@ -32,7 +32,7 @@ function foo() { exports.foo = foo; }); //// [1.js] -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -51,13 +51,13 @@ function __importStar(mod) { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; Object.defineProperty(exports, "__esModule", { value: true }); - __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); - var p1 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); + __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar); + var p1 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }).then(__importStar); p1.then(zero => { return zero.foo(); }); - exports.p2 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }); + exports.p2 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }).then(__importStar); function foo() { - const p2 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); + const p2 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }).then(__importStar); } }); diff --git a/tests/baselines/reference/importCallExpressionInUMD2.js b/tests/baselines/reference/importCallExpressionInUMD2.js index fd13b20751fbc..81fb031391619 100644 --- a/tests/baselines/reference/importCallExpressionInUMD2.js +++ b/tests/baselines/reference/importCallExpressionInUMD2.js @@ -34,7 +34,7 @@ foo(import("./0")); exports.B = B; }); //// [2.js] -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -59,5 +59,5 @@ function __importStar(mod) { b.print(); }); } - foo(__syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); })); + foo(__syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar)); }); diff --git a/tests/baselines/reference/importCallExpressionInUMD3.js b/tests/baselines/reference/importCallExpressionInUMD3.js index 3922f3e91a343..6c591e6fbebec 100644 --- a/tests/baselines/reference/importCallExpressionInUMD3.js +++ b/tests/baselines/reference/importCallExpressionInUMD3.js @@ -31,7 +31,7 @@ foo(); exports.B = B; }); //// [2.js] -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -50,7 +50,7 @@ function __importStar(mod) { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; async function foo() { - class C extends (await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }))).B { + class C extends (await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar))).B { } var c = new C(); c.print(); diff --git a/tests/baselines/reference/importCallExpressionInUMD4.js b/tests/baselines/reference/importCallExpressionInUMD4.js index bead30e49c1a7..5fd5e16f6c735 100644 --- a/tests/baselines/reference/importCallExpressionInUMD4.js +++ b/tests/baselines/reference/importCallExpressionInUMD4.js @@ -75,7 +75,7 @@ export class D { exports.backup = backup; }); //// [2.js] -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -96,30 +96,30 @@ function __importStar(mod) { Object.defineProperty(exports, "__esModule", { value: true }); class C { constructor() { - this.myModule = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); + this.myModule = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar); } method() { - const loadAsync = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); + const loadAsync = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }).then(__importStar); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { console.log(err); - let one = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./1"))) : new Promise((resolve_3, reject_3) => { require(["./1"], resolve_3, reject_3); })); + let one = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./1"))) : new Promise((resolve_3, reject_3) => { require(["./1"], resolve_3, reject_3); }).then(__importStar)); console.log(one.backup()); }); } } class D { constructor() { - this.myModule = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); + this.myModule = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }).then(__importStar); } method() { - const loadAsync = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }); + const loadAsync = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }).then(__importStar); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { console.log(err); - let one = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./1"))) : new Promise((resolve_6, reject_6) => { require(["./1"], resolve_6, reject_6); })); + let one = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./1"))) : new Promise((resolve_6, reject_6) => { require(["./1"], resolve_6, reject_6); }).then(__importStar)); console.log(one.backup()); }); } diff --git a/tests/baselines/reference/importCallExpressionNestedAMD.js b/tests/baselines/reference/importCallExpressionNestedAMD.js index dc211d4400378..66b2b0f36a0c5 100644 --- a/tests/baselines/reference/importCallExpressionNestedAMD.js +++ b/tests/baselines/reference/importCallExpressionNestedAMD.js @@ -23,11 +23,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports"], function (require, exports) { "use strict"; function foo() { return __awaiter(this, void 0, void 0, function* () { - return yield new Promise((resolve_1, reject_1) => { require([(yield new Promise((resolve_2, reject_2) => { require(["./foo"], resolve_2, reject_2); })).default], resolve_1, reject_1); }); + return yield new Promise((resolve_1, reject_1) => { require([(yield new Promise((resolve_2, reject_2) => { require(["./foo"], resolve_2, reject_2); }).then(__importStar)).default], resolve_1, reject_1); }).then(__importStar); }); } }); diff --git a/tests/baselines/reference/importCallExpressionNestedAMD2.js b/tests/baselines/reference/importCallExpressionNestedAMD2.js index 1e159af2180a6..e5db7bb7cb6a7 100644 --- a/tests/baselines/reference/importCallExpressionNestedAMD2.js +++ b/tests/baselines/reference/importCallExpressionNestedAMD2.js @@ -50,14 +50,21 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports"], function (require, exports) { "use strict"; function foo() { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_1, reject_1) { require(["./foo"], resolve_1, reject_1); })]; - case 1: return [4 /*yield*/, new Promise(function (resolve_2, reject_2) { require([(_a.sent()).default], resolve_2, reject_2); })]; + case 0: return [4 /*yield*/, new Promise(function (resolve_1, reject_1) { require(["./foo"], resolve_1, reject_1); }).then(__importStar)]; + case 1: return [4 /*yield*/, new Promise(function (resolve_2, reject_2) { require([(_a.sent()).default], resolve_2, reject_2); }).then(__importStar)]; case 2: return [2 /*return*/, _a.sent()]; } }); diff --git a/tests/baselines/reference/importCallExpressionNestedCJS.js b/tests/baselines/reference/importCallExpressionNestedCJS.js index d1f80c451651e..ccb0862913152 100644 --- a/tests/baselines/reference/importCallExpressionNestedCJS.js +++ b/tests/baselines/reference/importCallExpressionNestedCJS.js @@ -21,7 +21,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionNestedCJS2.js b/tests/baselines/reference/importCallExpressionNestedCJS2.js index fed0c6da28df6..eda6dacb0c824 100644 --- a/tests/baselines/reference/importCallExpressionNestedCJS2.js +++ b/tests/baselines/reference/importCallExpressionNestedCJS2.js @@ -48,7 +48,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionNestedUMD.js b/tests/baselines/reference/importCallExpressionNestedUMD.js index a428e406db1e5..be1b520658c43 100644 --- a/tests/baselines/reference/importCallExpressionNestedUMD.js +++ b/tests/baselines/reference/importCallExpressionNestedUMD.js @@ -31,7 +31,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -51,7 +51,7 @@ function __importStar(mod) { var __syncRequire = typeof module === "object" && typeof module.exports === "object"; function foo() { return __awaiter(this, void 0, void 0, function* () { - return yield _a = (yield __syncRequire ? Promise.resolve().then(() => __importStar(require("./foo"))) : new Promise((resolve_1, reject_1) => { require(["./foo"], resolve_1, reject_1); })).default, __syncRequire ? Promise.resolve().then(() => __importStar(require(_a))) : new Promise((resolve_2, reject_2) => { require([_a], resolve_2, reject_2); }); + return yield _a = (yield __syncRequire ? Promise.resolve().then(() => __importStar(require("./foo"))) : new Promise((resolve_1, reject_1) => { require(["./foo"], resolve_1, reject_1); }).then(__importStar)).default, __syncRequire ? Promise.resolve().then(() => __importStar(require(_a))) : new Promise((resolve_2, reject_2) => { require([_a], resolve_2, reject_2); }).then(__importStar); var _a; }); } diff --git a/tests/baselines/reference/importCallExpressionNestedUMD2.js b/tests/baselines/reference/importCallExpressionNestedUMD2.js index 71c90d074fcb0..07f795c17451d 100644 --- a/tests/baselines/reference/importCallExpressionNestedUMD2.js +++ b/tests/baselines/reference/importCallExpressionNestedUMD2.js @@ -58,7 +58,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -80,8 +80,8 @@ function __importStar(mod) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./foo")); }) : new Promise(function (resolve_1, reject_1) { require(["./foo"], resolve_1, reject_1); })]; - case 1: return [4 /*yield*/, (_b = (_a.sent()).default, __syncRequire ? Promise.resolve().then(function () { return __importStar(require(_b)); }) : new Promise(function (resolve_2, reject_2) { require([_b], resolve_2, reject_2); }))]; + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./foo")); }) : new Promise(function (resolve_1, reject_1) { require(["./foo"], resolve_1, reject_1); }).then(__importStar)]; + case 1: return [4 /*yield*/, (_b = (_a.sent()).default, __syncRequire ? Promise.resolve().then(function () { return __importStar(require(_b)); }) : new Promise(function (resolve_2, reject_2) { require([_b], resolve_2, reject_2); }).then(__importStar))]; case 2: return [2 /*return*/, _a.sent()]; } var _b; diff --git a/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.js b/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.js index 55a7fd66edf2e..7b467a669d3dc 100644 --- a/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.js +++ b/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.js @@ -79,7 +79,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.js b/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.js index 61350800a2314..16367f49510a7 100644 --- a/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.js +++ b/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.js @@ -41,7 +41,7 @@ class C { exports.C = C; //// [1.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionSpecifierNotStringTypeError.js b/tests/baselines/reference/importCallExpressionSpecifierNotStringTypeError.js index 616002cc3932f..f47755acac0d3 100644 --- a/tests/baselines/reference/importCallExpressionSpecifierNotStringTypeError.js +++ b/tests/baselines/reference/importCallExpressionSpecifierNotStringTypeError.js @@ -14,7 +14,7 @@ var p3 = import(["path1", "path2"]); var p4 = import(()=>"PathToModule"); //// [importCallExpressionSpecifierNotStringTypeError.js] -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importCallExpressionWithTypeArgument.js b/tests/baselines/reference/importCallExpressionWithTypeArgument.js index 6b2d9f397590b..0f057e85a2a57 100644 --- a/tests/baselines/reference/importCallExpressionWithTypeArgument.js +++ b/tests/baselines/reference/importCallExpressionWithTypeArgument.js @@ -15,7 +15,7 @@ function foo() { return "foo"; } exports.foo = foo; //// [1.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/importWithTrailingSlash.js b/tests/baselines/reference/importWithTrailingSlash.js index a762935b10a07..6242f5d8c5705 100644 --- a/tests/baselines/reference/importWithTrailingSlash.js +++ b/tests/baselines/reference/importWithTrailingSlash.js @@ -29,7 +29,7 @@ exports.__esModule = true; exports["default"] = { aIndex: 0 }; //// [test.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; @@ -39,7 +39,7 @@ _1["default"].a; _2["default"].aIndex; //// [test.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/importsImplicitlyReadonly.js b/tests/baselines/reference/importsImplicitlyReadonly.js index ba77fbb6affbf..38e1b21354188 100644 --- a/tests/baselines/reference/importsImplicitlyReadonly.js +++ b/tests/baselines/reference/importsImplicitlyReadonly.js @@ -28,7 +28,7 @@ var y = 1; exports.y = y; //// [b.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/inferredIndexerOnNamespaceImport.js b/tests/baselines/reference/inferredIndexerOnNamespaceImport.js index 14e08e51b01ed..1d1209c6e3168 100644 --- a/tests/baselines/reference/inferredIndexerOnNamespaceImport.js +++ b/tests/baselines/reference/inferredIndexerOnNamespaceImport.js @@ -20,7 +20,7 @@ exports.x = 3; exports.y = 5; //// [bar.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/invalidSyntaxNamespaceImportWithCommonjs.js b/tests/baselines/reference/invalidSyntaxNamespaceImportWithCommonjs.js index fb88b6dc9a762..0d35a5bd549a3 100644 --- a/tests/baselines/reference/invalidSyntaxNamespaceImportWithCommonjs.js +++ b/tests/baselines/reference/invalidSyntaxNamespaceImportWithCommonjs.js @@ -17,7 +17,7 @@ var C = /** @class */ (function () { exports.C = C; //// [1.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/isolatedModulesImportExportElision.js b/tests/baselines/reference/isolatedModulesImportExportElision.js index db9b0408ddad2..ddd010afd4381 100644 --- a/tests/baselines/reference/isolatedModulesImportExportElision.js +++ b/tests/baselines/reference/isolatedModulesImportExportElision.js @@ -24,7 +24,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/isolatedModulesReExportType.js b/tests/baselines/reference/isolatedModulesReExportType.js index d26218689354e..b2bf479f5d207 100644 --- a/tests/baselines/reference/isolatedModulesReExportType.js +++ b/tests/baselines/reference/isolatedModulesReExportType.js @@ -58,7 +58,7 @@ var C = /** @class */ (function () { exports.C = C; //// [user.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/jsxImportInAttribute.js b/tests/baselines/reference/jsxImportInAttribute.js index e15934bd4a3a2..162e1e7a71a90 100644 --- a/tests/baselines/reference/jsxImportInAttribute.js +++ b/tests/baselines/reference/jsxImportInAttribute.js @@ -15,7 +15,7 @@ let x = Test; // emit test_1.default //// [consumer.jsx] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/jsxViaImport.2.js b/tests/baselines/reference/jsxViaImport.2.js index 2f3f11248ec8b..a0fd3145aa337 100644 --- a/tests/baselines/reference/jsxViaImport.2.js +++ b/tests/baselines/reference/jsxViaImport.2.js @@ -34,7 +34,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/mergedDeclarations7.js b/tests/baselines/reference/mergedDeclarations7.js index 4120307021335..8eaaf916c15fc 100644 --- a/tests/baselines/reference/mergedDeclarations7.js +++ b/tests/baselines/reference/mergedDeclarations7.js @@ -24,7 +24,7 @@ let p: Passport = passport.use(); //// [test.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/moduleMergeConstructor.js b/tests/baselines/reference/moduleMergeConstructor.js index 1b02e37549cbc..783b02860df87 100644 --- a/tests/baselines/reference/moduleMergeConstructor.js +++ b/tests/baselines/reference/moduleMergeConstructor.js @@ -27,9 +27,17 @@ class Test { //// [index.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "foo"], function (require, exports, foo) { "use strict"; exports.__esModule = true; + foo = __importStar(foo); var Test = /** @class */ (function () { function Test() { this.bar = new foo.Foo(); diff --git a/tests/baselines/reference/multipleDefaultExports01.js b/tests/baselines/reference/multipleDefaultExports01.js index cd1a7b33ca737..90fb796c681df 100644 --- a/tests/baselines/reference/multipleDefaultExports01.js +++ b/tests/baselines/reference/multipleDefaultExports01.js @@ -33,7 +33,7 @@ var x = 10; exports.default = x; //// [m2.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/multipleDefaultExports02.js b/tests/baselines/reference/multipleDefaultExports02.js index f4c964e82c29f..0e13ebe5f76bc 100644 --- a/tests/baselines/reference/multipleDefaultExports02.js +++ b/tests/baselines/reference/multipleDefaultExports02.js @@ -25,7 +25,7 @@ function bar() { exports.default = bar; //// [m2.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/narrowedImports.js b/tests/baselines/reference/narrowedImports.js index 8aad58fa1afe3..cffc6859fb547 100644 --- a/tests/baselines/reference/narrowedImports.js +++ b/tests/baselines/reference/narrowedImports.js @@ -26,10 +26,10 @@ if (b1) x = b1; //// [x.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/noCrashOnImportShadowing.js b/tests/baselines/reference/noCrashOnImportShadowing.js index 0d1b26b807e8c..733f95b1f9ede 100644 --- a/tests/baselines/reference/noCrashOnImportShadowing.js +++ b/tests/baselines/reference/noCrashOnImportShadowing.js @@ -32,7 +32,7 @@ exports.__esModule = true; exports.zzz = 123; //// [a.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -45,7 +45,7 @@ var x = { x: "" }; B.zzz; //// [index.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/outFilerootDirModuleNamesAmd.js b/tests/baselines/reference/outFilerootDirModuleNamesAmd.js index 9166551315309..4afd572b53eb9 100644 --- a/tests/baselines/reference/outFilerootDirModuleNamesAmd.js +++ b/tests/baselines/reference/outFilerootDirModuleNamesAmd.js @@ -11,15 +11,20 @@ export default function foo() { new Foo(); } //// [output.js] +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} define("b", ["require", "exports", "a"], function (require, exports, a_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); + a_1 = __importDefault(a_1); function foo() { new a_1.default(); } exports.default = foo; }); define("a", ["require", "exports", "b"], function (require, exports, b_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); + b_1 = __importDefault(b_1); class Foo { } exports.default = Foo; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js index c372e3558b1be..ff1c22a16689d 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js @@ -7,9 +7,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "angular2/core"], function (require, exports, ng) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); + ng = __importStar(ng); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js index d81cea1e0fb6d..29a0f61fad2f1 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js @@ -8,7 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js index c372e3558b1be..ff1c22a16689d 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js @@ -7,9 +7,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "angular2/core"], function (require, exports, ng) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); + ng = __importStar(ng); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js index d81cea1e0fb6d..29a0f61fad2f1 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js @@ -8,7 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js index c372e3558b1be..ff1c22a16689d 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js @@ -7,9 +7,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "angular2/core"], function (require, exports, ng) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); + ng = __importStar(ng); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js index d81cea1e0fb6d..29a0f61fad2f1 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js @@ -8,7 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js index c372e3558b1be..ff1c22a16689d 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js @@ -7,9 +7,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "angular2/core"], function (require, exports, ng) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); + ng = __importStar(ng); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js index d81cea1e0fb6d..29a0f61fad2f1 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js @@ -8,7 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js index c372e3558b1be..ff1c22a16689d 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js @@ -7,9 +7,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "angular2/core"], function (require, exports, ng) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); + ng = __importStar(ng); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js index d81cea1e0fb6d..29a0f61fad2f1 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js @@ -8,7 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/amd/importHigher/root.js b/tests/baselines/reference/project/nodeModulesImportHigher/amd/importHigher/root.js index 65e3b33be1a80..2e5f93d503ac1 100644 --- a/tests/baselines/reference/project/nodeModulesImportHigher/amd/importHigher/root.js +++ b/tests/baselines/reference/project/nodeModulesImportHigher/amd/importHigher/root.js @@ -1,6 +1,14 @@ +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; exports.__esModule = true; + m1 = __importStar(m1); m1.f1("test"); m1.f2.a = 10; m1.f2.person.age = "10"; // Error: Should be number (if direct import of m2 made the m3 module visible). diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js b/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js index 0268860bddbd6..2613f56dbcc44 100644 --- a/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js +++ b/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js @@ -1,5 +1,5 @@ "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/maxDepthExceeded/built/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/maxDepthExceeded/built/root.js index 493e1b9636e3d..884cbebb56568 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/maxDepthExceeded/built/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/maxDepthExceeded/built/root.js @@ -1,6 +1,14 @@ +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; exports.__esModule = true; + m1 = __importStar(m1); m1.f1("test"); m1.f2.a = "10"; // Error: Should be number m1.rel = 42; // Error: Should be boolean diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/built/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/built/root.js index 6cb0099e9ea40..0ab840d7b9a7e 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/built/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/built/root.js @@ -1,5 +1,5 @@ "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js index 948a6d68b8338..8ce337db37eb5 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js @@ -1,6 +1,15 @@ +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "m1", "m4"], function (require, exports, m1, m4) { "use strict"; exports.__esModule = true; + m1 = __importStar(m1); + m4 = __importStar(m4); m1.f1("test"); m1.f2.a = 10; m1.f2.person.age = "10"; // Should error if loaded the .js files correctly diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js index 35a15cf85a9dd..c3b40e22780a2 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js @@ -1,5 +1,5 @@ "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/reExportDefaultExport.js b/tests/baselines/reference/reExportDefaultExport.js index e066eecf960fe..e8f817899c6dd 100644 --- a/tests/baselines/reference/reExportDefaultExport.js +++ b/tests/baselines/reference/reExportDefaultExport.js @@ -22,7 +22,7 @@ exports.default = f; exports.f = f; //// [m2.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/reactNamespaceImportPresevation.js b/tests/baselines/reference/reactNamespaceImportPresevation.js index fe1eccb411140..2f55351445b63 100644 --- a/tests/baselines/reference/reactNamespaceImportPresevation.js +++ b/tests/baselines/reference/reactNamespaceImportPresevation.js @@ -15,7 +15,7 @@ declare var foo: any; //// [test.jsx] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/requireAsFunctionInExternalModule.js b/tests/baselines/reference/requireAsFunctionInExternalModule.js index 3408015a0ccfc..30f72f61edd1d 100644 --- a/tests/baselines/reference/requireAsFunctionInExternalModule.js +++ b/tests/baselines/reference/requireAsFunctionInExternalModule.js @@ -25,7 +25,7 @@ function has(a) { return true; } exports.has = has; //// [m.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/transformNestedGeneratorsWithTry.js b/tests/baselines/reference/transformNestedGeneratorsWithTry.js index 536cb8edea6e9..b1da382dc8384 100644 --- a/tests/baselines/reference/transformNestedGeneratorsWithTry.js +++ b/tests/baselines/reference/transformNestedGeneratorsWithTry.js @@ -59,7 +59,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js index a004d6bdeba15..7dd1a0d89946f 100644 --- a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js +++ b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js @@ -8,7 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.oldTranspile.js b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.oldTranspile.js index a004d6bdeba15..7dd1a0d89946f 100644 --- a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.oldTranspile.js +++ b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.oldTranspile.js @@ -8,7 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/tsconfigMapOptionsAreCaseInsensitive.js b/tests/baselines/reference/tsconfigMapOptionsAreCaseInsensitive.js index be1f2323a13b6..f631751c59860 100644 --- a/tests/baselines/reference/tsconfigMapOptionsAreCaseInsensitive.js +++ b/tests/baselines/reference/tsconfigMapOptionsAreCaseInsensitive.js @@ -17,9 +17,13 @@ define(["require", "exports"], function (require, exports) { exports["default"] = 42; }); //// [index.js] +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} define(["require", "exports", "./other.js"], function (require, exports, other_js_1) { "use strict"; exports.__esModule = true; + other_js_1 = __importDefault(other_js_1); var x = 10 + other_js_1["default"]; exports.x = x; }); diff --git a/tests/baselines/reference/tsxDynamicTagName5.js b/tests/baselines/reference/tsxDynamicTagName5.js index 52e3239f08cdf..59146ec07add7 100644 --- a/tests/baselines/reference/tsxDynamicTagName5.js +++ b/tests/baselines/reference/tsxDynamicTagName5.js @@ -30,7 +30,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/tsxDynamicTagName7.js b/tests/baselines/reference/tsxDynamicTagName7.js index c89e586533553..dcc893fec832c 100644 --- a/tests/baselines/reference/tsxDynamicTagName7.js +++ b/tests/baselines/reference/tsxDynamicTagName7.js @@ -30,7 +30,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/tsxDynamicTagName8.js b/tests/baselines/reference/tsxDynamicTagName8.js index 7f481a93b6564..7722a7c18254c 100644 --- a/tests/baselines/reference/tsxDynamicTagName8.js +++ b/tests/baselines/reference/tsxDynamicTagName8.js @@ -30,7 +30,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/tsxDynamicTagName9.js b/tests/baselines/reference/tsxDynamicTagName9.js index 3824f2eff3009..11d4ed9639579 100644 --- a/tests/baselines/reference/tsxDynamicTagName9.js +++ b/tests/baselines/reference/tsxDynamicTagName9.js @@ -30,7 +30,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/tsxElementResolution19.js b/tests/baselines/reference/tsxElementResolution19.js index 60b72237354e9..a65f4ab9c702d 100644 --- a/tests/baselines/reference/tsxElementResolution19.js +++ b/tests/baselines/reference/tsxElementResolution19.js @@ -31,8 +31,16 @@ define(["require", "exports"], function (require, exports) { exports.MyClass = MyClass; }); //// [file2.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} define(["require", "exports", "react", "./file1"], function (require, exports, React, file1_1) { "use strict"; exports.__esModule = true; + React = __importStar(React); React.createElement(file1_1.MyClass, null); }); diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.js b/tests/baselines/reference/tsxExternalModuleEmit1.js index 5c04923b62340..dc0c17d603c48 100644 --- a/tests/baselines/reference/tsxExternalModuleEmit1.js +++ b/tests/baselines/reference/tsxExternalModuleEmit1.js @@ -42,7 +42,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -74,7 +74,7 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/tsxExternalModuleEmit2.js b/tests/baselines/reference/tsxExternalModuleEmit2.js index 974373f54f84f..980367d790216 100644 --- a/tests/baselines/reference/tsxExternalModuleEmit2.js +++ b/tests/baselines/reference/tsxExternalModuleEmit2.js @@ -26,7 +26,7 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { } return t; }; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/umd-augmentation-1.js b/tests/baselines/reference/umd-augmentation-1.js index 4a4e69942115c..63ec83f792e59 100644 --- a/tests/baselines/reference/umd-augmentation-1.js +++ b/tests/baselines/reference/umd-augmentation-1.js @@ -40,7 +40,7 @@ var t = p.x; //// [b.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/umd-augmentation-3.js b/tests/baselines/reference/umd-augmentation-3.js index cba8335c7ab8d..a928c801e5338 100644 --- a/tests/baselines/reference/umd-augmentation-3.js +++ b/tests/baselines/reference/umd-augmentation-3.js @@ -46,7 +46,7 @@ var t = p.x; //// [b.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/umd3.js b/tests/baselines/reference/umd3.js index 175ece3c28b45..2f76d50e6498a 100644 --- a/tests/baselines/reference/umd3.js +++ b/tests/baselines/reference/umd3.js @@ -15,7 +15,7 @@ let y: number = x.n; //// [a.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/umd4.js b/tests/baselines/reference/umd4.js index ddab566bf8bdd..54f60b0966c0e 100644 --- a/tests/baselines/reference/umd4.js +++ b/tests/baselines/reference/umd4.js @@ -15,7 +15,7 @@ let y: number = x.n; //// [a.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/umd5.js b/tests/baselines/reference/umd5.js index b73d3a9b053ed..ffce0fc4528f8 100644 --- a/tests/baselines/reference/umd5.js +++ b/tests/baselines/reference/umd5.js @@ -17,7 +17,7 @@ let z = Foo; //// [a.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; diff --git a/tests/baselines/reference/untypedModuleImport.js b/tests/baselines/reference/untypedModuleImport.js index 4f379c0269312..fef9cd0d08dde 100644 --- a/tests/baselines/reference/untypedModuleImport.js +++ b/tests/baselines/reference/untypedModuleImport.js @@ -23,7 +23,7 @@ foo(bar()); //// [a.js] "use strict"; -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; @@ -40,7 +40,7 @@ var foo = require("foo"); foo(); //// [c.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/untypedModuleImport_allowJs.js b/tests/baselines/reference/untypedModuleImport_allowJs.js index c9d56f4b065b7..1fb13250b7022 100644 --- a/tests/baselines/reference/untypedModuleImport_allowJs.js +++ b/tests/baselines/reference/untypedModuleImport_allowJs.js @@ -12,7 +12,7 @@ foo.bar(); //// [a.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } exports.__esModule = true; diff --git a/tests/baselines/reference/unusedImports11.js b/tests/baselines/reference/unusedImports11.js index 31d6ac2e5e7ac..f4b8211d36fba 100644 --- a/tests/baselines/reference/unusedImports11.js +++ b/tests/baselines/reference/unusedImports11.js @@ -29,10 +29,10 @@ exports.Member = Member; exports["default"] = Member; //// [a.js] "use strict"; -function __importDefault(mod) { +var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; } -function __importStar(mod) { +var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; From e9106036e5f087c9f8580f436b2bade891110142 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 2 Nov 2017 15:43:03 -0700 Subject: [PATCH 06/26] update typechecker to have errors on called imported namespaces and good error recovery with a quickfix --- src/compiler/checker.ts | 67 +++++++++++++++++-- src/compiler/diagnosticMessages.json | 8 +++ src/compiler/types.ts | 1 + .../codefixes/fixInvalidImportSyntax.ts | 52 ++++++++++++++ src/services/codefixes/fixes.ts | 2 + .../reference/augmentExportEquals7.types | 2 +- .../reference/es6ExportEqualsInterop.types | 8 +-- ...ransformNestedGeneratorsWithTry.errors.txt | 37 ++++++++++ .../transformNestedGeneratorsWithTry.js | 4 +- .../transformNestedGeneratorsWithTry.types | 4 +- tests/baselines/reference/umd8.symbols | 4 +- tests/baselines/reference/umd8.types | 8 +-- .../fourslash/codeFixCalledES2015Import1.ts | 18 +++++ .../fourslash/codeFixCalledES2015Import2.ts | 18 +++++ .../fourslash/codeFixCalledES2015Import3.ts | 19 ++++++ .../fourslash/codeFixCalledES2015Import4.ts | 17 +++++ .../fourslash/codeFixCalledES2015Import5.ts | 17 +++++ .../fourslash/codeFixCalledES2015Import6.ts | 18 +++++ .../fourslash/codeFixCalledES2015Import7.ts | 17 +++++ .../fourslash/codeFixCalledES2015Import8.ts | 17 +++++ .../fourslash/codeFixCalledES2015Import9.ts | 18 +++++ .../findAllRefsImportStarOfExportEquals.ts | 5 +- tests/cases/fourslash/javascriptModules24.ts | 2 +- 23 files changed, 339 insertions(+), 24 deletions(-) create mode 100644 src/services/codefixes/fixInvalidImportSyntax.ts create mode 100644 tests/baselines/reference/transformNestedGeneratorsWithTry.errors.txt create mode 100644 tests/cases/fourslash/codeFixCalledES2015Import1.ts create mode 100644 tests/cases/fourslash/codeFixCalledES2015Import2.ts create mode 100644 tests/cases/fourslash/codeFixCalledES2015Import3.ts create mode 100644 tests/cases/fourslash/codeFixCalledES2015Import4.ts create mode 100644 tests/cases/fourslash/codeFixCalledES2015Import5.ts create mode 100644 tests/cases/fourslash/codeFixCalledES2015Import6.ts create mode 100644 tests/cases/fourslash/codeFixCalledES2015Import7.ts create mode 100644 tests/cases/fourslash/codeFixCalledES2015Import8.ts create mode 100644 tests/cases/fourslash/codeFixCalledES2015Import9.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b540f92b52579..2b5d049bdf7f5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1846,8 +1846,34 @@ namespace ts { // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). function resolveESModuleSymbol(moduleSymbol: Symbol, moduleReferenceExpression: Expression, dontResolveAlias: boolean): Symbol { const symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); - if (!dontResolveAlias && symbol && !(symbol.flags & (SymbolFlags.Module | SymbolFlags.Variable))) { - error(moduleReferenceExpression, Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); + if (!dontResolveAlias && symbol) { + if (!(symbol.flags & (SymbolFlags.Module | SymbolFlags.Variable))) { + error(moduleReferenceExpression, Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); + return symbol; + } + const referenaceParent = moduleReferenceExpression.parent; + if (referenaceParent.kind === SyntaxKind.ImportDeclaration && getNamespaceDeclarationNode(referenaceParent as ImportDeclaration)) { + const type = getTypeOfSymbol(symbol); + let sigs = getSignaturesOfStructuredType(type, SignatureKind.Call); + if (!sigs || !sigs.length) { + sigs = getSignaturesOfStructuredType(type, SignatureKind.Construct); + } + if (sigs && sigs.length) { + // Create a new symbol which has the module's type less the call and construct signatures + const result = createSymbol(symbol.flags, symbol.escapedName); + result.declarations = symbol.declarations ? symbol.declarations.slice() : []; + result.parent = symbol.parent; + result.target = symbol; + result.originatingImport = referenaceParent as ImportDeclaration; + if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; + if (symbol.constEnumOnlyModule) result.constEnumOnlyModule = true; + if (symbol.members) result.members = cloneMap(symbol.members); + if (symbol.exports) result.exports = cloneMap(symbol.exports); + const moduleType = resolveStructuredTypeMembers(type as StructuredType); // Should already be resolved from the signature checks above + result.type = createAnonymousType(result, moduleType.members, emptyArray, emptyArray, moduleType.stringIndexInfo, moduleType.numberIndexInfo); + return result; + } + } } return symbol; } @@ -8963,7 +8989,19 @@ namespace ts { diagnostics.add(createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); } - return result !== Ternary.False; + const answer = result !== Ternary.False; + // Check if we should issue an extra diagnostic to produce a quickfix for a slightly incorrect import statement + if (headMessage && errorNode && !answer && source.symbol) { + const links = getSymbolLinks(source.symbol); + if (links.originatingImport) { + const helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, /*errorNode*/ undefined); + if (helpfulRetry) { + // Likely an incorrect import. Issue a helpful diagnostic to produce a quickfix to change the import + diagnostics.add(createDiagnosticForNode(links.originatingImport, Diagnostics.Import_is_called_or_constructed_which_is_not_valid_ES2015_module_usage_and_will_fail_at_runtime)); + } + } + } + return answer; function reportError(message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): void { Debug.assert(!!errorNode); @@ -16618,7 +16656,7 @@ namespace ts { error(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); } else { - error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType)); + invocationError(node, apparentType, SignatureKind.Call); } return resolveErrorCall(node); } @@ -16720,7 +16758,7 @@ namespace ts { return signature; } - error(node, Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature); + invocationError(node, expressionType, SignatureKind.Construct); return resolveErrorCall(node); } @@ -16767,6 +16805,22 @@ namespace ts { return true; } + function invocationError(node: Node, apparentType: Type, kind: SignatureKind) { + error(node, kind === SignatureKind.Call + ? Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures + : Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature + , typeToString(apparentType)); + invocationErrorRecovery(apparentType, kind); + } + + function invocationErrorRecovery(apparentType: Type, kind: SignatureKind) { + if (apparentType.symbol && getSymbolLinks(apparentType.symbol).originatingImport) { + const sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind); + if (!sigs || !sigs.length) return; + error(getSymbolLinks(apparentType.symbol).originatingImport, Diagnostics.Import_is_called_or_constructed_which_is_not_valid_ES2015_module_usage_and_will_fail_at_runtime); + } + } + function resolveTaggedTemplateExpression(node: TaggedTemplateExpression, candidatesOutArray: Signature[]): Signature { const tagType = checkExpression(node.tag); const apparentType = getApparentType(tagType); @@ -16784,7 +16838,7 @@ namespace ts { } if (!callSignatures.length) { - error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType)); + invocationError(node, apparentType, SignatureKind.Call); return resolveErrorCall(node); } @@ -16841,6 +16895,7 @@ namespace ts { errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType)); errorInfo = chainDiagnosticMessages(errorInfo, headMessage); diagnostics.add(createDiagnosticForNodeFromMessageChain(node, errorInfo)); + invocationErrorRecovery(apparentType, SignatureKind.Call); return resolveErrorCall(node); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 2309977539cb9..44df7559c6205 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3326,6 +3326,10 @@ "category": "Message", "code": 6186 }, + "Import is called or constructed, which is not valid ES2015 module usage, and will fail at runtime.": { + "category": "Error", + "code": 7004 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 @@ -3797,5 +3801,9 @@ "Convert to default import": { "category": "Message", "code": 95013 + }, + "Replace import with '{0}'.": { + "category": "Message", + "code": 95014 } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3065ec0243134..a6c62b92d2137 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3102,6 +3102,7 @@ namespace ts { bindingElement?: BindingElement; // Binding element associated with property symbol exportsSomeValue?: boolean; // True if module exports some value (not just types) enumKind?: EnumKind; // Enum declaration classification + originatingImport?: ImportDeclaration; // Import declaration which produced the symbol, present if the symbol is poisoned } /* @internal */ diff --git a/src/services/codefixes/fixInvalidImportSyntax.ts b/src/services/codefixes/fixInvalidImportSyntax.ts new file mode 100644 index 0000000000000..37c3ba1a73633 --- /dev/null +++ b/src/services/codefixes/fixInvalidImportSyntax.ts @@ -0,0 +1,52 @@ +/* @internal */ +namespace ts.codefix { + registerCodeFix({ + errorCodes: [Diagnostics.Import_is_called_or_constructed_which_is_not_valid_ES2015_module_usage_and_will_fail_at_runtime.code], + getCodeActions: getActionsForInvalidImport + }); + + function getActionsForInvalidImport(context: CodeFixContext): CodeAction[] | undefined { + const sourceFile = context.sourceFile; + + // This is the whole import statement, eg: + // import * as Bluebird from 'bluebird'; + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + const node = getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false).parent as ImportDeclaration; + const namespace = getNamespaceDeclarationNode(node) as NamespaceImport; + const opts = context.program.getCompilerOptions(); + const variations: CodeAction[] = []; + if (opts.module === ModuleKind.CommonJS || (!opts.module && opts.target < ScriptTarget.ES2015)) { + // import Bluebird = require("bluebird"); + const replacement = createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + namespace.name, + createExternalModuleReference(node.moduleSpecifier) + ); + const changeTracker = textChanges.ChangeTracker.fromContext(context); + changeTracker.replaceNode(sourceFile, node, replacement, { useNonAdjustedEndPosition: true }); + const changes = changeTracker.getChanges(); + variations.push({ + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Replace_import_with_0), [changes[0].textChanges[0].newText]), + changes + }); + } + + // import Bluebird from "bluebird"; + const replacement = createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createImportClause(namespace.name, /*namedBindings*/ undefined), + node.moduleSpecifier + ); + const changeTracker = textChanges.ChangeTracker.fromContext(context); + changeTracker.replaceNode(sourceFile, node, replacement, { useNonAdjustedEndPosition: true }); + const changes = changeTracker.getChanges(); + variations.push({ + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Replace_import_with_0), [changes[0].textChanges[0].newText]), + changes + }); + + return variations; + } +} diff --git a/src/services/codefixes/fixes.ts b/src/services/codefixes/fixes.ts index 5b1ee8ec8572c..bdbd8311a762d 100644 --- a/src/services/codefixes/fixes.ts +++ b/src/services/codefixes/fixes.ts @@ -15,3 +15,5 @@ /// /// /// +/// + diff --git a/tests/baselines/reference/augmentExportEquals7.types b/tests/baselines/reference/augmentExportEquals7.types index f2870eab8dfbb..b574fe9728a00 100644 --- a/tests/baselines/reference/augmentExportEquals7.types +++ b/tests/baselines/reference/augmentExportEquals7.types @@ -10,7 +10,7 @@ export = lib; === /node_modules/@types/lib-extender/index.d.ts === import * as lib from "lib"; ->lib : () => void +>lib : {} declare module "lib" { export function fn(): void; diff --git a/tests/baselines/reference/es6ExportEqualsInterop.types b/tests/baselines/reference/es6ExportEqualsInterop.types index a20f53009c462..3fb08be9472ca 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.types +++ b/tests/baselines/reference/es6ExportEqualsInterop.types @@ -136,13 +136,13 @@ import * as y7 from "function"; >y7 : () => any import * as y8 from "function-module"; ->y8 : typeof z8 +>y8 : typeof y8 import * as y9 from "class"; >y9 : typeof z9 import * as y0 from "class-module"; ->y0 : typeof z0 +>y0 : typeof y0 y1.a; >y1.a : any @@ -181,7 +181,7 @@ y7.a; y8.a; >y8.a : number ->y8 : typeof z8 +>y8 : typeof y8 >a : number y9.a; @@ -191,7 +191,7 @@ y9.a; y0.a; >y0.a : number ->y0 : typeof z0 +>y0 : typeof y0 >a : number // named import diff --git a/tests/baselines/reference/transformNestedGeneratorsWithTry.errors.txt b/tests/baselines/reference/transformNestedGeneratorsWithTry.errors.txt new file mode 100644 index 0000000000000..e3b982f0ec624 --- /dev/null +++ b/tests/baselines/reference/transformNestedGeneratorsWithTry.errors.txt @@ -0,0 +1,37 @@ +tests/cases/compiler/main.ts(2,1): error TS7004: Import is called or constructed, which is not valid ES2015 module usage, and will fail at runtime. +tests/cases/compiler/main.ts(3,21): error TS1055: Type '{ readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; }' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. +tests/cases/compiler/main.ts(3,21): error TS1055: Type '{ readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; }' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. + Type '{ readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; }' provides no match for the signature 'new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): PromiseLike'. +tests/cases/compiler/main.ts(5,35): error TS1055: Type '{ readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; }' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. + + +==== tests/cases/compiler/main.ts (4 errors) ==== + // https://github.com/Microsoft/TypeScript/issues/11177 + import * as Bluebird from 'bluebird'; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS7004: Import is called or constructed, which is not valid ES2015 module usage, and will fail at runtime. + async function a(): Bluebird { + ~~~~~~~~~~~~~~ +!!! error TS1055: Type '{ readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; }' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. + ~~~~~~~~~~~~~~ +!!! error TS1055: Type '{ readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; }' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. +!!! error TS1055: Type '{ readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; }' provides no match for the signature 'new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): PromiseLike'. + try { + const b = async function b(): Bluebird { + ~~~~~~~~~~~~~~ +!!! error TS1055: Type '{ readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; }' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. + try { + await Bluebird.resolve(); // -- remove this and it compiles + } catch (error) { } + }; + + await b(); // -- or remove this and it compiles + } catch (error) { } + } + +==== tests/cases/compiler/bluebird.d.ts (0 errors) ==== + declare module "bluebird" { + type Bluebird = Promise; + const Bluebird: typeof Promise; + export = Bluebird; + } \ No newline at end of file diff --git a/tests/baselines/reference/transformNestedGeneratorsWithTry.js b/tests/baselines/reference/transformNestedGeneratorsWithTry.js index b1da382dc8384..a93f09b04d513 100644 --- a/tests/baselines/reference/transformNestedGeneratorsWithTry.js +++ b/tests/baselines/reference/transformNestedGeneratorsWithTry.js @@ -70,14 +70,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); // https://github.com/Microsoft/TypeScript/issues/11177 var Bluebird = __importStar(require("bluebird")); function a() { - return __awaiter(this, void 0, Bluebird, function () { + return __awaiter(this, void 0, void 0, function () { var b, error_1; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); b = function b() { - return __awaiter(this, void 0, Bluebird, function () { + return __awaiter(this, void 0, void 0, function () { var error_2; return __generator(this, function (_a) { switch (_a.label) { diff --git a/tests/baselines/reference/transformNestedGeneratorsWithTry.types b/tests/baselines/reference/transformNestedGeneratorsWithTry.types index 3e4ef3f0852cf..6d8c318cdcbaf 100644 --- a/tests/baselines/reference/transformNestedGeneratorsWithTry.types +++ b/tests/baselines/reference/transformNestedGeneratorsWithTry.types @@ -1,7 +1,7 @@ === tests/cases/compiler/main.ts === // https://github.com/Microsoft/TypeScript/issues/11177 import * as Bluebird from 'bluebird'; ->Bluebird : PromiseConstructor +>Bluebird : { readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; } async function a(): Bluebird { >a : () => Promise @@ -19,7 +19,7 @@ async function a(): Bluebird { >await Bluebird.resolve() : void >Bluebird.resolve() : Promise >Bluebird.resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->Bluebird : PromiseConstructor +>Bluebird : { readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; } >resolve : { (value: T | PromiseLike): Promise; (): Promise; } } catch (error) { } diff --git a/tests/baselines/reference/umd8.symbols b/tests/baselines/reference/umd8.symbols index 704019209fdeb..99c5a40be728b 100644 --- a/tests/baselines/reference/umd8.symbols +++ b/tests/baselines/reference/umd8.symbols @@ -8,9 +8,9 @@ let y: Foo; // OK in type position >Foo : Symbol(Foo, Decl(foo.d.ts, 6, 15)) y.foo(); ->y.foo : Symbol(ff.foo, Decl(foo.d.ts, 0, 21)) +>y.foo : Symbol(Thing.foo, Decl(foo.d.ts, 0, 21)) >y : Symbol(y, Decl(a.ts, 3, 3)) ->foo : Symbol(ff.foo, Decl(foo.d.ts, 0, 21)) +>foo : Symbol(Thing.foo, Decl(foo.d.ts, 0, 21)) let z: Foo.SubThing; // OK in ns position >z : Symbol(z, Decl(a.ts, 5, 3)) diff --git a/tests/baselines/reference/umd8.types b/tests/baselines/reference/umd8.types index d2fa4dbc34ab6..3489266ebc936 100644 --- a/tests/baselines/reference/umd8.types +++ b/tests/baselines/reference/umd8.types @@ -4,13 +4,13 @@ import * as ff from './foo'; >ff : typeof ff let y: Foo; // OK in type position ->y : ff ->Foo : ff +>y : Thing +>Foo : Thing y.foo(); >y.foo() : number >y.foo : () => number ->y : ff +>y : Thing >foo : () => number let z: Foo.SubThing; // OK in ns position @@ -20,7 +20,7 @@ let z: Foo.SubThing; // OK in ns position let x: any = Foo; // Not OK in value position >x : any ->Foo : typeof ff +>Foo : typeof Thing === tests/cases/conformance/externalModules/foo.d.ts === declare class Thing { diff --git a/tests/cases/fourslash/codeFixCalledES2015Import1.ts b/tests/cases/fourslash/codeFixCalledES2015Import1.ts new file mode 100644 index 0000000000000..71d57c73e57e6 --- /dev/null +++ b/tests/cases/fourslash/codeFixCalledES2015Import1.ts @@ -0,0 +1,18 @@ +/// + +// @Filename: foo.d.ts +////declare function foo(): void; +////declare namespace foo {} +////export = foo; + +// @Filename: index.ts +////[|import * as foo from "./foo";|] +////function invoke(f: () => void) { f(); } +////invoke(foo); + +goTo.file(1); +verify.codeFix({ + description: `Replace import with 'import foo = require("./foo");'.`, + newRangeContent: `import foo = require("./foo");`, + index: 0, +}); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import2.ts b/tests/cases/fourslash/codeFixCalledES2015Import2.ts new file mode 100644 index 0000000000000..42726d13bbaa3 --- /dev/null +++ b/tests/cases/fourslash/codeFixCalledES2015Import2.ts @@ -0,0 +1,18 @@ +/// + +// @Filename: foo.d.ts +////declare function foo(): void; +////declare namespace foo {} +////export = foo; + +// @Filename: index.ts +////[|import * as foo from "./foo";|] +////function invoke(f: () => void) { f(); } +////invoke(foo); + +goTo.file(1); +verify.codeFix({ + description: `Replace import with 'import foo from "./foo";'.`, + newRangeContent: `import foo from "./foo";`, + index: 1, +}); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import3.ts b/tests/cases/fourslash/codeFixCalledES2015Import3.ts new file mode 100644 index 0000000000000..50a8827e28b4c --- /dev/null +++ b/tests/cases/fourslash/codeFixCalledES2015Import3.ts @@ -0,0 +1,19 @@ +/// + +// @module: amd +// @Filename: foo.d.ts +////declare function foo(): void; +////declare namespace foo {} +////export = foo; + +// @Filename: index.ts +////[|import * as foo from "./foo";|] +////function invoke(f: () => void) { f(); } +////invoke(foo); + +goTo.file(1); +verify.codeFix({ + description: `Replace import with 'import foo from "./foo";'.`, + newRangeContent: `import foo from "./foo";`, + index: 0, +}); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import4.ts b/tests/cases/fourslash/codeFixCalledES2015Import4.ts new file mode 100644 index 0000000000000..10bf47fec10d8 --- /dev/null +++ b/tests/cases/fourslash/codeFixCalledES2015Import4.ts @@ -0,0 +1,17 @@ +/// + +// @Filename: foo.d.ts +////declare function foo(): void; +////declare namespace foo {} +////export = foo; + +// @Filename: index.ts +////[|import * as foo from "./foo";|] +////foo(); + +goTo.file(1); +verify.codeFix({ + description: `Replace import with 'import foo = require("./foo");'.`, + newRangeContent: `import foo = require("./foo");`, + index: 0, +}); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import5.ts b/tests/cases/fourslash/codeFixCalledES2015Import5.ts new file mode 100644 index 0000000000000..fd0f4b87cae1c --- /dev/null +++ b/tests/cases/fourslash/codeFixCalledES2015Import5.ts @@ -0,0 +1,17 @@ +/// + +// @Filename: foo.d.ts +////declare function foo(): void; +////declare namespace foo {} +////export = foo; + +// @Filename: index.ts +////[|import * as foo from "./foo";|] +////foo(); + +goTo.file(1); +verify.codeFix({ + description: `Replace import with 'import foo from "./foo";'.`, + newRangeContent: `import foo from "./foo";`, + index: 1, +}); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import6.ts b/tests/cases/fourslash/codeFixCalledES2015Import6.ts new file mode 100644 index 0000000000000..9b2105c9970d6 --- /dev/null +++ b/tests/cases/fourslash/codeFixCalledES2015Import6.ts @@ -0,0 +1,18 @@ +/// + +// @module: amd +// @Filename: foo.d.ts +////declare function foo(): void; +////declare namespace foo {} +////export = foo; + +// @Filename: index.ts +////[|import * as foo from "./foo";|] +////foo(); + +goTo.file(1); +verify.codeFix({ + description: `Replace import with 'import foo from "./foo";'.`, + newRangeContent: `import foo from "./foo";`, + index: 0, +}); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import7.ts b/tests/cases/fourslash/codeFixCalledES2015Import7.ts new file mode 100644 index 0000000000000..758d769fc245e --- /dev/null +++ b/tests/cases/fourslash/codeFixCalledES2015Import7.ts @@ -0,0 +1,17 @@ +/// + +// @Filename: foo.d.ts +////declare class foo(): void; +////declare namespace foo {} +////export = foo; + +// @Filename: index.ts +////[|import * as foo from "./foo";|] +////new foo(); + +goTo.file(1); +verify.codeFix({ + description: `Replace import with 'import foo = require("./foo");'.`, + newRangeContent: `import foo = require("./foo");`, + index: 0, +}); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import8.ts b/tests/cases/fourslash/codeFixCalledES2015Import8.ts new file mode 100644 index 0000000000000..af3781127188a --- /dev/null +++ b/tests/cases/fourslash/codeFixCalledES2015Import8.ts @@ -0,0 +1,17 @@ +/// + +// @Filename: foo.d.ts +////declare class foo(): void; +////declare namespace foo {} +////export = foo; + +// @Filename: index.ts +////[|import * as foo from "./foo";|] +////new foo(); + +goTo.file(1); +verify.codeFix({ + description: `Replace import with 'import foo from "./foo";'.`, + newRangeContent: `import foo from "./foo";`, + index: 1, +}); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import9.ts b/tests/cases/fourslash/codeFixCalledES2015Import9.ts new file mode 100644 index 0000000000000..e1840cdcfa234 --- /dev/null +++ b/tests/cases/fourslash/codeFixCalledES2015Import9.ts @@ -0,0 +1,18 @@ +/// + +// @module: amd +// @Filename: foo.d.ts +////declare class foo(): void; +////declare namespace foo {} +////export = foo; + +// @Filename: index.ts +////[|import * as foo from "./foo";|] +////new foo(); + +goTo.file(1); +verify.codeFix({ + description: `Replace import with 'import foo from "./foo";'.`, + newRangeContent: `import foo from "./foo";`, + index: 0, +}); diff --git a/tests/cases/fourslash/findAllRefsImportStarOfExportEquals.ts b/tests/cases/fourslash/findAllRefsImportStarOfExportEquals.ts index c57f4a67fda98..c409f0c67eba6 100644 --- a/tests/cases/fourslash/findAllRefsImportStarOfExportEquals.ts +++ b/tests/cases/fourslash/findAllRefsImportStarOfExportEquals.ts @@ -1,5 +1,6 @@ /// +// @allowSyntheticDefaultimports: true // @Filename: /node_modules/a/index.d.ts ////declare function [|{| "isWriteAccess": true, "isDefinition": true |}a|](): void; ////declare namespace [|{| "isWriteAccess": true, "isDefinition": true |}a|] { @@ -9,13 +10,13 @@ // Import with different name and we find local refs // @Filename: /b.ts -////import * as [|{| "isWriteAccess": true, "isDefinition": true |}b|] from "a"; +////import [|{| "isWriteAccess": true, "isDefinition": true |}b|] from "a"; ////[|b|](); ////[|b|].x; // Import with same name and we find all refs // @Filename: /c.ts -////import * as [|{| "isWriteAccess": true, "isDefinition": true |}a|] from "a"; +////import [|{| "isWriteAccess": true, "isDefinition": true |}a|] from "a"; ////[|a|](); ////[|a|].x; diff --git a/tests/cases/fourslash/javascriptModules24.ts b/tests/cases/fourslash/javascriptModules24.ts index 5a0dd892db7b3..6ee379cc9f046 100644 --- a/tests/cases/fourslash/javascriptModules24.ts +++ b/tests/cases/fourslash/javascriptModules24.ts @@ -16,6 +16,6 @@ goTo.marker('1'); /**** BUG: Should be an error to invoke a call signature on a namespace import ****/ //verify.errorExistsBeforeMarker('1'); -verify.quickInfoIs("(alias) foo(): number\nimport foo"); +verify.quickInfoIs("import foo"); goTo.marker('2'); verify.signatureHelpArgumentCountIs(1); From e84b051fa50c3d12bf4414fb5d24499ca83819d8 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 2 Nov 2017 17:49:54 -0700 Subject: [PATCH 07/26] Overhaul allowSyntheticDefaultExports to be safer --- src/compiler/checker.ts | 85 +++++++++++++++---- src/compiler/types.ts | 2 +- .../allowSyntheticDefaultImports1.js | 11 +-- .../allowSyntheticDefaultImports1.symbols | 10 +-- .../allowSyntheticDefaultImports1.types | 2 +- .../allowSyntheticDefaultImports2.js | 19 +---- .../allowSyntheticDefaultImports2.symbols | 10 +-- .../allowSyntheticDefaultImports2.types | 2 +- .../es6ExportEqualsInterop.errors.txt | 32 +------ .../reference/es6ExportEqualsInterop.types | 18 ++-- .../es6ImportDefaultBindingInEs5.errors.txt | 11 --- .../es6ImportDefaultBindingInEs5.types | 2 +- .../importCallExpressionAsyncES3System.types | 30 +++---- .../importCallExpressionAsyncES5System.types | 30 +++---- .../importCallExpressionAsyncES6System.types | 30 +++---- .../importCallExpressionES5System.types | 34 ++++---- .../importCallExpressionES6System.types | 34 ++++---- ...mportCallExpressionInExportEqualsAMD.types | 6 +- ...mportCallExpressionInExportEqualsCJS.types | 6 +- ...mportCallExpressionInExportEqualsUMD.types | 6 +- .../importCallExpressionInSystem1.types | 26 +++--- .../importCallExpressionInSystem2.types | 2 +- .../importCallExpressionInSystem3.types | 6 +- .../importCallExpressionInSystem4.types | 60 ++++++------- .../moduleElementsInWrongContext.types | 2 +- ...eticDefaultExportsWithDynamicImports.types | 8 +- .../compiler/allowSyntheticDefaultImports1.ts | 2 +- .../compiler/allowSyntheticDefaultImports2.ts | 2 +- 28 files changed, 236 insertions(+), 252 deletions(-) delete mode 100644 tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2b5d049bdf7f5..ce896828d50f7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -64,7 +64,7 @@ namespace ts { const languageVersion = getEmitScriptTarget(compilerOptions); const modulekind = getEmitModuleKind(compilerOptions); const noUnusedIdentifiers = !!compilerOptions.noUnusedLocals || !!compilerOptions.noUnusedParameters; - const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ModuleKind.System; + const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : (modulekind && modulekind < ModuleKind.ES2015); const strictNullChecks = getStrictOptionValue(compilerOptions, "strictNullChecks"); const strictFunctionTypes = getStrictOptionValue(compilerOptions, "strictFunctionTypes"); const noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny"); @@ -1431,6 +1431,43 @@ namespace ts { return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); } + function resolveExportByName(moduleSymbol: Symbol, name: __String, dontResolveAlias: boolean) { + const exportValue = moduleSymbol.exports.get(InternalSymbolName.ExportEquals); + return exportValue + ? getPropertyOfType(getTypeOfSymbol(exportValue), name) + : resolveSymbol(moduleSymbol.exports.get(name), dontResolveAlias); + } + + function canHaveSyntheticDefault(file: SourceFile | undefined, moduleSymbol: Symbol, dontResolveAlias: boolean) { + if (!allowSyntheticDefaultImports) { + return false; + } + // Declaration files (and ambient modules) + if (!file || file.isDeclarationFile) { + // Definitely cannot have a synthetic default if they have a default member specified + if (resolveExportByName(moduleSymbol, InternalSymbolName.Default, dontResolveAlias)) { + return false; + } + // It _might_ still be incorrect to assume there is no __esModule marker on the import at runtime, even if there is no `default` member + // So we check a bit more, + if (resolveExportByName(moduleSymbol, escapeLeadingUnderscores("__esModule"), dontResolveAlias)) { + // If there is an `__esModule` specified in the declaration (meaning someone explicitly added it or wrote it in their code), + // it definitely is a module and does not have a synthetic default + return false; + } + // There are _many_ declaration files not written with esmodules in mind that still get compiled into a format with __esModule set + // Meaning there may be no default at runtime - however to be on the permissive side, we allow access to a synthetic default member + // as there is no marker to indicate if the accompanying JS has `__esModule` or not, or is even native esm + return true; + } + // TypeScript files never have a synthetic default (as they are always emitted with an __esModule marker) _unless_ they contain an export= statement + if (!isSourceFileJavaScript(file)) { + return hasExportAssignmentSymbol(moduleSymbol); + } + // JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker + return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, escapeLeadingUnderscores("__esModule"), dontResolveAlias); + } + function getTargetOfImportClause(node: ImportClause, dontResolveAlias: boolean): Symbol { const moduleSymbol = resolveExternalModuleName(node, (node.parent).moduleSpecifier); @@ -1440,22 +1477,26 @@ namespace ts { exportDefaultSymbol = moduleSymbol; } else { - const exportValue = moduleSymbol.exports.get("export=" as __String); - exportDefaultSymbol = exportValue - ? getPropertyOfType(getTypeOfSymbol(exportValue), "default" as __String) - : resolveSymbol(moduleSymbol.exports.get("default" as __String), dontResolveAlias); + exportDefaultSymbol = resolveExportByName(moduleSymbol, InternalSymbolName.Default, dontResolveAlias); } - if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { + const file = forEach(moduleSymbol.declarations, sourceFileOrUndefined); + const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias); + if (!exportDefaultSymbol && !hasSyntheticDefault) { error(node.name, Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } - else if (!exportDefaultSymbol && allowSyntheticDefaultImports) { + else if (!exportDefaultSymbol && hasSyntheticDefault) { + // per emit behavior, a synthetic default overrides a "real" .default member if `__esModule` is not present return resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } return exportDefaultSymbol; } } + function sourceFileOrUndefined(d: Declaration) { + return isSourceFile(d) ? d : undefined; + } + function getTargetOfNamespaceImport(node: NamespaceImport, dontResolveAlias: boolean): Symbol { const moduleSpecifier = (node.parent.parent).moduleSpecifier; return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); @@ -1851,8 +1892,11 @@ namespace ts { error(moduleReferenceExpression, Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } - const referenaceParent = moduleReferenceExpression.parent; - if (referenaceParent.kind === SyntaxKind.ImportDeclaration && getNamespaceDeclarationNode(referenaceParent as ImportDeclaration)) { + const referenceParent = moduleReferenceExpression.parent; + if ( + (referenceParent.kind === SyntaxKind.ImportDeclaration && getNamespaceDeclarationNode(referenceParent as ImportDeclaration)) || + isImportCall(referenceParent) + ) { const type = getTypeOfSymbol(symbol); let sigs = getSignaturesOfStructuredType(type, SignatureKind.Call); if (!sigs || !sigs.length) { @@ -1864,7 +1908,7 @@ namespace ts { result.declarations = symbol.declarations ? symbol.declarations.slice() : []; result.parent = symbol.parent; result.target = symbol; - result.originatingImport = referenaceParent as ImportDeclaration; + result.originatingImport = referenceParent as ImportDeclaration | ImportCall; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; if (symbol.constEnumOnlyModule) result.constEnumOnlyModule = true; if (symbol.members) result.members = cloneMap(symbol.members); @@ -8993,7 +9037,7 @@ namespace ts { // Check if we should issue an extra diagnostic to produce a quickfix for a slightly incorrect import statement if (headMessage && errorNode && !answer && source.symbol) { const links = getSymbolLinks(source.symbol); - if (links.originatingImport) { + if (links.originatingImport && !isImportCall(links.originatingImport)) { const helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, /*errorNode*/ undefined); if (helpfulRetry) { // Likely an incorrect import. Issue a helpful diagnostic to produce a quickfix to change the import @@ -16814,10 +16858,16 @@ namespace ts { } function invocationErrorRecovery(apparentType: Type, kind: SignatureKind) { - if (apparentType.symbol && getSymbolLinks(apparentType.symbol).originatingImport) { + if (!apparentType.symbol) { + return; + } + const importNode = getSymbolLinks(apparentType.symbol).originatingImport; + // Create a diagnostic on the originating import if possible onto which we can attach a quickfix + // An import call expression cannot be rewritten into another form to correct the error - the only solution is to use `.default` at the use-site + if (importNode && !isImportCall(importNode)) { const sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind); if (!sigs || !sigs.length) return; - error(getSymbolLinks(apparentType.symbol).originatingImport, Diagnostics.Import_is_called_or_constructed_which_is_not_valid_ES2015_module_usage_and_will_fail_at_runtime); + error(importNode, Diagnostics.Import_is_called_or_constructed_which_is_not_valid_ES2015_module_usage_and_will_fail_at_runtime); } } @@ -17126,17 +17176,18 @@ namespace ts { if (moduleSymbol) { const esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true); if (esModuleSymbol) { - return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol)); + return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol)); } } return createPromiseReturnType(node, anyType); } - function getTypeWithSyntheticDefaultImportType(type: Type, symbol: Symbol): Type { + function getTypeWithSyntheticDefaultImportType(type: Type, symbol: Symbol, originalSymbol: Symbol): Type { if (allowSyntheticDefaultImports && type && type !== unknownType) { const synthType = type as SyntheticDefaultModuleType; if (!synthType.syntheticType) { - if (!getPropertyOfType(type, InternalSymbolName.Default)) { + const hasSyntheticDefault = canHaveSyntheticDefault(forEach(originalSymbol.declarations, sourceFileOrUndefined), originalSymbol, /*dontResolveAlias*/ false); + if (hasSyntheticDefault) { const memberTable = createSymbolTable(); const newSymbol = createSymbol(SymbolFlags.Alias, InternalSymbolName.Default); newSymbol.target = resolveSymbol(symbol); @@ -17144,7 +17195,7 @@ namespace ts { const anonymousSymbol = createSymbol(SymbolFlags.TypeLiteral, InternalSymbolName.Type); const defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); anonymousSymbol.type = defaultContainingObject; - synthType.syntheticType = getIntersectionType([type, defaultContainingObject]); + synthType.syntheticType = (type.flags & TypeFlags.StructuredType && type.symbol.flags & (SymbolFlags.Module | SymbolFlags.Variable)) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*propegatedFlags*/ 0) : defaultContainingObject; } else { synthType.syntheticType = type; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a6c62b92d2137..6ed43e1b3e433 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3102,7 +3102,7 @@ namespace ts { bindingElement?: BindingElement; // Binding element associated with property symbol exportsSomeValue?: boolean; // True if module exports some value (not just types) enumKind?: EnumKind; // Enum declaration classification - originatingImport?: ImportDeclaration; // Import declaration which produced the symbol, present if the symbol is poisoned + originatingImport?: ImportDeclaration | ImportCall; // Import declaration which produced the symbol, present if the symbol is poisoned } /* @internal */ diff --git a/tests/baselines/reference/allowSyntheticDefaultImports1.js b/tests/baselines/reference/allowSyntheticDefaultImports1.js index 3a4bce821b343..ced1db946b6c2 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports1.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports1.js @@ -4,21 +4,12 @@ import Namespace from "./b"; export var x = new Namespace.Foo(); -//// [b.ts] +//// [b.d.ts] export class Foo { member: string; } -//// [b.js] -"use strict"; -exports.__esModule = true; -var Foo = /** @class */ (function () { - function Foo() { - } - return Foo; -}()); -exports.Foo = Foo; //// [a.js] "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { diff --git a/tests/baselines/reference/allowSyntheticDefaultImports1.symbols b/tests/baselines/reference/allowSyntheticDefaultImports1.symbols index ecbe9e4c2057a..5ee2812ab59c6 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports1.symbols +++ b/tests/baselines/reference/allowSyntheticDefaultImports1.symbols @@ -4,15 +4,15 @@ import Namespace from "./b"; export var x = new Namespace.Foo(); >x : Symbol(x, Decl(a.ts, 1, 10)) ->Namespace.Foo : Symbol(Namespace.Foo, Decl(b.ts, 0, 0)) +>Namespace.Foo : Symbol(Namespace.Foo, Decl(b.d.ts, 0, 0)) >Namespace : Symbol(Namespace, Decl(a.ts, 0, 6)) ->Foo : Symbol(Namespace.Foo, Decl(b.ts, 0, 0)) +>Foo : Symbol(Namespace.Foo, Decl(b.d.ts, 0, 0)) -=== tests/cases/compiler/b.ts === +=== tests/cases/compiler/b.d.ts === export class Foo { ->Foo : Symbol(Foo, Decl(b.ts, 0, 0)) +>Foo : Symbol(Foo, Decl(b.d.ts, 0, 0)) member: string; ->member : Symbol(Foo.member, Decl(b.ts, 0, 18)) +>member : Symbol(Foo.member, Decl(b.d.ts, 0, 18)) } diff --git a/tests/baselines/reference/allowSyntheticDefaultImports1.types b/tests/baselines/reference/allowSyntheticDefaultImports1.types index c2265d7611b38..c8092331a4784 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports1.types +++ b/tests/baselines/reference/allowSyntheticDefaultImports1.types @@ -9,7 +9,7 @@ export var x = new Namespace.Foo(); >Namespace : typeof Namespace >Foo : typeof Namespace.Foo -=== tests/cases/compiler/b.ts === +=== tests/cases/compiler/b.d.ts === export class Foo { >Foo : Foo diff --git a/tests/baselines/reference/allowSyntheticDefaultImports2.js b/tests/baselines/reference/allowSyntheticDefaultImports2.js index 5dc8472d58bc8..c1e43a4fc81e4 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports2.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports2.js @@ -4,28 +4,11 @@ import Namespace from "./b"; export var x = new Namespace.Foo(); -//// [b.ts] +//// [b.d.ts] export class Foo { member: string; } -//// [b.js] -System.register([], function (exports_1, context_1) { - "use strict"; - var __moduleName = context_1 && context_1.id; - var Foo; - return { - setters: [], - execute: function () { - Foo = /** @class */ (function () { - function Foo() { - } - return Foo; - }()); - exports_1("Foo", Foo); - } - }; -}); //// [a.js] System.register(["./b"], function (exports_1, context_1) { "use strict"; diff --git a/tests/baselines/reference/allowSyntheticDefaultImports2.symbols b/tests/baselines/reference/allowSyntheticDefaultImports2.symbols index 615b1095c66c3..a2b33c94d82a5 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports2.symbols +++ b/tests/baselines/reference/allowSyntheticDefaultImports2.symbols @@ -4,14 +4,14 @@ import Namespace from "./b"; export var x = new Namespace.Foo(); >x : Symbol(x, Decl(a.ts, 1, 10)) ->Namespace.Foo : Symbol(Namespace.Foo, Decl(b.ts, 0, 0)) +>Namespace.Foo : Symbol(Namespace.Foo, Decl(b.d.ts, 0, 0)) >Namespace : Symbol(Namespace, Decl(a.ts, 0, 6)) ->Foo : Symbol(Namespace.Foo, Decl(b.ts, 0, 0)) +>Foo : Symbol(Namespace.Foo, Decl(b.d.ts, 0, 0)) -=== tests/cases/compiler/b.ts === +=== tests/cases/compiler/b.d.ts === export class Foo { ->Foo : Symbol(Foo, Decl(b.ts, 0, 0)) +>Foo : Symbol(Foo, Decl(b.d.ts, 0, 0)) member: string; ->member : Symbol(Foo.member, Decl(b.ts, 0, 18)) +>member : Symbol(Foo.member, Decl(b.d.ts, 0, 18)) } diff --git a/tests/baselines/reference/allowSyntheticDefaultImports2.types b/tests/baselines/reference/allowSyntheticDefaultImports2.types index c40fbc7e98859..420c19b7c1dd7 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports2.types +++ b/tests/baselines/reference/allowSyntheticDefaultImports2.types @@ -9,7 +9,7 @@ export var x = new Namespace.Foo(); >Namespace : typeof Namespace >Foo : typeof Namespace.Foo -=== tests/cases/compiler/b.ts === +=== tests/cases/compiler/b.d.ts === export class Foo { >Foo : Foo diff --git a/tests/baselines/reference/es6ExportEqualsInterop.errors.txt b/tests/baselines/reference/es6ExportEqualsInterop.errors.txt index 4675136d0817f..dc93c38b31b71 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.errors.txt +++ b/tests/baselines/reference/es6ExportEqualsInterop.errors.txt @@ -1,16 +1,6 @@ tests/cases/compiler/main.ts(15,1): error TS2693: 'z1' only refers to a type, but is being used as a value here. tests/cases/compiler/main.ts(21,4): error TS2339: Property 'a' does not exist on type '() => any'. tests/cases/compiler/main.ts(23,4): error TS2339: Property 'a' does not exist on type 'typeof Foo'. -tests/cases/compiler/main.ts(27,8): error TS1192: Module '"interface"' has no default export. -tests/cases/compiler/main.ts(28,8): error TS1192: Module '"variable"' has no default export. -tests/cases/compiler/main.ts(29,8): error TS1192: Module '"interface-variable"' has no default export. -tests/cases/compiler/main.ts(30,8): error TS1192: Module '"module"' has no default export. -tests/cases/compiler/main.ts(31,8): error TS1192: Module '"interface-module"' has no default export. -tests/cases/compiler/main.ts(32,8): error TS1192: Module '"variable-module"' has no default export. -tests/cases/compiler/main.ts(33,8): error TS1192: Module '"function"' has no default export. -tests/cases/compiler/main.ts(34,8): error TS1192: Module '"function-module"' has no default export. -tests/cases/compiler/main.ts(35,8): error TS1192: Module '"class"' has no default export. -tests/cases/compiler/main.ts(36,8): error TS1192: Module '"class-module"' has no default export. tests/cases/compiler/main.ts(39,21): error TS2497: Module '"interface"' resolves to a non-module entity and cannot be imported using this construct. tests/cases/compiler/main.ts(45,21): error TS2497: Module '"function"' resolves to a non-module entity and cannot be imported using this construct. tests/cases/compiler/main.ts(47,21): error TS2497: Module '"class"' resolves to a non-module entity and cannot be imported using this construct. @@ -41,7 +31,7 @@ tests/cases/compiler/main.ts(105,15): error TS2498: Module '"class"' uses 'expor tests/cases/compiler/main.ts(106,15): error TS2498: Module '"class-module"' uses 'export =' and cannot be used with 'export *'. -==== tests/cases/compiler/main.ts (41 errors) ==== +==== tests/cases/compiler/main.ts (31 errors) ==== /// // import-equals @@ -75,35 +65,15 @@ tests/cases/compiler/main.ts(106,15): error TS2498: Module '"class-module"' uses // default import import x1 from "interface"; - ~~ -!!! error TS1192: Module '"interface"' has no default export. import x2 from "variable"; - ~~ -!!! error TS1192: Module '"variable"' has no default export. import x3 from "interface-variable"; - ~~ -!!! error TS1192: Module '"interface-variable"' has no default export. import x4 from "module"; - ~~ -!!! error TS1192: Module '"module"' has no default export. import x5 from "interface-module"; - ~~ -!!! error TS1192: Module '"interface-module"' has no default export. import x6 from "variable-module"; - ~~ -!!! error TS1192: Module '"variable-module"' has no default export. import x7 from "function"; - ~~ -!!! error TS1192: Module '"function"' has no default export. import x8 from "function-module"; - ~~ -!!! error TS1192: Module '"function-module"' has no default export. import x9 from "class"; - ~~ -!!! error TS1192: Module '"class"' has no default export. import x0 from "class-module"; - ~~ -!!! error TS1192: Module '"class-module"' has no default export. // namespace import import * as y1 from "interface"; diff --git a/tests/baselines/reference/es6ExportEqualsInterop.types b/tests/baselines/reference/es6ExportEqualsInterop.types index 3fb08be9472ca..e9bb56a90cebd 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.types +++ b/tests/baselines/reference/es6ExportEqualsInterop.types @@ -87,31 +87,31 @@ import x1 from "interface"; >x1 : any import x2 from "variable"; ->x2 : any +>x2 : { a: number; b: number; } import x3 from "interface-variable"; ->x3 : any +>x3 : { a: number; b: number; } import x4 from "module"; ->x4 : any +>x4 : typeof z4 import x5 from "interface-module"; ->x5 : any +>x5 : typeof z5 import x6 from "variable-module"; ->x6 : any +>x6 : { a: number; b: number; } import x7 from "function"; ->x7 : any +>x7 : () => any import x8 from "function-module"; ->x8 : any +>x8 : typeof z8 import x9 from "class"; ->x9 : any +>x9 : typeof z9 import x0 from "class-module"; ->x0 : any +>x0 : typeof z0 // namespace import import * as y1 from "interface"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt deleted file mode 100644 index 604b27fd9c2b6..0000000000000 --- a/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/es6ImportDefaultBindingInEs5_1.ts(1,8): error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingInEs5_0"' has no default export. - - -==== tests/cases/compiler/es6ImportDefaultBindingInEs5_0.ts (0 errors) ==== - var a = 10; - export = a; - -==== tests/cases/compiler/es6ImportDefaultBindingInEs5_1.ts (1 errors) ==== - import defaultBinding from "./es6ImportDefaultBindingInEs5_0"; - ~~~~~~~~~~~~~~ -!!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingInEs5_0"' has no default export. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingInEs5.types b/tests/baselines/reference/es6ImportDefaultBindingInEs5.types index b22dea04a71b5..703c04397eece 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingInEs5.types +++ b/tests/baselines/reference/es6ImportDefaultBindingInEs5.types @@ -8,5 +8,5 @@ export = a; === tests/cases/compiler/es6ImportDefaultBindingInEs5_1.ts === import defaultBinding from "./es6ImportDefaultBindingInEs5_0"; ->defaultBinding : any +>defaultBinding : number diff --git a/tests/baselines/reference/importCallExpressionAsyncES3System.types b/tests/baselines/reference/importCallExpressionAsyncES3System.types index 90c981c01ca75..4f6a2bb31bea1 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES3System.types +++ b/tests/baselines/reference/importCallExpressionAsyncES3System.types @@ -3,9 +3,9 @@ export async function fn() { >fn : () => Promise const req = await import('./test') // ONE ->req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->import('./test') : Promise +>req : typeof "tests/cases/conformance/dynamicImport/test" +>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" +>import('./test') : Promise >'./test' : "./test" } @@ -16,9 +16,9 @@ export class cl1 { >m : () => Promise const req = await import('./test') // TWO ->req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->import('./test') : Promise +>req : typeof "tests/cases/conformance/dynamicImport/test" +>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" +>import('./test') : Promise >'./test' : "./test" } } @@ -32,9 +32,9 @@ export const obj = { >async () => { const req = await import('./test') // THREE } : () => Promise const req = await import('./test') // THREE ->req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->import('./test') : Promise +>req : typeof "tests/cases/conformance/dynamicImport/test" +>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" +>import('./test') : Promise >'./test' : "./test" } } @@ -51,9 +51,9 @@ export class cl2 { >async () => { const req = await import('./test') // FOUR } : () => Promise const req = await import('./test') // FOUR ->req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->import('./test') : Promise +>req : typeof "tests/cases/conformance/dynamicImport/test" +>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" +>import('./test') : Promise >'./test' : "./test" } } @@ -64,9 +64,9 @@ export const l = async () => { >async () => { const req = await import('./test') // FIVE} : () => Promise const req = await import('./test') // FIVE ->req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->import('./test') : Promise +>req : typeof "tests/cases/conformance/dynamicImport/test" +>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" +>import('./test') : Promise >'./test' : "./test" } diff --git a/tests/baselines/reference/importCallExpressionAsyncES5System.types b/tests/baselines/reference/importCallExpressionAsyncES5System.types index 90c981c01ca75..4f6a2bb31bea1 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES5System.types +++ b/tests/baselines/reference/importCallExpressionAsyncES5System.types @@ -3,9 +3,9 @@ export async function fn() { >fn : () => Promise const req = await import('./test') // ONE ->req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->import('./test') : Promise +>req : typeof "tests/cases/conformance/dynamicImport/test" +>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" +>import('./test') : Promise >'./test' : "./test" } @@ -16,9 +16,9 @@ export class cl1 { >m : () => Promise const req = await import('./test') // TWO ->req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->import('./test') : Promise +>req : typeof "tests/cases/conformance/dynamicImport/test" +>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" +>import('./test') : Promise >'./test' : "./test" } } @@ -32,9 +32,9 @@ export const obj = { >async () => { const req = await import('./test') // THREE } : () => Promise const req = await import('./test') // THREE ->req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->import('./test') : Promise +>req : typeof "tests/cases/conformance/dynamicImport/test" +>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" +>import('./test') : Promise >'./test' : "./test" } } @@ -51,9 +51,9 @@ export class cl2 { >async () => { const req = await import('./test') // FOUR } : () => Promise const req = await import('./test') // FOUR ->req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->import('./test') : Promise +>req : typeof "tests/cases/conformance/dynamicImport/test" +>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" +>import('./test') : Promise >'./test' : "./test" } } @@ -64,9 +64,9 @@ export const l = async () => { >async () => { const req = await import('./test') // FIVE} : () => Promise const req = await import('./test') // FIVE ->req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->import('./test') : Promise +>req : typeof "tests/cases/conformance/dynamicImport/test" +>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" +>import('./test') : Promise >'./test' : "./test" } diff --git a/tests/baselines/reference/importCallExpressionAsyncES6System.types b/tests/baselines/reference/importCallExpressionAsyncES6System.types index 90c981c01ca75..4f6a2bb31bea1 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES6System.types +++ b/tests/baselines/reference/importCallExpressionAsyncES6System.types @@ -3,9 +3,9 @@ export async function fn() { >fn : () => Promise const req = await import('./test') // ONE ->req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->import('./test') : Promise +>req : typeof "tests/cases/conformance/dynamicImport/test" +>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" +>import('./test') : Promise >'./test' : "./test" } @@ -16,9 +16,9 @@ export class cl1 { >m : () => Promise const req = await import('./test') // TWO ->req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->import('./test') : Promise +>req : typeof "tests/cases/conformance/dynamicImport/test" +>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" +>import('./test') : Promise >'./test' : "./test" } } @@ -32,9 +32,9 @@ export const obj = { >async () => { const req = await import('./test') // THREE } : () => Promise const req = await import('./test') // THREE ->req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->import('./test') : Promise +>req : typeof "tests/cases/conformance/dynamicImport/test" +>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" +>import('./test') : Promise >'./test' : "./test" } } @@ -51,9 +51,9 @@ export class cl2 { >async () => { const req = await import('./test') // FOUR } : () => Promise const req = await import('./test') // FOUR ->req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->import('./test') : Promise +>req : typeof "tests/cases/conformance/dynamicImport/test" +>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" +>import('./test') : Promise >'./test' : "./test" } } @@ -64,9 +64,9 @@ export const l = async () => { >async () => { const req = await import('./test') // FIVE} : () => Promise const req = await import('./test') // FIVE ->req : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" & { default: typeof "tests/cases/conformance/dynamicImport/test"; } ->import('./test') : Promise +>req : typeof "tests/cases/conformance/dynamicImport/test" +>await import('./test') : typeof "tests/cases/conformance/dynamicImport/test" +>import('./test') : Promise >'./test' : "./test" } diff --git a/tests/baselines/reference/importCallExpressionES5System.types b/tests/baselines/reference/importCallExpressionES5System.types index 02bd64142d499..e97f722b14ff5 100644 --- a/tests/baselines/reference/importCallExpressionES5System.types +++ b/tests/baselines/reference/importCallExpressionES5System.types @@ -5,41 +5,41 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; } +>p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string +>zero : typeof "tests/cases/conformance/dynamicImport/0" return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; } +>zero : typeof "tests/cases/conformance/dynamicImport/0" >foo : () => string }); export var p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } @@ -50,8 +50,8 @@ class C { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } @@ -63,8 +63,8 @@ export class D { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } diff --git a/tests/baselines/reference/importCallExpressionES6System.types b/tests/baselines/reference/importCallExpressionES6System.types index 02bd64142d499..e97f722b14ff5 100644 --- a/tests/baselines/reference/importCallExpressionES6System.types +++ b/tests/baselines/reference/importCallExpressionES6System.types @@ -5,41 +5,41 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; } +>p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string +>zero : typeof "tests/cases/conformance/dynamicImport/0" return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; } +>zero : typeof "tests/cases/conformance/dynamicImport/0" >foo : () => string }); export var p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } @@ -50,8 +50,8 @@ class C { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } @@ -63,8 +63,8 @@ export class D { >method : () => void const loadAsync = import ("./0"); ->loadAsync : Promise ->import ("./0") : Promise +>loadAsync : Promise +>import ("./0") : Promise >"./0" : "./0" } } diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsAMD.types b/tests/baselines/reference/importCallExpressionInExportEqualsAMD.types index b590130d1cff5..e9f48d1165cb6 100644 --- a/tests/baselines/reference/importCallExpressionInExportEqualsAMD.types +++ b/tests/baselines/reference/importCallExpressionInExportEqualsAMD.types @@ -6,9 +6,9 @@ export = async function() { >async function() { const something = await import("./something");} : () => Promise const something = await import("./something"); ->something : 42 ->await import("./something") : 42 ->import("./something") : Promise<42> +>something : { default: 42; } +>await import("./something") : { default: 42; } +>import("./something") : Promise<{ default: 42; }> >"./something" : "./something" }; diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsCJS.types b/tests/baselines/reference/importCallExpressionInExportEqualsCJS.types index b590130d1cff5..e9f48d1165cb6 100644 --- a/tests/baselines/reference/importCallExpressionInExportEqualsCJS.types +++ b/tests/baselines/reference/importCallExpressionInExportEqualsCJS.types @@ -6,9 +6,9 @@ export = async function() { >async function() { const something = await import("./something");} : () => Promise const something = await import("./something"); ->something : 42 ->await import("./something") : 42 ->import("./something") : Promise<42> +>something : { default: 42; } +>await import("./something") : { default: 42; } +>import("./something") : Promise<{ default: 42; }> >"./something" : "./something" }; diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsUMD.types b/tests/baselines/reference/importCallExpressionInExportEqualsUMD.types index b590130d1cff5..e9f48d1165cb6 100644 --- a/tests/baselines/reference/importCallExpressionInExportEqualsUMD.types +++ b/tests/baselines/reference/importCallExpressionInExportEqualsUMD.types @@ -6,9 +6,9 @@ export = async function() { >async function() { const something = await import("./something");} : () => Promise const something = await import("./something"); ->something : 42 ->await import("./something") : 42 ->import("./something") : Promise<42> +>something : { default: 42; } +>await import("./something") : { default: 42; } +>import("./something") : Promise<{ default: 42; }> >"./something" : "./something" }; diff --git a/tests/baselines/reference/importCallExpressionInSystem1.types b/tests/baselines/reference/importCallExpressionInSystem1.types index a82d817675388..661d27d14692e 100644 --- a/tests/baselines/reference/importCallExpressionInSystem1.types +++ b/tests/baselines/reference/importCallExpressionInSystem1.types @@ -5,40 +5,40 @@ export function foo() { return "foo"; } === tests/cases/conformance/dynamicImport/1.ts === import("./0"); ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" var p1 = import("./0"); ->p1 : Promise ->import("./0") : Promise +>p1 : Promise +>import("./0") : Promise >"./0" : "./0" p1.then(zero => { >p1.then(zero => { return zero.foo();}) : Promise ->p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->p1 : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; } +>p1.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>p1 : Promise +>then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string +>zero : typeof "tests/cases/conformance/dynamicImport/0" return zero.foo(); >zero.foo() : string >zero.foo : () => string ->zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; } +>zero : typeof "tests/cases/conformance/dynamicImport/0" >foo : () => string }); export var p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" function foo() { >foo : () => void const p2 = import("./0"); ->p2 : Promise ->import("./0") : Promise +>p2 : Promise +>import("./0") : Promise >"./0" : "./0" } diff --git a/tests/baselines/reference/importCallExpressionInSystem2.types b/tests/baselines/reference/importCallExpressionInSystem2.types index 160da81b214fb..44b17eb51fd5c 100644 --- a/tests/baselines/reference/importCallExpressionInSystem2.types +++ b/tests/baselines/reference/importCallExpressionInSystem2.types @@ -41,6 +41,6 @@ function foo(x: Promise) { foo(import("./0")); >foo(import("./0")) : void >foo : (x: Promise) => void ->import("./0") : Promise +>import("./0") : Promise >"./0" : "./0" diff --git a/tests/baselines/reference/importCallExpressionInSystem3.types b/tests/baselines/reference/importCallExpressionInSystem3.types index 08bf03fb506ad..e517be6e722f4 100644 --- a/tests/baselines/reference/importCallExpressionInSystem3.types +++ b/tests/baselines/reference/importCallExpressionInSystem3.types @@ -14,9 +14,9 @@ async function foo() { class C extends (await import("./0")).B {} >C : C >(await import("./0")).B : B ->(await import("./0")) : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; } ->await import("./0") : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; } ->import("./0") : Promise +>(await import("./0")) : typeof "tests/cases/conformance/dynamicImport/0" +>await import("./0") : typeof "tests/cases/conformance/dynamicImport/0" +>import("./0") : Promise >"./0" : "./0" >B : typeof B diff --git a/tests/baselines/reference/importCallExpressionInSystem4.types b/tests/baselines/reference/importCallExpressionInSystem4.types index c9f2b2e5211ac..156247851c914 100644 --- a/tests/baselines/reference/importCallExpressionInSystem4.types +++ b/tests/baselines/reference/importCallExpressionInSystem4.types @@ -24,27 +24,27 @@ class C { >C : C private myModule = import("./0"); ->myModule : Promise ->import("./0") : Promise +>myModule : Promise +>import("./0") : Promise >"./0" : "./0" method() { >method : () => void const loadAsync = import("./0"); ->loadAsync : Promise ->import("./0") : Promise +>loadAsync : Promise +>import("./0") : Promise >"./0" : "./0" this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise ->this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->this.myModule : Promise +>this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>this.myModule : Promise >this : this ->myModule : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => void ->Zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; } +>myModule : Promise +>then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void +>Zero : typeof "tests/cases/conformance/dynamicImport/0" console.log(Zero.foo()); >console.log(Zero.foo()) : any @@ -53,7 +53,7 @@ class C { >log : any >Zero.foo() : string >Zero.foo : () => string ->Zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; } +>Zero : typeof "tests/cases/conformance/dynamicImport/0" >foo : () => string }, async err => { @@ -68,9 +68,9 @@ class C { >err : any let one = await import("./1"); ->one : typeof "tests/cases/conformance/dynamicImport/1" & { default: typeof "tests/cases/conformance/dynamicImport/1"; } ->await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" & { default: typeof "tests/cases/conformance/dynamicImport/1"; } ->import("./1") : Promise +>one : typeof "tests/cases/conformance/dynamicImport/1" +>await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" +>import("./1") : Promise >"./1" : "./1" console.log(one.backup()); @@ -80,7 +80,7 @@ class C { >log : any >one.backup() : string >one.backup : () => string ->one : typeof "tests/cases/conformance/dynamicImport/1" & { default: typeof "tests/cases/conformance/dynamicImport/1"; } +>one : typeof "tests/cases/conformance/dynamicImport/1" >backup : () => string }); @@ -91,27 +91,27 @@ export class D { >D : D private myModule = import("./0"); ->myModule : Promise ->import("./0") : Promise +>myModule : Promise +>import("./0") : Promise >"./0" : "./0" method() { >method : () => void const loadAsync = import("./0"); ->loadAsync : Promise ->import("./0") : Promise +>loadAsync : Promise +>import("./0") : Promise >"./0" : "./0" this.myModule.then(Zero => { >this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise ->this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->this.myModule : Promise +>this.myModule.then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>this.myModule : Promise >this : this ->myModule : Promise ->then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; }) => void ->Zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; } +>myModule : Promise +>then : (onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void +>Zero : typeof "tests/cases/conformance/dynamicImport/0" console.log(Zero.foo()); >console.log(Zero.foo()) : any @@ -120,7 +120,7 @@ export class D { >log : any >Zero.foo() : string >Zero.foo : () => string ->Zero : typeof "tests/cases/conformance/dynamicImport/0" & { default: typeof "tests/cases/conformance/dynamicImport/0"; } +>Zero : typeof "tests/cases/conformance/dynamicImport/0" >foo : () => string }, async err => { @@ -135,9 +135,9 @@ export class D { >err : any let one = await import("./1"); ->one : typeof "tests/cases/conformance/dynamicImport/1" & { default: typeof "tests/cases/conformance/dynamicImport/1"; } ->await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" & { default: typeof "tests/cases/conformance/dynamicImport/1"; } ->import("./1") : Promise +>one : typeof "tests/cases/conformance/dynamicImport/1" +>await import("./1") : typeof "tests/cases/conformance/dynamicImport/1" +>import("./1") : Promise >"./1" : "./1" console.log(one.backup()); @@ -147,7 +147,7 @@ export class D { >log : any >one.backup() : string >one.backup : () => string ->one : typeof "tests/cases/conformance/dynamicImport/1" & { default: typeof "tests/cases/conformance/dynamicImport/1"; } +>one : typeof "tests/cases/conformance/dynamicImport/1" >backup : () => string }); diff --git a/tests/baselines/reference/moduleElementsInWrongContext.types b/tests/baselines/reference/moduleElementsInWrongContext.types index 0f9a802758cb8..85fffcf28f19c 100644 --- a/tests/baselines/reference/moduleElementsInWrongContext.types +++ b/tests/baselines/reference/moduleElementsInWrongContext.types @@ -55,7 +55,7 @@ >Foo : typeof Foo import bar from "ambient"; ->bar : any +>bar : typeof Foo import { baz } from "ambient"; >baz : any diff --git a/tests/baselines/reference/syntheticDefaultExportsWithDynamicImports.types b/tests/baselines/reference/syntheticDefaultExportsWithDynamicImports.types index 1c38ecc466ce5..3f1ef83a0ae9c 100644 --- a/tests/baselines/reference/syntheticDefaultExportsWithDynamicImports.types +++ b/tests/baselines/reference/syntheticDefaultExportsWithDynamicImports.types @@ -9,11 +9,11 @@ export = packageExport; === tests/cases/compiler/index.ts === import("package").then(({default: foo}) => foo(42)); >import("package").then(({default: foo}) => foo(42)) : Promise ->import("package").then : string) & { default: (x: number) => string; }, TResult2 = never>(onfulfilled?: (value: ((x: number) => string) & { default: (x: number) => string; }) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->import("package") : Promise<((x: number) => string) & { default: (x: number) => string; }> +>import("package").then : string; }, TResult2 = never>(onfulfilled?: (value: { default: (x: number) => string; }) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>import("package") : Promise<{ default: (x: number) => string; }> >"package" : "package" ->then : string) & { default: (x: number) => string; }, TResult2 = never>(onfulfilled?: (value: ((x: number) => string) & { default: (x: number) => string; }) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise ->({default: foo}) => foo(42) : ({ default: foo }: ((x: number) => string) & { default: (x: number) => string; }) => string +>then : string; }, TResult2 = never>(onfulfilled?: (value: { default: (x: number) => string; }) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>({default: foo}) => foo(42) : ({ default: foo }: { default: (x: number) => string; }) => string >default : any >foo : (x: number) => string >foo(42) : string diff --git a/tests/cases/compiler/allowSyntheticDefaultImports1.ts b/tests/cases/compiler/allowSyntheticDefaultImports1.ts index 4793da791361c..a2aadfa0b6eeb 100644 --- a/tests/cases/compiler/allowSyntheticDefaultImports1.ts +++ b/tests/cases/compiler/allowSyntheticDefaultImports1.ts @@ -4,7 +4,7 @@ import Namespace from "./b"; export var x = new Namespace.Foo(); -// @Filename: b.ts +// @Filename: b.d.ts export class Foo { member: string; } diff --git a/tests/cases/compiler/allowSyntheticDefaultImports2.ts b/tests/cases/compiler/allowSyntheticDefaultImports2.ts index 8fa004be38720..efdee90e81742 100644 --- a/tests/cases/compiler/allowSyntheticDefaultImports2.ts +++ b/tests/cases/compiler/allowSyntheticDefaultImports2.ts @@ -3,7 +3,7 @@ import Namespace from "./b"; export var x = new Namespace.Foo(); -// @Filename: b.ts +// @Filename: b.d.ts export class Foo { member: string; } \ No newline at end of file From f23d41c2acd327064e5ab61fabcfdd1d19b7fb67 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 3 Nov 2017 14:53:01 -0700 Subject: [PATCH 08/26] Put the new behavior behind a flag --- src/compiler/checker.ts | 52 ++++++++++--------- src/compiler/commandLineParser.ts | 6 +++ src/compiler/diagnosticMessages.json | 4 ++ src/compiler/transformers/module/module.ts | 17 ++++-- src/compiler/types.ts | 1 + tests/baselines/reference/APISample_jsdoc.js | 9 +--- tests/baselines/reference/APISample_linter.js | 9 +--- .../reference/APISample_transform.js | 9 +--- .../baselines/reference/APISample_watcher.js | 9 +--- .../allowImportClausesToMergeWithTypes.js | 10 +--- .../allowSyntheticDefaultImports1.js | 5 +- .../allowSyntheticDefaultImports4.js | 5 +- .../reference/ambientDeclarationsPatterns.js | 5 +- tests/baselines/reference/ambientShorthand.js | 14 +---- .../reference/ambientShorthand_reExport.js | 9 +--- .../reference/amdDependencyCommentName4.js | 12 ----- .../reference/api/tsserverlibrary.d.ts | 1 + tests/baselines/reference/api/typescript.d.ts | 1 + .../reference/asyncImportNestedYield.js | 11 +--- .../reference/augmentExportEquals3.js | 8 --- .../reference/augmentExportEquals3_1.js | 8 --- .../reference/augmentExportEquals4.js | 8 --- .../reference/augmentExportEquals4_1.js | 8 --- .../reference/augmentExportEquals6.js | 8 --- .../reference/augmentExportEquals7.types | 2 +- .../declarationEmitTypeofDefaultExport.js | 9 +--- .../baselines/reference/decoratorMetadata.js | 5 +- ...dataWithImportDeclarationNameCollision4.js | 2 +- ...dataWithImportDeclarationNameCollision5.js | 2 +- ...dataWithImportDeclarationNameCollision6.js | 2 +- ...dataWithImportDeclarationNameCollision7.js | 2 +- .../defaultExportInAwaitExpression01.js | 5 +- .../defaultExportInAwaitExpression02.js | 5 +- .../reference/defaultExportsCannotMerge01.js | 5 +- .../reference/defaultExportsCannotMerge02.js | 5 +- .../reference/defaultExportsCannotMerge03.js | 5 +- .../duplicatePackage_referenceTypes.js | 9 +--- .../reference/duplicatePackage_subModule.js | 9 +--- .../dynamicImportInDefaultExportExpression.js | 9 +--- .../dynamicImportWithNestedThis_es2015.js | 9 +--- .../dynamicImportWithNestedThis_es5.js | 9 +--- tests/baselines/reference/emptyModuleName.js | 9 +--- .../es6ExportEqualsInterop.errors.txt | 32 +++++++++++- .../reference/es6ExportEqualsInterop.js | 25 ++++----- .../reference/es6ExportEqualsInterop.types | 26 +++++----- .../reference/es6ImportDefaultBindingAmd.js | 4 -- .../reference/es6ImportDefaultBindingDts.js | 5 +- ...ultBindingFollowedWithNamedImport1InEs5.js | 15 +++--- ...ndingFollowedWithNamedImport1WithExport.js | 15 +++--- ...faultBindingFollowedWithNamedImportDts1.js | 15 +++--- ...ndingFollowedWithNamespaceBinding1InEs5.js | 5 +- ...FollowedWithNamespaceBinding1WithExport.js | 4 -- ...tBindingFollowedWithNamespaceBindingDts.js | 9 +--- ...BindingFollowedWithNamespaceBindingDts1.js | 4 -- ...indingFollowedWithNamespaceBindingInEs5.js | 9 +--- ...gFollowedWithNamespaceBindingWithExport.js | 9 +--- .../es6ImportDefaultBindingInEs5.errors.txt | 11 ++++ .../es6ImportDefaultBindingInEs5.types | 2 +- .../es6ImportDefaultBindingMergeErrors.js | 5 +- .../es6ImportDefaultBindingWithExport.js | 4 -- .../reference/es6ImportNameSpaceImport.js | 9 +--- .../reference/es6ImportNameSpaceImportAmd.js | 8 --- .../reference/es6ImportNameSpaceImportDts.js | 9 +--- .../es6ImportNameSpaceImportInEs5.js | 9 +--- .../es6ImportNameSpaceImportWithExport.js | 8 --- .../reference/exportAndImport-es3-amd.js | 4 -- .../reference/exportAndImport-es3.js | 5 +- .../reference/exportAndImport-es5-amd.js | 4 -- .../reference/exportAndImport-es5.js | 5 +- .../reference/exportDefaultAbstractClass.js | 5 +- .../reference/exportDefaultProperty.js | 11 ++-- .../reference/exportDefaultProperty2.js | 5 +- .../reference/exportEqualsDefaultProperty.js | 5 +- tests/baselines/reference/exportStar-amd.js | 4 -- tests/baselines/reference/exportStar.js | 5 +- .../reference/exportStarFromEmptyModule.js | 9 +--- .../reference/exportsAndImports4-amd.js | 14 ----- .../reference/exportsAndImports4-es6.js | 18 ++----- .../baselines/reference/exportsAndImports4.js | 18 ++----- ...sAndImportsWithContextualKeywordNames02.js | 9 +--- .../exportsAndImportsWithUnderscores1.js | 5 +- .../exportsAndImportsWithUnderscores2.js | 5 +- .../exportsAndImportsWithUnderscores3.js | 5 +- .../reference/extendsUntypedModule.js | 5 +- .../externalModuleImmutableBindings.js | 9 +--- .../importCallExpressionAsyncES3AMD.js | 17 ++---- .../importCallExpressionAsyncES3CJS.js | 17 ++---- .../importCallExpressionAsyncES3UMD.js | 17 ++---- .../importCallExpressionAsyncES5AMD.js | 17 ++---- .../importCallExpressionAsyncES5CJS.js | 17 ++---- .../importCallExpressionAsyncES5UMD.js | 17 ++---- .../importCallExpressionAsyncES6AMD.js | 17 ++---- .../importCallExpressionAsyncES6CJS.js | 17 ++---- .../importCallExpressionAsyncES6UMD.js | 17 ++---- .../importCallExpressionCheckReturntype1.js | 13 ++--- .../importCallExpressionDeclarationEmit1.js | 17 ++---- .../reference/importCallExpressionES5AMD.js | 19 +++---- .../reference/importCallExpressionES5CJS.js | 19 +++---- .../reference/importCallExpressionES5UMD.js | 19 +++---- .../reference/importCallExpressionES6AMD.js | 19 +++---- .../reference/importCallExpressionES6CJS.js | 19 +++---- .../reference/importCallExpressionES6UMD.js | 19 +++---- .../importCallExpressionGrammarError.js | 17 ++---- .../reference/importCallExpressionInAMD1.js | 15 ++---- .../reference/importCallExpressionInAMD2.js | 9 +--- .../reference/importCallExpressionInAMD3.js | 9 +--- .../reference/importCallExpressionInAMD4.js | 19 +++---- .../reference/importCallExpressionInCJS1.js | 15 ++---- .../reference/importCallExpressionInCJS2.js | 11 +--- .../reference/importCallExpressionInCJS3.js | 9 +--- .../reference/importCallExpressionInCJS4.js | 9 +--- .../reference/importCallExpressionInCJS5.js | 19 +++---- .../importCallExpressionInExportEqualsAMD.js | 9 +--- ...mportCallExpressionInExportEqualsAMD.types | 6 +-- .../importCallExpressionInExportEqualsCJS.js | 9 +--- ...mportCallExpressionInExportEqualsCJS.types | 6 +-- .../importCallExpressionInExportEqualsUMD.js | 9 +--- ...mportCallExpressionInExportEqualsUMD.types | 6 +-- .../importCallExpressionInScriptContext1.js | 9 +--- .../importCallExpressionInScriptContext2.js | 9 +--- .../reference/importCallExpressionInUMD1.js | 15 ++---- .../reference/importCallExpressionInUMD2.js | 9 +--- .../reference/importCallExpressionInUMD3.js | 9 +--- .../reference/importCallExpressionInUMD4.js | 19 +++---- .../importCallExpressionNestedAMD.js | 9 +--- .../importCallExpressionNestedAMD2.js | 11 +--- .../importCallExpressionNestedCJS.js | 9 +--- .../importCallExpressionNestedCJS2.js | 11 +--- .../importCallExpressionNestedUMD.js | 9 +--- .../importCallExpressionNestedUMD2.js | 11 +--- ...portCallExpressionNoModuleKindSpecified.js | 13 ++--- .../importCallExpressionReturnPromiseOfAny.js | 23 +++----- ...llExpressionSpecifierNotStringTypeError.js | 17 ++---- .../importCallExpressionWithTypeArgument.js | 11 +--- .../reference/importWithTrailingSlash.js | 14 ++--- .../reference/importsImplicitlyReadonly.js | 9 +--- .../inferredIndexerOnNamespaceImport.js | 9 +--- ...nvalidSyntaxNamespaceImportWithCommonjs.js | 9 +--- .../isolatedModulesImportExportElision.js | 9 +--- .../reference/isolatedModulesReExportType.js | 9 +--- .../reference/jsxImportInAttribute.js | 5 +- tests/baselines/reference/jsxViaImport.2.js | 5 +- .../reference/mergedDeclarations7.js | 9 +--- .../moduleElementsInWrongContext.types | 2 +- .../reference/moduleMergeConstructor.js | 8 --- .../reference/multipleDefaultExports01.js | 5 +- .../reference/multipleDefaultExports02.js | 5 +- tests/baselines/reference/narrowedImports.js | 14 +---- .../reference/noCrashOnImportShadowing.js | 18 +------ .../reference/outFilerootDirModuleNamesAmd.js | 5 -- .../amd/main.js | 8 --- .../node/main.js | 9 +--- .../amd/main.js | 8 --- .../node/main.js | 9 +--- .../emitDecoratorMetadataSystemJS/amd/main.js | 8 --- .../node/main.js | 9 +--- .../amd/main.js | 8 --- .../node/main.js | 9 +--- .../amd/main.js | 8 --- .../node/main.js | 9 +--- .../amd/importHigher/root.js | 8 --- .../node/importHigher/root.js | 9 +--- .../amd/maxDepthExceeded/built/root.js | 8 --- .../node/maxDepthExceeded/built/root.js | 9 +--- .../amd/maxDepthIncreased/root.js | 9 ---- .../node/maxDepthIncreased/root.js | 11 +--- .../reference/reExportDefaultExport.js | 5 +- .../reactNamespaceImportPresevation.js | 9 +--- .../requireAsFunctionInExternalModule.js | 5 +- ...ransformNestedGeneratorsWithTry.errors.txt | 37 ------------- .../transformNestedGeneratorsWithTry.js | 13 ++--- .../transformNestedGeneratorsWithTry.types | 4 +- ...ata when transpile with CommonJS option.js | 9 +--- ...spile with CommonJS option.oldTranspile.js | 9 +--- .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfigMapOptionsAreCaseInsensitive.js | 4 -- .../baselines/reference/tsxDynamicTagName5.js | 9 +--- .../baselines/reference/tsxDynamicTagName7.js | 9 +--- .../baselines/reference/tsxDynamicTagName8.js | 9 +--- .../baselines/reference/tsxDynamicTagName9.js | 9 +--- .../reference/tsxElementResolution19.js | 8 --- .../reference/tsxExternalModuleEmit1.js | 18 +------ .../reference/tsxExternalModuleEmit2.js | 5 +- .../baselines/reference/umd-augmentation-1.js | 9 +--- .../baselines/reference/umd-augmentation-3.js | 9 +--- tests/baselines/reference/umd3.js | 9 +--- tests/baselines/reference/umd4.js | 9 +--- tests/baselines/reference/umd5.js | 9 +--- tests/baselines/reference/umd8.symbols | 4 +- tests/baselines/reference/umd8.types | 8 +-- .../reference/untypedModuleImport.js | 14 +---- .../reference/untypedModuleImport_allowJs.js | 5 +- tests/baselines/reference/unusedImports11.js | 14 +---- .../fourslash/codeFixCalledES2015Import1.ts | 2 +- .../fourslash/codeFixCalledES2015Import2.ts | 2 +- .../fourslash/codeFixCalledES2015Import3.ts | 2 +- .../fourslash/codeFixCalledES2015Import4.ts | 2 +- .../fourslash/codeFixCalledES2015Import5.ts | 2 +- .../fourslash/codeFixCalledES2015Import6.ts | 2 +- .../fourslash/codeFixCalledES2015Import7.ts | 2 +- .../fourslash/codeFixCalledES2015Import8.ts | 2 +- .../fourslash/codeFixCalledES2015Import9.ts | 2 +- tests/cases/fourslash/javascriptModules24.ts | 2 +- 210 files changed, 453 insertions(+), 1493 deletions(-) create mode 100644 tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt delete mode 100644 tests/baselines/reference/transformNestedGeneratorsWithTry.errors.txt diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ce896828d50f7..4d8f91459879e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -64,7 +64,7 @@ namespace ts { const languageVersion = getEmitScriptTarget(compilerOptions); const modulekind = getEmitModuleKind(compilerOptions); const noUnusedIdentifiers = !!compilerOptions.noUnusedLocals || !!compilerOptions.noUnusedParameters; - const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : (modulekind && modulekind < ModuleKind.ES2015); + const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : compilerOptions.strictESM ? (modulekind && modulekind < ModuleKind.ES2015) : modulekind === ModuleKind.System; const strictNullChecks = getStrictOptionValue(compilerOptions, "strictNullChecks"); const strictFunctionTypes = getStrictOptionValue(compilerOptions, "strictFunctionTypes"); const noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny"); @@ -1892,30 +1892,32 @@ namespace ts { error(moduleReferenceExpression, Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } - const referenceParent = moduleReferenceExpression.parent; - if ( - (referenceParent.kind === SyntaxKind.ImportDeclaration && getNamespaceDeclarationNode(referenceParent as ImportDeclaration)) || - isImportCall(referenceParent) - ) { - const type = getTypeOfSymbol(symbol); - let sigs = getSignaturesOfStructuredType(type, SignatureKind.Call); - if (!sigs || !sigs.length) { - sigs = getSignaturesOfStructuredType(type, SignatureKind.Construct); - } - if (sigs && sigs.length) { - // Create a new symbol which has the module's type less the call and construct signatures - const result = createSymbol(symbol.flags, symbol.escapedName); - result.declarations = symbol.declarations ? symbol.declarations.slice() : []; - result.parent = symbol.parent; - result.target = symbol; - result.originatingImport = referenceParent as ImportDeclaration | ImportCall; - if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; - if (symbol.constEnumOnlyModule) result.constEnumOnlyModule = true; - if (symbol.members) result.members = cloneMap(symbol.members); - if (symbol.exports) result.exports = cloneMap(symbol.exports); - const moduleType = resolveStructuredTypeMembers(type as StructuredType); // Should already be resolved from the signature checks above - result.type = createAnonymousType(result, moduleType.members, emptyArray, emptyArray, moduleType.stringIndexInfo, moduleType.numberIndexInfo); - return result; + if (compilerOptions.strictESM) { + const referenceParent = moduleReferenceExpression.parent; + if ( + (referenceParent.kind === SyntaxKind.ImportDeclaration && getNamespaceDeclarationNode(referenceParent as ImportDeclaration)) || + isImportCall(referenceParent) + ) { + const type = getTypeOfSymbol(symbol); + let sigs = getSignaturesOfStructuredType(type, SignatureKind.Call); + if (!sigs || !sigs.length) { + sigs = getSignaturesOfStructuredType(type, SignatureKind.Construct); + } + if (sigs && sigs.length) { + // Create a new symbol which has the module's type less the call and construct signatures + const result = createSymbol(symbol.flags, symbol.escapedName); + result.declarations = symbol.declarations ? symbol.declarations.slice() : []; + result.parent = symbol.parent; + result.target = symbol; + result.originatingImport = referenceParent as ImportDeclaration | ImportCall; + if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; + if (symbol.constEnumOnlyModule) result.constEnumOnlyModule = true; + if (symbol.members) result.members = cloneMap(symbol.members); + if (symbol.exports) result.exports = cloneMap(symbol.exports); + const moduleType = resolveStructuredTypeMembers(type as StructuredType); // Should already be resolved from the signature checks above + result.type = createAnonymousType(result, moduleType.members, emptyArray, emptyArray, moduleType.stringIndexInfo, moduleType.numberIndexInfo); + return result; + } } } } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index b7003fbffd904..2163dac515964 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -390,6 +390,12 @@ namespace ts { category: Diagnostics.Module_Resolution_Options, description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, + { + name: "strictESM", + type: "boolean", + category: Diagnostics.Module_Resolution_Options, + description: Diagnostics.Create_namespace_objects_for_ECMAScript_imports_which_are_neither_callable_nor_constructable_implies_allowSyntheticDefaultImports + }, { name: "preserveSymlinks", type: "boolean", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 44df7559c6205..e719f54e3fbf0 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3442,6 +3442,10 @@ "category": "Error", "code": 7036 }, + "Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`.": { + "category": "Message", + "code": 7037 + }, "You cannot rename this element.": { "category": "Error", diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 2c42562d67001..890b5da6ea524 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -638,8 +638,12 @@ namespace ts { } } - context.requestEmitHelper(importStarHelper); - return createCall(createPropertyAccess(createNew(createIdentifier("Promise"), /*typeArguments*/ undefined, [func]), createIdentifier("then")), /*typeArguments*/ undefined, [getHelperName("__importStar")]); + const promise = createNew(createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); + if (compilerOptions.strictESM) { + context.requestEmitHelper(importStarHelper); + return createCall(createPropertyAccess(promise, createIdentifier("then")), /*typeArguments*/ undefined, [getHelperName("__importStar")]); + } + return promise; } function createImportCallExpressionCommonJS(arg: Expression | undefined, containsLexicalThis: boolean): Expression { @@ -649,8 +653,11 @@ namespace ts { // We have to wrap require in then callback so that require is done in asynchronously // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately const promiseResolveCall = createCall(createPropertyAccess(createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []); - context.requestEmitHelper(importStarHelper); - const requireCall = createCall(getHelperName("__importStar"), /*typeArguments*/ undefined, [createCall(createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : [])]); + let requireCall = createCall(createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); + if (compilerOptions.strictESM) { + context.requestEmitHelper(importStarHelper); + requireCall = createCall(getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); + } let func: FunctionExpression | ArrowFunction; if (languageVersion >= ScriptTarget.ES2015) { @@ -685,7 +692,7 @@ namespace ts { function getHelperExpressionForImport(node: ImportDeclaration, innerExpr: Expression) { - if (node.transformFlags & TransformFlags.NeverApplyImportHelper) { + if (!compilerOptions.strictESM || node.transformFlags & TransformFlags.NeverApplyImportHelper) { return innerExpr; } if (getNamespaceDeclarationNode(node)) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6ed43e1b3e433..87ef1ae3dada3 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3800,6 +3800,7 @@ namespace ts { typeRoots?: string[]; /*@internal*/ version?: boolean; /*@internal*/ watch?: boolean; + strictESM?: boolean; [option: string]: CompilerOptionsValue | JsonSourceFile | undefined; } diff --git a/tests/baselines/reference/APISample_jsdoc.js b/tests/baselines/reference/APISample_jsdoc.js index 87adffc6f3566..c74e188f38b22 100644 --- a/tests/baselines/reference/APISample_jsdoc.js +++ b/tests/baselines/reference/APISample_jsdoc.js @@ -121,15 +121,8 @@ function getSomeOtherTags(node: ts.Node) { * https://github.com/vega/ts-json-schema-generator * Please log a "breaking change" issue for any API breaking change affecting this issue */ -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var ts = __importStar(require("typescript")); +var ts = require("typescript"); // excerpted from https://github.com/YousefED/typescript-json-schema // (converted from a method and modified; for example, `this: any` to compensate, among other changes) function parseCommentsIntoDefinition(symbol, definition, otherAnnotations) { diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index 5aeea38f94636..51b208c39c902 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -70,15 +70,8 @@ fileNames.forEach(fileName => { at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#traversing-the-ast-with-a-little-linter * Please log a "breaking change" issue for any API breaking change affecting this issue */ -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var ts = __importStar(require("typescript")); +var ts = require("typescript"); function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { diff --git a/tests/baselines/reference/APISample_transform.js b/tests/baselines/reference/APISample_transform.js index 3cdb106e3926a..47f63f56e704b 100644 --- a/tests/baselines/reference/APISample_transform.js +++ b/tests/baselines/reference/APISample_transform.js @@ -22,15 +22,8 @@ console.log(JSON.stringify(result)); at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-simple-transform-function * Please log a "breaking change" issue for any API breaking change affecting this issue */ -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var ts = __importStar(require("typescript")); +var ts = require("typescript"); var source = "let x: string = 'string'"; var result = ts.transpile(source, { module: ts.ModuleKind.CommonJS }); console.log(JSON.stringify(result)); diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 7ac527aadaffe..f4d03f8f62fe3 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -116,15 +116,8 @@ watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }); at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#incremental-build-support-using-the-language-services * Please log a "breaking change" issue for any API breaking change affecting this issue */ -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var ts = __importStar(require("typescript")); +var ts = require("typescript"); function watch(rootFileNames, options) { var files = {}; // initialize the list of files diff --git a/tests/baselines/reference/allowImportClausesToMergeWithTypes.js b/tests/baselines/reference/allowImportClausesToMergeWithTypes.js index 16c5490e1496d..1679fa103723f 100644 --- a/tests/baselines/reference/allowImportClausesToMergeWithTypes.js +++ b/tests/baselines/reference/allowImportClausesToMergeWithTypes.js @@ -34,22 +34,16 @@ exports.zzz = 123; exports["default"] = exports.zzz; //// [a.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var b_1 = __importDefault(require("./b")); +var b_1 = require("./b"); exports["default"] = b_1["default"]; var x = { x: "" }; b_1["default"]; //// [index.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; var x = { x: "" }; zzz; -var b_1 = __importDefault(require("./b")); +var b_1 = require("./b"); b_1["default"]; var y = x; diff --git a/tests/baselines/reference/allowSyntheticDefaultImports1.js b/tests/baselines/reference/allowSyntheticDefaultImports1.js index ced1db946b6c2..8c5565a1fb723 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports1.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports1.js @@ -12,9 +12,6 @@ export class Foo { //// [a.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var b_1 = __importDefault(require("./b")); +var b_1 = require("./b"); exports.x = new b_1["default"].Foo(); diff --git a/tests/baselines/reference/allowSyntheticDefaultImports4.js b/tests/baselines/reference/allowSyntheticDefaultImports4.js index 8d35851c3607e..762c032b81287 100644 --- a/tests/baselines/reference/allowSyntheticDefaultImports4.js +++ b/tests/baselines/reference/allowSyntheticDefaultImports4.js @@ -13,9 +13,6 @@ export var x = new Foo(); //// [a.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var b_1 = __importDefault(require("./b")); +var b_1 = require("./b"); exports.x = new b_1["default"](); diff --git a/tests/baselines/reference/ambientDeclarationsPatterns.js b/tests/baselines/reference/ambientDeclarationsPatterns.js index 9f2419e196656..84088d11d4eb4 100644 --- a/tests/baselines/reference/ambientDeclarationsPatterns.js +++ b/tests/baselines/reference/ambientDeclarationsPatterns.js @@ -34,9 +34,6 @@ foo(fileText); //// [user.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; /// var foobarbaz_1 = require("foobarbaz"); @@ -44,5 +41,5 @@ foobarbaz_1.foo(foobarbaz_1.baz); var foosball_1 = require("foosball"); foobarbaz_1.foo(foosball_1.foos); // Works with relative file name -var file_text_1 = __importDefault(require("./file!text")); +var file_text_1 = require("./file!text"); foobarbaz_1.foo(file_text_1["default"]); diff --git a/tests/baselines/reference/ambientShorthand.js b/tests/baselines/reference/ambientShorthand.js index 88e9e1339b627..a7513e7eb585a 100644 --- a/tests/baselines/reference/ambientShorthand.js +++ b/tests/baselines/reference/ambientShorthand.js @@ -15,19 +15,9 @@ foo(bar, baz, boom); //// [user.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; /// -var jquery_1 = __importDefault(require("jquery")); -var baz = __importStar(require("fs")); +var jquery_1 = require("jquery"); +var baz = require("fs"); var boom = require("jquery"); jquery_1["default"](jquery_1.bar, baz, boom); diff --git a/tests/baselines/reference/ambientShorthand_reExport.js b/tests/baselines/reference/ambientShorthand_reExport.js index 8f58967cf97c9..6842d0f75541f 100644 --- a/tests/baselines/reference/ambientShorthand_reExport.js +++ b/tests/baselines/reference/ambientShorthand_reExport.js @@ -30,15 +30,8 @@ exports.__esModule = true; __export(require("jquery")); //// [reExportUser.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; var reExportX_1 = require("./reExportX"); -var $ = __importStar(require("./reExportAll")); +var $ = require("./reExportAll"); // '$' is not callable, it is an object. reExportX_1.x($); diff --git a/tests/baselines/reference/amdDependencyCommentName4.js b/tests/baselines/reference/amdDependencyCommentName4.js index 77f0d40f0f744..6542aa14fa299 100644 --- a/tests/baselines/reference/amdDependencyCommentName4.js +++ b/tests/baselines/reference/amdDependencyCommentName4.js @@ -25,21 +25,9 @@ import "unaliasedModule2"; /// /// /// -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "aliasedModule5", "aliasedModule6", "aliasedModule1", "aliasedModule2", "aliasedModule3", "aliasedModule4", "unaliasedModule3", "unaliasedModule4", "unaliasedModule1", "unaliasedModule2"], function (require, exports, n1, n2, r1, aliasedModule2_1, aliasedModule3_1, ns) { "use strict"; exports.__esModule = true; - aliasedModule3_1 = __importDefault(aliasedModule3_1); - ns = __importStar(ns); r1; aliasedModule2_1.p1; aliasedModule3_1["default"]; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index cffa1375608c4..ba05f5a7882ff 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2285,6 +2285,7 @@ declare namespace ts { types?: string[]; /** Paths used to compute primary types search locations */ typeRoots?: string[]; + strictESM?: boolean; [option: string]: CompilerOptionsValue | JsonSourceFile | undefined; } interface TypeAcquisition { diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 666cc34162bb2..9326e31e4f299 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2285,6 +2285,7 @@ declare namespace ts { types?: string[]; /** Paths used to compute primary types search locations */ typeRoots?: string[]; + strictESM?: boolean; [option: string]: CompilerOptionsValue | JsonSourceFile | undefined; } interface TypeAcquisition { diff --git a/tests/baselines/reference/asyncImportNestedYield.js b/tests/baselines/reference/asyncImportNestedYield.js index f5f932aa42bc5..0dd76a13ace8c 100644 --- a/tests/baselines/reference/asyncImportNestedYield.js +++ b/tests/baselines/reference/asyncImportNestedYield.js @@ -43,21 +43,14 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} function foo() { return __asyncGenerator(this, arguments, function foo_1() { return __generator(this, function (_a) { switch (_a.label) { case 0: return [4 /*yield*/, "foo"]; - case 1: return [4 /*yield*/, __await.apply(void 0, [Promise.resolve().then(function () { return __importStar(require(_a.sent())); })])]; + case 1: return [4 /*yield*/, __await.apply(void 0, [Promise.resolve().then(function () { return require(_a.sent()); })])]; case 2: - Promise.resolve().then(function () { return __importStar(require((_a.sent())["default"])); }); + Promise.resolve().then(function () { return require((_a.sent())["default"]); }); return [2 /*return*/]; } }); diff --git a/tests/baselines/reference/augmentExportEquals3.js b/tests/baselines/reference/augmentExportEquals3.js index 35ac0e08929d9..3ff5f574488e4 100644 --- a/tests/baselines/reference/augmentExportEquals3.js +++ b/tests/baselines/reference/augmentExportEquals3.js @@ -39,17 +39,9 @@ define(["require", "exports", "./file1"], function (require, exports, x) { x.b = 1; }); //// [file3.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "./file1", "./file2"], function (require, exports, x) { "use strict"; exports.__esModule = true; - x = __importStar(x); var a; var b = x.b; }); diff --git a/tests/baselines/reference/augmentExportEquals3_1.js b/tests/baselines/reference/augmentExportEquals3_1.js index 3856d3bea077c..e91ca4498dd86 100644 --- a/tests/baselines/reference/augmentExportEquals3_1.js +++ b/tests/baselines/reference/augmentExportEquals3_1.js @@ -34,17 +34,9 @@ define(["require", "exports", "file1"], function (require, exports, x) { x.b = 1; }); //// [file3.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "file1", "file2"], function (require, exports, x) { "use strict"; exports.__esModule = true; - x = __importStar(x); var a; var b = x.b; }); diff --git a/tests/baselines/reference/augmentExportEquals4.js b/tests/baselines/reference/augmentExportEquals4.js index 293bcd1077788..be6c6859ba76e 100644 --- a/tests/baselines/reference/augmentExportEquals4.js +++ b/tests/baselines/reference/augmentExportEquals4.js @@ -43,17 +43,9 @@ define(["require", "exports", "./file1"], function (require, exports, x) { x.b = 1; }); //// [file3.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "./file1", "./file2"], function (require, exports, x) { "use strict"; exports.__esModule = true; - x = __importStar(x); var a; var b = x.b; }); diff --git a/tests/baselines/reference/augmentExportEquals4_1.js b/tests/baselines/reference/augmentExportEquals4_1.js index 97d17acf67a70..cd2f54599699e 100644 --- a/tests/baselines/reference/augmentExportEquals4_1.js +++ b/tests/baselines/reference/augmentExportEquals4_1.js @@ -34,17 +34,9 @@ define(["require", "exports", "file1"], function (require, exports, x) { x.b = 1; }); //// [file3.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "file1", "file2"], function (require, exports, x) { "use strict"; exports.__esModule = true; - x = __importStar(x); var a; var b = x.b; }); diff --git a/tests/baselines/reference/augmentExportEquals6.js b/tests/baselines/reference/augmentExportEquals6.js index 86f302e1551f3..99c6c1602bd76 100644 --- a/tests/baselines/reference/augmentExportEquals6.js +++ b/tests/baselines/reference/augmentExportEquals6.js @@ -55,17 +55,9 @@ define(["require", "exports", "./file1"], function (require, exports, x) { x.B.b = 1; }); //// [file3.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "./file1", "./file2"], function (require, exports, x) { "use strict"; exports.__esModule = true; - x = __importStar(x); var a; var b = a.a; var c = x.B.b; diff --git a/tests/baselines/reference/augmentExportEquals7.types b/tests/baselines/reference/augmentExportEquals7.types index b574fe9728a00..f2870eab8dfbb 100644 --- a/tests/baselines/reference/augmentExportEquals7.types +++ b/tests/baselines/reference/augmentExportEquals7.types @@ -10,7 +10,7 @@ export = lib; === /node_modules/@types/lib-extender/index.d.ts === import * as lib from "lib"; ->lib : {} +>lib : () => void declare module "lib" { export function fn(): void; diff --git a/tests/baselines/reference/declarationEmitTypeofDefaultExport.js b/tests/baselines/reference/declarationEmitTypeofDefaultExport.js index cbc122907aad3..c4a105ca8b9c4 100644 --- a/tests/baselines/reference/declarationEmitTypeofDefaultExport.js +++ b/tests/baselines/reference/declarationEmitTypeofDefaultExport.js @@ -20,15 +20,8 @@ exports["default"] = C; ; //// [b.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var a = __importStar(require("./a")); +var a = require("./a"); exports["default"] = a["default"]; diff --git a/tests/baselines/reference/decoratorMetadata.js b/tests/baselines/reference/decoratorMetadata.js index 739ec70ec9e70..4e411154ec1fc 100644 --- a/tests/baselines/reference/decoratorMetadata.js +++ b/tests/baselines/reference/decoratorMetadata.js @@ -38,11 +38,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} Object.defineProperty(exports, "__esModule", { value: true }); -var service_1 = __importDefault(require("./service")); +var service_1 = require("./service"); var MyComponent = /** @class */ (function () { function MyComponent(Service) { this.Service = Service; diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js index f48fd79adca0b..bec7400996e00 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision4.js @@ -37,7 +37,7 @@ exports.db = db; //// [service.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var db_1 = __importDefault(require("./db")); // error no default export +var db_1 = require("./db"); // error no default export function someDecorator(target) { return target; } diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js index 79809058d3876..1985fe396df19 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision5.js @@ -37,7 +37,7 @@ exports.default = db; //// [service.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var db_1 = __importDefault(require("./db")); +var db_1 = require("./db"); function someDecorator(target) { return target; } diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js index 7967ed7e2e626..c7f9529973fe6 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision6.js @@ -37,7 +37,7 @@ exports.default = db; //// [service.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var db_1 = __importDefault(require("./db")); +var db_1 = require("./db"); function someDecorator(target) { return target; } diff --git a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js index a20a12f7c0a35..fa96fb3229ebd 100644 --- a/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js +++ b/tests/baselines/reference/decoratorMetadataWithImportDeclarationNameCollision7.js @@ -37,7 +37,7 @@ exports.default = db; //// [service.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var db_1 = __importDefault(require("./db")); +var db_1 = require("./db"); function someDecorator(target) { return target; } diff --git a/tests/baselines/reference/defaultExportInAwaitExpression01.js b/tests/baselines/reference/defaultExportInAwaitExpression01.js index 557350c63ad04..6a31461fe3cf2 100644 --- a/tests/baselines/reference/defaultExportInAwaitExpression01.js +++ b/tests/baselines/reference/defaultExportInAwaitExpression01.js @@ -36,9 +36,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -50,7 +47,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - const a_1 = __importDefault(require("./a")); + const a_1 = require("./a"); (function () { return __awaiter(this, void 0, void 0, function* () { const value = yield a_1.default; diff --git a/tests/baselines/reference/defaultExportInAwaitExpression02.js b/tests/baselines/reference/defaultExportInAwaitExpression02.js index 16c3d7eb0c889..565cfb416175c 100644 --- a/tests/baselines/reference/defaultExportInAwaitExpression02.js +++ b/tests/baselines/reference/defaultExportInAwaitExpression02.js @@ -27,11 +27,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} Object.defineProperty(exports, "__esModule", { value: true }); -const a_1 = __importDefault(require("./a")); +const a_1 = require("./a"); (function () { return __awaiter(this, void 0, void 0, function* () { const value = yield a_1.default; diff --git a/tests/baselines/reference/defaultExportsCannotMerge01.js b/tests/baselines/reference/defaultExportsCannotMerge01.js index 32cd2eaec8258..9c433ce3a2b11 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge01.js +++ b/tests/baselines/reference/defaultExportsCannotMerge01.js @@ -42,11 +42,8 @@ exports.default = Decl; })(Decl = exports.Decl || (exports.Decl = {})); //// [m2.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} Object.defineProperty(exports, "__esModule", { value: true }); -var m1_1 = __importDefault(require("m1")); +var m1_1 = require("m1"); m1_1.default(); var x; var y; diff --git a/tests/baselines/reference/defaultExportsCannotMerge02.js b/tests/baselines/reference/defaultExportsCannotMerge02.js index daa3b0fec2cdb..98bbe7b0d08e4 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge02.js +++ b/tests/baselines/reference/defaultExportsCannotMerge02.js @@ -35,11 +35,8 @@ var Decl = /** @class */ (function () { exports.default = Decl; //// [m2.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} Object.defineProperty(exports, "__esModule", { value: true }); -var m1_1 = __importDefault(require("m1")); +var m1_1 = require("m1"); m1_1.default(); var x; var y; diff --git a/tests/baselines/reference/defaultExportsCannotMerge03.js b/tests/baselines/reference/defaultExportsCannotMerge03.js index 0cbe2b5b6e438..8aa10e6eab1f5 100644 --- a/tests/baselines/reference/defaultExportsCannotMerge03.js +++ b/tests/baselines/reference/defaultExportsCannotMerge03.js @@ -35,11 +35,8 @@ var Decl = /** @class */ (function () { exports.default = Decl; //// [m2.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} Object.defineProperty(exports, "__esModule", { value: true }); -var m1_1 = __importDefault(require("m1")); +var m1_1 = require("m1"); m1_1.default(); var x; var y; diff --git a/tests/baselines/reference/duplicatePackage_referenceTypes.js b/tests/baselines/reference/duplicatePackage_referenceTypes.js index 2b69262cab5fd..2abd8090e0703 100644 --- a/tests/baselines/reference/duplicatePackage_referenceTypes.js +++ b/tests/baselines/reference/duplicatePackage_referenceTypes.js @@ -26,13 +26,6 @@ let foo: Foo = a.foo; //// [index.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var a = __importStar(require("a")); +var a = require("a"); var foo = a.foo; diff --git a/tests/baselines/reference/duplicatePackage_subModule.js b/tests/baselines/reference/duplicatePackage_subModule.js index 7ec3d7fe5e3aa..0a5793a79a2c7 100644 --- a/tests/baselines/reference/duplicatePackage_subModule.js +++ b/tests/baselines/reference/duplicatePackage_subModule.js @@ -29,13 +29,6 @@ const o: Foo = a.o; //// [index.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var a = __importStar(require("a")); +var a = require("a"); var o = a.o; diff --git a/tests/baselines/reference/dynamicImportInDefaultExportExpression.js b/tests/baselines/reference/dynamicImportInDefaultExportExpression.js index de5bd27c4741c..75e5e0d57a22e 100644 --- a/tests/baselines/reference/dynamicImportInDefaultExportExpression.js +++ b/tests/baselines/reference/dynamicImportInDefaultExportExpression.js @@ -7,16 +7,9 @@ export default { //// [dynamicImportInDefaultExportExpression.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; exports["default"] = { getInstance: function () { - return Promise.resolve().then(function () { return __importStar(require('./foo2')); }); + return Promise.resolve().then(function () { return require('./foo2'); }); } }; diff --git a/tests/baselines/reference/dynamicImportWithNestedThis_es2015.js b/tests/baselines/reference/dynamicImportWithNestedThis_es2015.js index afe7d78e172f4..4f79e0caec1c2 100644 --- a/tests/baselines/reference/dynamicImportWithNestedThis_es2015.js +++ b/tests/baselines/reference/dynamicImportWithNestedThis_es2015.js @@ -12,13 +12,6 @@ const c = new C(); c.dynamic(); //// [dynamicImportWithNestedThis_es2015.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -36,7 +29,7 @@ var __importStar = (this && this.__importStar) || function (mod) { this._path = './other'; } dynamic() { - return _a = this._path, __syncRequire ? Promise.resolve().then(() => __importStar(require(_a))) : new Promise((resolve_1, reject_1) => { require([_a], resolve_1, reject_1); }).then(__importStar); + return _a = this._path, __syncRequire ? Promise.resolve().then(() => require(_a)) : new Promise((resolve_1, reject_1) => { require([_a], resolve_1, reject_1); }); var _a; } } diff --git a/tests/baselines/reference/dynamicImportWithNestedThis_es5.js b/tests/baselines/reference/dynamicImportWithNestedThis_es5.js index e0a5415bff2ed..fcfde9e9887f1 100644 --- a/tests/baselines/reference/dynamicImportWithNestedThis_es5.js +++ b/tests/baselines/reference/dynamicImportWithNestedThis_es5.js @@ -12,13 +12,6 @@ const c = new C(); c.dynamic(); //// [dynamicImportWithNestedThis_es5.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -37,7 +30,7 @@ var __importStar = (this && this.__importStar) || function (mod) { } C.prototype.dynamic = function () { var _this = this; - return _a = this._path, __syncRequire ? Promise.resolve().then(function () { return __importStar(require(_a)); }) : new Promise(function (resolve_1, reject_1) { require([_a], resolve_1, reject_1); }).then(__importStar); + return _a = this._path, __syncRequire ? Promise.resolve().then(function () { return require(_a); }) : new Promise(function (resolve_1, reject_1) { require([_a], resolve_1, reject_1); }); var _a; }; return C; diff --git a/tests/baselines/reference/emptyModuleName.js b/tests/baselines/reference/emptyModuleName.js index 1fbcd962354ac..121ae413662b7 100644 --- a/tests/baselines/reference/emptyModuleName.js +++ b/tests/baselines/reference/emptyModuleName.js @@ -15,15 +15,8 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var A = __importStar(require("")); +var A = require(""); var B = /** @class */ (function (_super) { __extends(B, _super); function B() { diff --git a/tests/baselines/reference/es6ExportEqualsInterop.errors.txt b/tests/baselines/reference/es6ExportEqualsInterop.errors.txt index dc93c38b31b71..4675136d0817f 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.errors.txt +++ b/tests/baselines/reference/es6ExportEqualsInterop.errors.txt @@ -1,6 +1,16 @@ tests/cases/compiler/main.ts(15,1): error TS2693: 'z1' only refers to a type, but is being used as a value here. tests/cases/compiler/main.ts(21,4): error TS2339: Property 'a' does not exist on type '() => any'. tests/cases/compiler/main.ts(23,4): error TS2339: Property 'a' does not exist on type 'typeof Foo'. +tests/cases/compiler/main.ts(27,8): error TS1192: Module '"interface"' has no default export. +tests/cases/compiler/main.ts(28,8): error TS1192: Module '"variable"' has no default export. +tests/cases/compiler/main.ts(29,8): error TS1192: Module '"interface-variable"' has no default export. +tests/cases/compiler/main.ts(30,8): error TS1192: Module '"module"' has no default export. +tests/cases/compiler/main.ts(31,8): error TS1192: Module '"interface-module"' has no default export. +tests/cases/compiler/main.ts(32,8): error TS1192: Module '"variable-module"' has no default export. +tests/cases/compiler/main.ts(33,8): error TS1192: Module '"function"' has no default export. +tests/cases/compiler/main.ts(34,8): error TS1192: Module '"function-module"' has no default export. +tests/cases/compiler/main.ts(35,8): error TS1192: Module '"class"' has no default export. +tests/cases/compiler/main.ts(36,8): error TS1192: Module '"class-module"' has no default export. tests/cases/compiler/main.ts(39,21): error TS2497: Module '"interface"' resolves to a non-module entity and cannot be imported using this construct. tests/cases/compiler/main.ts(45,21): error TS2497: Module '"function"' resolves to a non-module entity and cannot be imported using this construct. tests/cases/compiler/main.ts(47,21): error TS2497: Module '"class"' resolves to a non-module entity and cannot be imported using this construct. @@ -31,7 +41,7 @@ tests/cases/compiler/main.ts(105,15): error TS2498: Module '"class"' uses 'expor tests/cases/compiler/main.ts(106,15): error TS2498: Module '"class-module"' uses 'export =' and cannot be used with 'export *'. -==== tests/cases/compiler/main.ts (31 errors) ==== +==== tests/cases/compiler/main.ts (41 errors) ==== /// // import-equals @@ -65,15 +75,35 @@ tests/cases/compiler/main.ts(106,15): error TS2498: Module '"class-module"' uses // default import import x1 from "interface"; + ~~ +!!! error TS1192: Module '"interface"' has no default export. import x2 from "variable"; + ~~ +!!! error TS1192: Module '"variable"' has no default export. import x3 from "interface-variable"; + ~~ +!!! error TS1192: Module '"interface-variable"' has no default export. import x4 from "module"; + ~~ +!!! error TS1192: Module '"module"' has no default export. import x5 from "interface-module"; + ~~ +!!! error TS1192: Module '"interface-module"' has no default export. import x6 from "variable-module"; + ~~ +!!! error TS1192: Module '"variable-module"' has no default export. import x7 from "function"; + ~~ +!!! error TS1192: Module '"function"' has no default export. import x8 from "function-module"; + ~~ +!!! error TS1192: Module '"function-module"' has no default export. import x9 from "class"; + ~~ +!!! error TS1192: Module '"class"' has no default export. import x0 from "class-module"; + ~~ +!!! error TS1192: Module '"class-module"' has no default export. // namespace import import * as y1 from "interface"; diff --git a/tests/baselines/reference/es6ExportEqualsInterop.js b/tests/baselines/reference/es6ExportEqualsInterop.js index 224c631c9b3c3..13908a29e2d6b 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.js +++ b/tests/baselines/reference/es6ExportEqualsInterop.js @@ -212,13 +212,6 @@ export * from "class-module"; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; var z2 = require("variable"); var z3 = require("interface-variable"); @@ -239,15 +232,15 @@ z7.a; z8.a; z9.a; z0.a; -var y2 = __importStar(require("variable")); -var y3 = __importStar(require("interface-variable")); -var y4 = __importStar(require("module")); -var y5 = __importStar(require("interface-module")); -var y6 = __importStar(require("variable-module")); -var y7 = __importStar(require("function")); -var y8 = __importStar(require("function-module")); -var y9 = __importStar(require("class")); -var y0 = __importStar(require("class-module")); +var y2 = require("variable"); +var y3 = require("interface-variable"); +var y4 = require("module"); +var y5 = require("interface-module"); +var y6 = require("variable-module"); +var y7 = require("function"); +var y8 = require("function-module"); +var y9 = require("class"); +var y0 = require("class-module"); y1.a; y2.a; y3.a; diff --git a/tests/baselines/reference/es6ExportEqualsInterop.types b/tests/baselines/reference/es6ExportEqualsInterop.types index e9bb56a90cebd..a20f53009c462 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.types +++ b/tests/baselines/reference/es6ExportEqualsInterop.types @@ -87,31 +87,31 @@ import x1 from "interface"; >x1 : any import x2 from "variable"; ->x2 : { a: number; b: number; } +>x2 : any import x3 from "interface-variable"; ->x3 : { a: number; b: number; } +>x3 : any import x4 from "module"; ->x4 : typeof z4 +>x4 : any import x5 from "interface-module"; ->x5 : typeof z5 +>x5 : any import x6 from "variable-module"; ->x6 : { a: number; b: number; } +>x6 : any import x7 from "function"; ->x7 : () => any +>x7 : any import x8 from "function-module"; ->x8 : typeof z8 +>x8 : any import x9 from "class"; ->x9 : typeof z9 +>x9 : any import x0 from "class-module"; ->x0 : typeof z0 +>x0 : any // namespace import import * as y1 from "interface"; @@ -136,13 +136,13 @@ import * as y7 from "function"; >y7 : () => any import * as y8 from "function-module"; ->y8 : typeof y8 +>y8 : typeof z8 import * as y9 from "class"; >y9 : typeof z9 import * as y0 from "class-module"; ->y0 : typeof y0 +>y0 : typeof z0 y1.a; >y1.a : any @@ -181,7 +181,7 @@ y7.a; y8.a; >y8.a : number ->y8 : typeof y8 +>y8 : typeof z8 >a : number y9.a; @@ -191,7 +191,7 @@ y9.a; y0.a; >y0.a : number ->y0 : typeof y0 +>y0 : typeof z0 >a : number // named import diff --git a/tests/baselines/reference/es6ImportDefaultBindingAmd.js b/tests/baselines/reference/es6ImportDefaultBindingAmd.js index dda8e9faeaf71..d8a13efa2d6ab 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingAmd.js +++ b/tests/baselines/reference/es6ImportDefaultBindingAmd.js @@ -18,13 +18,9 @@ define(["require", "exports"], function (require, exports) { exports.default = a; }); //// [es6ImportDefaultBindingAmd_1.js] -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} define(["require", "exports", "es6ImportDefaultBindingAmd_0"], function (require, exports, es6ImportDefaultBindingAmd_0_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - es6ImportDefaultBindingAmd_0_1 = __importDefault(es6ImportDefaultBindingAmd_0_1); var x = es6ImportDefaultBindingAmd_0_1.default; }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingDts.js index 734033042e2da..5011e3144fd16 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingDts.js @@ -21,11 +21,8 @@ var c = /** @class */ (function () { exports.default = c; //// [client.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} Object.defineProperty(exports, "__esModule", { value: true }); -var server_1 = __importDefault(require("./server")); +var server_1 = require("./server"); exports.x = new server_1.default(); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js index bcf7fcbb6c1c5..46e52a43135f1 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1InEs5.js @@ -26,21 +26,18 @@ var a = 10; exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamedImport1InEs5_1.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} Object.defineProperty(exports, "__esModule", { value: true }); -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_1.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_2.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_3.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_4.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_5.default; -var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0")); +var es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6 = require("./es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0"); var x = es6ImportDefaultBindingFollowedWithNamedImport1InEs5_0_6.default; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js index a500ced22a65f..02c093987d4fa 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1WithExport.js @@ -26,21 +26,18 @@ var a = 10; exports.default = a; //// [client.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} Object.defineProperty(exports, "__esModule", { value: true }); -var server_1 = __importDefault(require("./server")); +var server_1 = require("./server"); exports.x1 = server_1.default; -var server_2 = __importDefault(require("./server")); +var server_2 = require("./server"); exports.x1 = server_2.default; -var server_3 = __importDefault(require("./server")); +var server_3 = require("./server"); exports.x1 = server_3.default; -var server_4 = __importDefault(require("./server")); +var server_4 = require("./server"); exports.x1 = server_4.default; -var server_5 = __importDefault(require("./server")); +var server_5 = require("./server"); exports.x1 = server_5.default; -var server_6 = __importDefault(require("./server")); +var server_6 = require("./server"); exports.x1 = server_6.default; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js index 9c708def8ecf2..3c8b211981950 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportDts1.js @@ -29,21 +29,18 @@ var a = /** @class */ (function () { exports.default = a; //// [client.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} Object.defineProperty(exports, "__esModule", { value: true }); -var server_1 = __importDefault(require("./server")); +var server_1 = require("./server"); exports.x1 = new server_1.default(); -var server_2 = __importDefault(require("./server")); +var server_2 = require("./server"); exports.x2 = new server_2.default(); -var server_3 = __importDefault(require("./server")); +var server_3 = require("./server"); exports.x3 = new server_3.default(); -var server_4 = __importDefault(require("./server")); +var server_4 = require("./server"); exports.x4 = new server_4.default(); -var server_5 = __importDefault(require("./server")); +var server_5 = require("./server"); exports.x5 = new server_5.default(); -var server_6 = __importDefault(require("./server")); +var server_6 = require("./server"); exports.x6 = new server_6.default(); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js index 8edd09287eb62..a6217abb784ed 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.js @@ -15,11 +15,8 @@ var a = 10; exports.default = a; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} Object.defineProperty(exports, "__esModule", { value: true }); -var es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0_1 = __importDefault(require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0")); +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 13e839e7195a4..2e5ce8ebc0bf4 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1WithExport.js @@ -16,13 +16,9 @@ define(["require", "exports"], function (require, exports) { exports.default = a; }); //// [client.js] -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} define(["require", "exports", "server"], function (require, exports, server_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - server_1 = __importDefault(server_1); exports.x = server_1.default; }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js index de4e3e4215188..47b02ccd40a37 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js @@ -18,15 +18,8 @@ var a = /** @class */ (function () { exports.a = a; //// [client.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var nameSpaceBinding = __importStar(require("./server")); +var nameSpaceBinding = require("./server"); exports.x = new nameSpaceBinding.a(); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js index cfc0a5aa4e688..240e9a483cba4 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts1.js @@ -20,13 +20,9 @@ define(["require", "exports"], function (require, exports) { exports.default = a; }); //// [client.js] -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} define(["require", "exports", "server"], function (require, exports, server_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - server_1 = __importDefault(server_1); exports.x = new server_1.default(); }); diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js index 16dbd8837daf9..5586054319ad0 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js @@ -13,15 +13,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; //// [es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -var nameSpaceBinding = __importStar(require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0")); +var nameSpaceBinding = require("./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"); var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js index 981f1c8a68bb6..ded9e2811a270 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js @@ -13,15 +13,8 @@ exports.__esModule = true; exports.a = 10; //// [client.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var nameSpaceBinding = __importStar(require("./server")); +var nameSpaceBinding = require("./server"); exports.x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt b/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt new file mode 100644 index 0000000000000..604b27fd9c2b6 --- /dev/null +++ b/tests/baselines/reference/es6ImportDefaultBindingInEs5.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/es6ImportDefaultBindingInEs5_1.ts(1,8): error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingInEs5_0"' has no default export. + + +==== tests/cases/compiler/es6ImportDefaultBindingInEs5_0.ts (0 errors) ==== + var a = 10; + export = a; + +==== tests/cases/compiler/es6ImportDefaultBindingInEs5_1.ts (1 errors) ==== + import defaultBinding from "./es6ImportDefaultBindingInEs5_0"; + ~~~~~~~~~~~~~~ +!!! error TS1192: Module '"tests/cases/compiler/es6ImportDefaultBindingInEs5_0"' has no default export. \ No newline at end of file diff --git a/tests/baselines/reference/es6ImportDefaultBindingInEs5.types b/tests/baselines/reference/es6ImportDefaultBindingInEs5.types index 703c04397eece..b22dea04a71b5 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingInEs5.types +++ b/tests/baselines/reference/es6ImportDefaultBindingInEs5.types @@ -8,5 +8,5 @@ export = a; === tests/cases/compiler/es6ImportDefaultBindingInEs5_1.ts === import defaultBinding from "./es6ImportDefaultBindingInEs5_0"; ->defaultBinding : number +>defaultBinding : any diff --git a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js index bd07295b2e2c5..85f3d34cd6781 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js +++ b/tests/baselines/reference/es6ImportDefaultBindingMergeErrors.js @@ -22,10 +22,7 @@ var a = 10; exports.default = a; //// [es6ImportDefaultBindingMergeErrors_1.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} Object.defineProperty(exports, "__esModule", { value: true }); -var es6ImportDefaultBindingMergeErrors_0_1 = __importDefault(require("./es6ImportDefaultBindingMergeErrors_0")); +var es6ImportDefaultBindingMergeErrors_0_1 = require("./es6ImportDefaultBindingMergeErrors_0"); var x = es6ImportDefaultBindingMergeErrors_0_1.default; var defaultBinding2 = "hello world"; diff --git a/tests/baselines/reference/es6ImportDefaultBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingWithExport.js index 316b9ae60c595..38b391ac6d315 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingWithExport.js @@ -17,13 +17,9 @@ define(["require", "exports"], function (require, exports) { exports.default = a; }); //// [client.js] -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} define(["require", "exports", "server"], function (require, exports, server_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - server_1 = __importDefault(server_1); exports.x = server_1.default; }); diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.js b/tests/baselines/reference/es6ImportNameSpaceImport.js index a852e65507dd9..c9013259e8ead 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImport.js +++ b/tests/baselines/reference/es6ImportNameSpaceImport.js @@ -15,15 +15,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; //// [es6ImportNameSpaceImport_1.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -const nameSpaceBinding = __importStar(require("./es6ImportNameSpaceImport_0")); +const nameSpaceBinding = require("./es6ImportNameSpaceImport_0"); var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportAmd.js b/tests/baselines/reference/es6ImportNameSpaceImportAmd.js index 7904466bebcd6..44a0635f7a2db 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportAmd.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportAmd.js @@ -16,17 +16,9 @@ define(["require", "exports"], function (require, exports) { exports.a = 10; }); //// [es6ImportNameSpaceImportAmd_1.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "es6ImportNameSpaceImportAmd_0"], function (require, exports, nameSpaceBinding) { "use strict"; exports.__esModule = true; - nameSpaceBinding = __importStar(nameSpaceBinding); var x = nameSpaceBinding.a; }); diff --git a/tests/baselines/reference/es6ImportNameSpaceImportDts.js b/tests/baselines/reference/es6ImportNameSpaceImportDts.js index ffe87da9a4a1a..e39402c36332c 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportDts.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportDts.js @@ -20,15 +20,8 @@ exports.c = c; ; //// [client.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var nameSpaceBinding = __importStar(require("./server")); +var nameSpaceBinding = require("./server"); exports.x = new nameSpaceBinding.c(); diff --git a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js index 43d276562f2e0..1eced8142cb8d 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.js @@ -15,15 +15,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.a = 10; //// [es6ImportNameSpaceImportInEs5_1.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -var nameSpaceBinding = __importStar(require("./es6ImportNameSpaceImportInEs5_0")); +var nameSpaceBinding = require("./es6ImportNameSpaceImportInEs5_0"); var x = nameSpaceBinding.a; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportWithExport.js b/tests/baselines/reference/es6ImportNameSpaceImportWithExport.js index be5d391d8b70e..57aa0cf0c05c3 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportWithExport.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportWithExport.js @@ -16,17 +16,9 @@ define(["require", "exports"], function (require, exports) { exports.a = 10; }); //// [client.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "server"], function (require, exports, nameSpaceBinding) { "use strict"; exports.__esModule = true; - nameSpaceBinding = __importStar(nameSpaceBinding); exports.x = nameSpaceBinding.a; }); diff --git a/tests/baselines/reference/exportAndImport-es3-amd.js b/tests/baselines/reference/exportAndImport-es3-amd.js index 2d54be2853513..ff341f922b5f2 100644 --- a/tests/baselines/reference/exportAndImport-es3-amd.js +++ b/tests/baselines/reference/exportAndImport-es3-amd.js @@ -20,13 +20,9 @@ define(["require", "exports"], function (require, exports) { exports["default"] = f1; }); //// [m2.js] -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} define(["require", "exports", "./m1"], function (require, exports, m1_1) { "use strict"; exports.__esModule = true; - m1_1 = __importDefault(m1_1); function f2() { m1_1["default"](); } diff --git a/tests/baselines/reference/exportAndImport-es3.js b/tests/baselines/reference/exportAndImport-es3.js index 3d2ccd549735b..48b3e94a2f218 100644 --- a/tests/baselines/reference/exportAndImport-es3.js +++ b/tests/baselines/reference/exportAndImport-es3.js @@ -19,11 +19,8 @@ function f1() { exports["default"] = f1; //// [m2.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var m1_1 = __importDefault(require("./m1")); +var m1_1 = require("./m1"); function f2() { m1_1["default"](); } diff --git a/tests/baselines/reference/exportAndImport-es5-amd.js b/tests/baselines/reference/exportAndImport-es5-amd.js index b7920b4f83981..d471d76da51a6 100644 --- a/tests/baselines/reference/exportAndImport-es5-amd.js +++ b/tests/baselines/reference/exportAndImport-es5-amd.js @@ -20,13 +20,9 @@ define(["require", "exports"], function (require, exports) { exports.default = f1; }); //// [m2.js] -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} define(["require", "exports", "./m1"], function (require, exports, m1_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - m1_1 = __importDefault(m1_1); function f2() { m1_1.default(); } diff --git a/tests/baselines/reference/exportAndImport-es5.js b/tests/baselines/reference/exportAndImport-es5.js index 8f2a6b4f93447..c329b650d6e55 100644 --- a/tests/baselines/reference/exportAndImport-es5.js +++ b/tests/baselines/reference/exportAndImport-es5.js @@ -19,11 +19,8 @@ function f1() { exports.default = f1; //// [m2.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} Object.defineProperty(exports, "__esModule", { value: true }); -var m1_1 = __importDefault(require("./m1")); +var m1_1 = require("./m1"); function f2() { m1_1.default(); } diff --git a/tests/baselines/reference/exportDefaultAbstractClass.js b/tests/baselines/reference/exportDefaultAbstractClass.js index 5972c1e35d974..821a68f4699bc 100644 --- a/tests/baselines/reference/exportDefaultAbstractClass.js +++ b/tests/baselines/reference/exportDefaultAbstractClass.js @@ -51,11 +51,8 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var a_1 = __importDefault(require("./a")); +var a_1 = require("./a"); var C = /** @class */ (function (_super) { __extends(C, _super); function C() { diff --git a/tests/baselines/reference/exportDefaultProperty.js b/tests/baselines/reference/exportDefaultProperty.js index d49ca5efa87a1..c8950a20e13dd 100644 --- a/tests/baselines/reference/exportDefaultProperty.js +++ b/tests/baselines/reference/exportDefaultProperty.js @@ -63,17 +63,14 @@ exports.__esModule = true; exports["default"] = "foo".length; //// [index.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; /// -var foobar_1 = __importDefault(require("foobar")); +var foobar_1 = require("foobar"); var X = foobar_1["default"].X; -var foobarx_1 = __importDefault(require("foobarx")); +var foobarx_1 = require("foobarx"); var x = X; var x2 = foobarx_1["default"]; -var a_1 = __importDefault(require("./a")); +var a_1 = require("./a"); var b = new a_1["default"](a_1["default"].b); -var b_1 = __importDefault(require("./b")); +var b_1 = require("./b"); b_1["default"] + 1; diff --git a/tests/baselines/reference/exportDefaultProperty2.js b/tests/baselines/reference/exportDefaultProperty2.js index 32e33922222f1..2721220c07644 100644 --- a/tests/baselines/reference/exportDefaultProperty2.js +++ b/tests/baselines/reference/exportDefaultProperty2.js @@ -29,9 +29,6 @@ var C = /** @class */ (function () { exports["default"] = C.B; //// [b.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var a_1 = __importDefault(require("./a")); +var a_1 = require("./a"); var x = { c: a_1["default"] }; diff --git a/tests/baselines/reference/exportEqualsDefaultProperty.js b/tests/baselines/reference/exportEqualsDefaultProperty.js index ce4f745354fcf..3e7fc4d12afc4 100644 --- a/tests/baselines/reference/exportEqualsDefaultProperty.js +++ b/tests/baselines/reference/exportEqualsDefaultProperty.js @@ -22,9 +22,6 @@ var x = { module.exports = x; //// [imp.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var exp_1 = __importDefault(require("./exp")); +var exp_1 = require("./exp"); exp_1["default"].toExponential(2); diff --git a/tests/baselines/reference/exportStar-amd.js b/tests/baselines/reference/exportStar-amd.js index 09ada4ba71f99..7658c470e5574 100644 --- a/tests/baselines/reference/exportStar-amd.js +++ b/tests/baselines/reference/exportStar-amd.js @@ -66,13 +66,9 @@ define(["require", "exports", "./t1", "./t2", "./t3"], function (require, export __export(t3_1); }); //// [main.js] -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} define(["require", "exports", "./t4"], function (require, exports, t4_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - t4_1 = __importDefault(t4_1); t4_1.default; t4_1.x; t4_1.y; diff --git a/tests/baselines/reference/exportStar.js b/tests/baselines/reference/exportStar.js index 41ca38b5b671b..36818f8ae9b76 100644 --- a/tests/baselines/reference/exportStar.js +++ b/tests/baselines/reference/exportStar.js @@ -59,11 +59,8 @@ __export(require("./t2")); __export(require("./t3")); //// [main.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} Object.defineProperty(exports, "__esModule", { value: true }); -var t4_1 = __importDefault(require("./t4")); +var t4_1 = require("./t4"); t4_1.default; t4_1.x; t4_1.y; diff --git a/tests/baselines/reference/exportStarFromEmptyModule.js b/tests/baselines/reference/exportStarFromEmptyModule.js index 8e56d5eadc08a..2730778930d62 100644 --- a/tests/baselines/reference/exportStarFromEmptyModule.js +++ b/tests/baselines/reference/exportStarFromEmptyModule.js @@ -49,15 +49,8 @@ var A = /** @class */ (function () { exports.A = A; //// [exportStarFromEmptyModule_module4.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -var X = __importStar(require("./exportStarFromEmptyModule_module3")); +var X = require("./exportStarFromEmptyModule_module3"); var s; X.A.q; X.A.r; // Error diff --git a/tests/baselines/reference/exportsAndImports4-amd.js b/tests/baselines/reference/exportsAndImports4-amd.js index 626fa152411ee..52a41a0a4512b 100644 --- a/tests/baselines/reference/exportsAndImports4-amd.js +++ b/tests/baselines/reference/exportsAndImports4-amd.js @@ -45,23 +45,9 @@ define(["require", "exports"], function (require, exports) { exports.default = "hello"; }); //// [t3.js] -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "./t1", "./t1", "./t1", "./t1", "./t1", "./t1"], function (require, exports, a, t1_1, c, t1_2, t1_3, t1_4) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - t1_1 = __importDefault(t1_1); - c = __importStar(c); - t1_3 = __importStar(t1_3); - t1_4 = __importDefault(t1_4); exports.a = a; a.default; exports.b = t1_1.default; diff --git a/tests/baselines/reference/exportsAndImports4-es6.js b/tests/baselines/reference/exportsAndImports4-es6.js index 5b9f990397128..ee35571942f6c 100644 --- a/tests/baselines/reference/exportsAndImports4-es6.js +++ b/tests/baselines/reference/exportsAndImports4-es6.js @@ -44,35 +44,25 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = "hello"; //// [t3.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); const a = require("./t1"); exports.a = a; a.default; -const t1_1 = __importDefault(require("./t1")); +const t1_1 = require("./t1"); exports.b = t1_1.default; t1_1.default; -const c = __importStar(require("./t1")); +const c = require("./t1"); exports.c = c; c.default; const t1_2 = require("./t1"); exports.d = t1_2.default; t1_2.default; -const t1_3 = __importStar(require("./t1")), e2 = t1_3; +const t1_3 = require("./t1"), e2 = t1_3; exports.e1 = t1_3.default; exports.e2 = e2; t1_3.default; e2.default; -const t1_4 = __importDefault(require("./t1")); +const t1_4 = require("./t1"); exports.f1 = t1_4.default; exports.f2 = t1_4.default; t1_4.default; diff --git a/tests/baselines/reference/exportsAndImports4.js b/tests/baselines/reference/exportsAndImports4.js index 6a17cd920d1b7..efb93eeebf62e 100644 --- a/tests/baselines/reference/exportsAndImports4.js +++ b/tests/baselines/reference/exportsAndImports4.js @@ -44,35 +44,25 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = "hello"; //// [t3.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); var a = require("./t1"); exports.a = a; a.default; -var t1_1 = __importDefault(require("./t1")); +var t1_1 = require("./t1"); exports.b = t1_1.default; t1_1.default; -var c = __importStar(require("./t1")); +var c = require("./t1"); exports.c = c; c.default; var t1_2 = require("./t1"); exports.d = t1_2.default; t1_2.default; -var t1_3 = __importStar(require("./t1")), e2 = t1_3; +var t1_3 = require("./t1"), e2 = t1_3; exports.e1 = t1_3.default; exports.e2 = e2; t1_3.default; e2.default; -var t1_4 = __importDefault(require("./t1")); +var t1_4 = require("./t1"); exports.f1 = t1_4.default; exports.f2 = t1_4.default; t1_4.default; diff --git a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js index bf1a99503a24b..cf1976e5b03f2 100644 --- a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js +++ b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.js @@ -24,15 +24,8 @@ exports.return = as; exports.as = as; //// [t2.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -var as = __importStar(require("./t1")); +var as = require("./t1"); var x = as.as; var y = as.return; //// [t3.js] diff --git a/tests/baselines/reference/exportsAndImportsWithUnderscores1.js b/tests/baselines/reference/exportsAndImportsWithUnderscores1.js index d8bc66ee0718e..284537252fe70 100644 --- a/tests/baselines/reference/exportsAndImportsWithUnderscores1.js +++ b/tests/baselines/reference/exportsAndImportsWithUnderscores1.js @@ -24,9 +24,6 @@ exports["default"] = R = { }; //// [m2.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var m1_1 = __importDefault(require("./m1")); +var m1_1 = require("./m1"); var __ = m1_1["default"].__, _ = m1_1["default"]._, ___ = m1_1["default"].___; diff --git a/tests/baselines/reference/exportsAndImportsWithUnderscores2.js b/tests/baselines/reference/exportsAndImportsWithUnderscores2.js index 212d4f015780b..90cbc11b95b10 100644 --- a/tests/baselines/reference/exportsAndImportsWithUnderscores2.js +++ b/tests/baselines/reference/exportsAndImportsWithUnderscores2.js @@ -22,9 +22,6 @@ exports["default"] = R = { }; //// [m2.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var m1_1 = __importDefault(require("./m1")); +var m1_1 = require("./m1"); var __esmodule = m1_1["default"].__esmodule, __proto__ = m1_1["default"].__proto__; diff --git a/tests/baselines/reference/exportsAndImportsWithUnderscores3.js b/tests/baselines/reference/exportsAndImportsWithUnderscores3.js index 8004e17246cd7..0aead5f1f8bbc 100644 --- a/tests/baselines/reference/exportsAndImportsWithUnderscores3.js +++ b/tests/baselines/reference/exportsAndImportsWithUnderscores3.js @@ -24,9 +24,6 @@ exports["default"] = R = { }; //// [m2.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var m1_1 = __importDefault(require("./m1")); +var m1_1 = require("./m1"); var ___ = m1_1["default"].___, ___hello = m1_1["default"].___hello, _hi = m1_1["default"]._hi; diff --git a/tests/baselines/reference/extendsUntypedModule.js b/tests/baselines/reference/extendsUntypedModule.js index 8f246cd524708..f56c2add0fd93 100644 --- a/tests/baselines/reference/extendsUntypedModule.js +++ b/tests/baselines/reference/extendsUntypedModule.js @@ -26,11 +26,8 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var foo_1 = __importDefault(require("foo")); +var foo_1 = require("foo"); var A = /** @class */ (function (_super) { __extends(A, _super); function A() { diff --git a/tests/baselines/reference/externalModuleImmutableBindings.js b/tests/baselines/reference/externalModuleImmutableBindings.js index 4547e37c3c009..d6f5913f5d1d3 100644 --- a/tests/baselines/reference/externalModuleImmutableBindings.js +++ b/tests/baselines/reference/externalModuleImmutableBindings.js @@ -56,16 +56,9 @@ exports.__esModule = true; exports.x = 1; //// [f2.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; // all mutations below are illegal and should be fixed -var stuff = __importStar(require("./f1")); +var stuff = require("./f1"); var n = 'baz'; stuff.x = 0; stuff['x'] = 1; diff --git a/tests/baselines/reference/importCallExpressionAsyncES3AMD.js b/tests/baselines/reference/importCallExpressionAsyncES3AMD.js index 6a9968279d66b..90465c0e6e483 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES3AMD.js +++ b/tests/baselines/reference/importCallExpressionAsyncES3AMD.js @@ -64,13 +64,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports"], function (require, exports) { "use strict"; var _this = this; @@ -80,7 +73,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); }).then(__importStar)]; // ONE + case 0: return [4 /*yield*/, new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); })]; // ONE case 1: req = _a.sent() // ONE ; @@ -98,7 +91,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); }).then(__importStar)]; // TWO + case 0: return [4 /*yield*/, new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); })]; // TWO case 1: req = _a.sent() // TWO ; @@ -115,7 +108,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); }).then(__importStar)]; // THREE + case 0: return [4 /*yield*/, new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); })]; // THREE case 1: req = _a.sent() // THREE ; @@ -132,7 +125,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); }).then(__importStar)]; // FOUR + case 0: return [4 /*yield*/, new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); })]; // FOUR case 1: req = _a.sent() // FOUR ; @@ -149,7 +142,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); }).then(__importStar)]; // FIVE + case 0: return [4 /*yield*/, new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); })]; // FIVE case 1: req = _a.sent() // FIVE ; diff --git a/tests/baselines/reference/importCallExpressionAsyncES3CJS.js b/tests/baselines/reference/importCallExpressionAsyncES3CJS.js index ece5a1f2f54f7..8c3c0d1da6fc4 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES3CJS.js +++ b/tests/baselines/reference/importCallExpressionAsyncES3CJS.js @@ -65,13 +65,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} var _this = this; exports.__esModule = true; function fn() { @@ -79,7 +72,7 @@ function fn() { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // ONE + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // ONE case 1: req = _a.sent() // ONE ; @@ -97,7 +90,7 @@ var cl1 = /** @class */ (function () { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // TWO + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // TWO case 1: req = _a.sent() // TWO ; @@ -114,7 +107,7 @@ exports.obj = { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // THREE + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // THREE case 1: req = _a.sent() // THREE ; @@ -131,7 +124,7 @@ var cl2 = /** @class */ (function () { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // FOUR + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // FOUR case 1: req = _a.sent() // FOUR ; @@ -148,7 +141,7 @@ exports.l = function () { return __awaiter(_this, void 0, void 0, function () { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // FIVE + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // FIVE case 1: req = _a.sent() // FIVE ; diff --git a/tests/baselines/reference/importCallExpressionAsyncES3UMD.js b/tests/baselines/reference/importCallExpressionAsyncES3UMD.js index dfa16f9c4e206..fce2af411e035 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES3UMD.js +++ b/tests/baselines/reference/importCallExpressionAsyncES3UMD.js @@ -64,13 +64,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -89,7 +82,7 @@ var __importStar = (this && this.__importStar) || function (mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); }).then(__importStar)]; // ONE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); })]; // ONE case 1: req = _a.sent() // ONE ; @@ -107,7 +100,7 @@ var __importStar = (this && this.__importStar) || function (mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); }).then(__importStar)]; // TWO + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); })]; // TWO case 1: req = _a.sent() // TWO ; @@ -124,7 +117,7 @@ var __importStar = (this && this.__importStar) || function (mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); }).then(__importStar)]; // THREE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); })]; // THREE case 1: req = _a.sent() // THREE ; @@ -141,7 +134,7 @@ var __importStar = (this && this.__importStar) || function (mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); }).then(__importStar)]; // FOUR + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); })]; // FOUR case 1: req = _a.sent() // FOUR ; @@ -158,7 +151,7 @@ var __importStar = (this && this.__importStar) || function (mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); }).then(__importStar)]; // FIVE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); })]; // FIVE case 1: req = _a.sent() // FIVE ; diff --git a/tests/baselines/reference/importCallExpressionAsyncES5AMD.js b/tests/baselines/reference/importCallExpressionAsyncES5AMD.js index 188e21dfd6c79..3bad6ffa1f551 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES5AMD.js +++ b/tests/baselines/reference/importCallExpressionAsyncES5AMD.js @@ -64,13 +64,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports"], function (require, exports) { "use strict"; var _this = this; @@ -80,7 +73,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); }).then(__importStar)]; // ONE + case 0: return [4 /*yield*/, new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); })]; // ONE case 1: req = _a.sent() // ONE ; @@ -98,7 +91,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); }).then(__importStar)]; // TWO + case 0: return [4 /*yield*/, new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); })]; // TWO case 1: req = _a.sent() // TWO ; @@ -115,7 +108,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); }).then(__importStar)]; // THREE + case 0: return [4 /*yield*/, new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); })]; // THREE case 1: req = _a.sent() // THREE ; @@ -132,7 +125,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); }).then(__importStar)]; // FOUR + case 0: return [4 /*yield*/, new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); })]; // FOUR case 1: req = _a.sent() // FOUR ; @@ -149,7 +142,7 @@ define(["require", "exports"], function (require, exports) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); }).then(__importStar)]; // FIVE + case 0: return [4 /*yield*/, new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); })]; // FIVE case 1: req = _a.sent() // FIVE ; diff --git a/tests/baselines/reference/importCallExpressionAsyncES5CJS.js b/tests/baselines/reference/importCallExpressionAsyncES5CJS.js index 5790620917e38..87499670f3a27 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES5CJS.js +++ b/tests/baselines/reference/importCallExpressionAsyncES5CJS.js @@ -65,13 +65,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} var _this = this; Object.defineProperty(exports, "__esModule", { value: true }); function fn() { @@ -79,7 +72,7 @@ function fn() { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // ONE + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // ONE case 1: req = _a.sent() // ONE ; @@ -97,7 +90,7 @@ var cl1 = /** @class */ (function () { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // TWO + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // TWO case 1: req = _a.sent() // TWO ; @@ -114,7 +107,7 @@ exports.obj = { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // THREE + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // THREE case 1: req = _a.sent() // THREE ; @@ -131,7 +124,7 @@ var cl2 = /** @class */ (function () { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // FOUR + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // FOUR case 1: req = _a.sent() // FOUR ; @@ -148,7 +141,7 @@ exports.l = function () { return __awaiter(_this, void 0, void 0, function () { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('./test')); })]; // FIVE + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require('./test'); })]; // FIVE case 1: req = _a.sent() // FIVE ; diff --git a/tests/baselines/reference/importCallExpressionAsyncES5UMD.js b/tests/baselines/reference/importCallExpressionAsyncES5UMD.js index 747a7e6d2f072..a3b3e74db6bb4 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES5UMD.js +++ b/tests/baselines/reference/importCallExpressionAsyncES5UMD.js @@ -64,13 +64,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -89,7 +82,7 @@ var __importStar = (this && this.__importStar) || function (mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); }).then(__importStar)]; // ONE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_1, reject_1) { require(['./test'], resolve_1, reject_1); })]; // ONE case 1: req = _a.sent() // ONE ; @@ -107,7 +100,7 @@ var __importStar = (this && this.__importStar) || function (mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); }).then(__importStar)]; // TWO + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_2, reject_2) { require(['./test'], resolve_2, reject_2); })]; // TWO case 1: req = _a.sent() // TWO ; @@ -124,7 +117,7 @@ var __importStar = (this && this.__importStar) || function (mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); }).then(__importStar)]; // THREE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_3, reject_3) { require(['./test'], resolve_3, reject_3); })]; // THREE case 1: req = _a.sent() // THREE ; @@ -141,7 +134,7 @@ var __importStar = (this && this.__importStar) || function (mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); }).then(__importStar)]; // FOUR + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_4, reject_4) { require(['./test'], resolve_4, reject_4); })]; // FOUR case 1: req = _a.sent() // FOUR ; @@ -158,7 +151,7 @@ var __importStar = (this && this.__importStar) || function (mod) { var req; return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require('./test')); }) : new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); }).then(__importStar)]; // FIVE + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require('./test'); }) : new Promise(function (resolve_5, reject_5) { require(['./test'], resolve_5, reject_5); })]; // FIVE case 1: req = _a.sent() // FIVE ; diff --git a/tests/baselines/reference/importCallExpressionAsyncES6AMD.js b/tests/baselines/reference/importCallExpressionAsyncES6AMD.js index 62bc16549c1af..7f86625bbfc67 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES6AMD.js +++ b/tests/baselines/reference/importCallExpressionAsyncES6AMD.js @@ -37,46 +37,39 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function fn() { return __awaiter(this, void 0, void 0, function* () { - const req = yield new Promise((resolve_1, reject_1) => { require(['./test'], resolve_1, reject_1); }).then(__importStar); // ONE + const req = yield new Promise((resolve_1, reject_1) => { require(['./test'], resolve_1, reject_1); }); // ONE }); } exports.fn = fn; class cl1 { m() { return __awaiter(this, void 0, void 0, function* () { - const req = yield new Promise((resolve_2, reject_2) => { require(['./test'], resolve_2, reject_2); }).then(__importStar); // TWO + const req = yield new Promise((resolve_2, reject_2) => { require(['./test'], resolve_2, reject_2); }); // TWO }); } } exports.cl1 = cl1; exports.obj = { m: () => __awaiter(this, void 0, void 0, function* () { - const req = yield new Promise((resolve_3, reject_3) => { require(['./test'], resolve_3, reject_3); }).then(__importStar); // THREE + const req = yield new Promise((resolve_3, reject_3) => { require(['./test'], resolve_3, reject_3); }); // THREE }) }; class cl2 { constructor() { this.p = { m: () => __awaiter(this, void 0, void 0, function* () { - const req = yield new Promise((resolve_4, reject_4) => { require(['./test'], resolve_4, reject_4); }).then(__importStar); // FOUR + const req = yield new Promise((resolve_4, reject_4) => { require(['./test'], resolve_4, reject_4); }); // FOUR }) }; } } exports.cl2 = cl2; exports.l = () => __awaiter(this, void 0, void 0, function* () { - const req = yield new Promise((resolve_5, reject_5) => { require(['./test'], resolve_5, reject_5); }).then(__importStar); // FIVE + const req = yield new Promise((resolve_5, reject_5) => { require(['./test'], resolve_5, reject_5); }); // FIVE }); }); diff --git a/tests/baselines/reference/importCallExpressionAsyncES6CJS.js b/tests/baselines/reference/importCallExpressionAsyncES6CJS.js index 9464b8a483305..20961f9633069 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES6CJS.js +++ b/tests/baselines/reference/importCallExpressionAsyncES6CJS.js @@ -38,43 +38,36 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); function fn() { return __awaiter(this, void 0, void 0, function* () { - const req = yield Promise.resolve().then(() => __importStar(require('./test'))); // ONE + const req = yield Promise.resolve().then(() => require('./test')); // ONE }); } exports.fn = fn; class cl1 { m() { return __awaiter(this, void 0, void 0, function* () { - const req = yield Promise.resolve().then(() => __importStar(require('./test'))); // TWO + const req = yield Promise.resolve().then(() => require('./test')); // TWO }); } } exports.cl1 = cl1; exports.obj = { m: () => __awaiter(this, void 0, void 0, function* () { - const req = yield Promise.resolve().then(() => __importStar(require('./test'))); // THREE + const req = yield Promise.resolve().then(() => require('./test')); // THREE }) }; class cl2 { constructor() { this.p = { m: () => __awaiter(this, void 0, void 0, function* () { - const req = yield Promise.resolve().then(() => __importStar(require('./test'))); // FOUR + const req = yield Promise.resolve().then(() => require('./test')); // FOUR }) }; } } exports.cl2 = cl2; exports.l = () => __awaiter(this, void 0, void 0, function* () { - const req = yield Promise.resolve().then(() => __importStar(require('./test'))); // FIVE + const req = yield Promise.resolve().then(() => require('./test')); // FIVE }); diff --git a/tests/baselines/reference/importCallExpressionAsyncES6UMD.js b/tests/baselines/reference/importCallExpressionAsyncES6UMD.js index 7c305b0709455..1d4aff0267060 100644 --- a/tests/baselines/reference/importCallExpressionAsyncES6UMD.js +++ b/tests/baselines/reference/importCallExpressionAsyncES6UMD.js @@ -37,13 +37,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -58,34 +51,34 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); function fn() { return __awaiter(this, void 0, void 0, function* () { - const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_1, reject_1) => { require(['./test'], resolve_1, reject_1); }).then(__importStar); // ONE + const req = yield __syncRequire ? Promise.resolve().then(() => require('./test')) : new Promise((resolve_1, reject_1) => { require(['./test'], resolve_1, reject_1); }); // ONE }); } exports.fn = fn; class cl1 { m() { return __awaiter(this, void 0, void 0, function* () { - const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_2, reject_2) => { require(['./test'], resolve_2, reject_2); }).then(__importStar); // TWO + const req = yield __syncRequire ? Promise.resolve().then(() => require('./test')) : new Promise((resolve_2, reject_2) => { require(['./test'], resolve_2, reject_2); }); // TWO }); } } exports.cl1 = cl1; exports.obj = { m: () => __awaiter(this, void 0, void 0, function* () { - const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_3, reject_3) => { require(['./test'], resolve_3, reject_3); }).then(__importStar); // THREE + const req = yield __syncRequire ? Promise.resolve().then(() => require('./test')) : new Promise((resolve_3, reject_3) => { require(['./test'], resolve_3, reject_3); }); // THREE }) }; class cl2 { constructor() { this.p = { m: () => __awaiter(this, void 0, void 0, function* () { - const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_4, reject_4) => { require(['./test'], resolve_4, reject_4); }).then(__importStar); // FOUR + const req = yield __syncRequire ? Promise.resolve().then(() => require('./test')) : new Promise((resolve_4, reject_4) => { require(['./test'], resolve_4, reject_4); }); // FOUR }) }; } } exports.cl2 = cl2; exports.l = () => __awaiter(this, void 0, void 0, function* () { - const req = yield __syncRequire ? Promise.resolve().then(() => __importStar(require('./test'))) : new Promise((resolve_5, reject_5) => { require(['./test'], resolve_5, reject_5); }).then(__importStar); // FIVE + const req = yield __syncRequire ? Promise.resolve().then(() => require('./test')) : new Promise((resolve_5, reject_5) => { require(['./test'], resolve_5, reject_5); }); // FIVE }); }); diff --git a/tests/baselines/reference/importCallExpressionCheckReturntype1.js b/tests/baselines/reference/importCallExpressionCheckReturntype1.js index 2c056ae9dc521..3cc4893ff6720 100644 --- a/tests/baselines/reference/importCallExpressionCheckReturntype1.js +++ b/tests/baselines/reference/importCallExpressionCheckReturntype1.js @@ -29,14 +29,7 @@ class C { exports.C = C; //// [1.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -let p1 = Promise.resolve().then(() => __importStar(require("./defaultPath"))); -let p2 = Promise.resolve().then(() => __importStar(require("./defaultPath"))); -let p3 = Promise.resolve().then(() => __importStar(require("./defaultPath"))); +let p1 = Promise.resolve().then(() => require("./defaultPath")); +let p2 = Promise.resolve().then(() => require("./defaultPath")); +let p3 = Promise.resolve().then(() => require("./defaultPath")); diff --git a/tests/baselines/reference/importCallExpressionDeclarationEmit1.js b/tests/baselines/reference/importCallExpressionDeclarationEmit1.js index 978e2c7ed4124..721d85abe717a 100644 --- a/tests/baselines/reference/importCallExpressionDeclarationEmit1.js +++ b/tests/baselines/reference/importCallExpressionDeclarationEmit1.js @@ -15,19 +15,12 @@ function returnDynamicLoad(path: string) { } //// [importCallExpressionDeclarationEmit1.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} -Promise.resolve().then(() => __importStar(require(getSpecifier()))); -var p0 = Promise.resolve().then(() => __importStar(require(`${directory}\${moduleFile}`))); -var p1 = Promise.resolve().then(() => __importStar(require(getSpecifier()))); -const p2 = Promise.resolve().then(() => __importStar(require(whatToLoad ? getSpecifier() : "defaulPath"))); +Promise.resolve().then(() => require(getSpecifier())); +var p0 = Promise.resolve().then(() => require(`${directory}\${moduleFile}`)); +var p1 = Promise.resolve().then(() => require(getSpecifier())); +const p2 = Promise.resolve().then(() => require(whatToLoad ? getSpecifier() : "defaulPath")); function returnDynamicLoad(path) { - return Promise.resolve().then(() => __importStar(require(path))); + return Promise.resolve().then(() => require(path)); } diff --git a/tests/baselines/reference/importCallExpressionES5AMD.js b/tests/baselines/reference/importCallExpressionES5AMD.js index faf4bbd7c3597..eec2f378ac095 100644 --- a/tests/baselines/reference/importCallExpressionES5AMD.js +++ b/tests/baselines/reference/importCallExpressionES5AMD.js @@ -36,30 +36,23 @@ define(["require", "exports"], function (require, exports) { exports.foo = foo; }); //// [1.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }).then(__importStar); - var p1 = new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }).then(__importStar); + new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }); + var p1 = new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }); p1.then(function (zero) { return zero.foo(); }); - exports.p2 = new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }).then(__importStar); + exports.p2 = new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }); function foo() { - var p2 = new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }).then(__importStar); + var p2 = new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }); } var C = /** @class */ (function () { function C() { } C.prototype.method = function () { - var loadAsync = new Promise(function (resolve_5, reject_5) { require(["./0"], resolve_5, reject_5); }).then(__importStar); + var loadAsync = new Promise(function (resolve_5, reject_5) { require(["./0"], resolve_5, reject_5); }); }; return C; }()); @@ -67,7 +60,7 @@ define(["require", "exports"], function (require, exports) { function D() { } D.prototype.method = function () { - var loadAsync = new Promise(function (resolve_6, reject_6) { require(["./0"], resolve_6, reject_6); }).then(__importStar); + var loadAsync = new Promise(function (resolve_6, reject_6) { require(["./0"], resolve_6, reject_6); }); }; return D; }()); diff --git a/tests/baselines/reference/importCallExpressionES5CJS.js b/tests/baselines/reference/importCallExpressionES5CJS.js index fd38badf5406f..521044a10ceb7 100644 --- a/tests/baselines/reference/importCallExpressionES5CJS.js +++ b/tests/baselines/reference/importCallExpressionES5CJS.js @@ -35,28 +35,21 @@ function foo() { return "foo"; } exports.foo = foo; //// [1.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -Promise.resolve().then(function () { return __importStar(require("./0")); }); -var p1 = Promise.resolve().then(function () { return __importStar(require("./0")); }); +Promise.resolve().then(function () { return require("./0"); }); +var p1 = Promise.resolve().then(function () { return require("./0"); }); p1.then(function (zero) { return zero.foo(); }); -exports.p2 = Promise.resolve().then(function () { return __importStar(require("./0")); }); +exports.p2 = Promise.resolve().then(function () { return require("./0"); }); function foo() { - var p2 = Promise.resolve().then(function () { return __importStar(require("./0")); }); + var p2 = Promise.resolve().then(function () { return require("./0"); }); } var C = /** @class */ (function () { function C() { } C.prototype.method = function () { - var loadAsync = Promise.resolve().then(function () { return __importStar(require("./0")); }); + var loadAsync = Promise.resolve().then(function () { return require("./0"); }); }; return C; }()); @@ -64,7 +57,7 @@ var D = /** @class */ (function () { function D() { } D.prototype.method = function () { - var loadAsync = Promise.resolve().then(function () { return __importStar(require("./0")); }); + var loadAsync = Promise.resolve().then(function () { return require("./0"); }); }; return D; }()); diff --git a/tests/baselines/reference/importCallExpressionES5UMD.js b/tests/baselines/reference/importCallExpressionES5UMD.js index 72e13639c912a..0ca61909ddc0c 100644 --- a/tests/baselines/reference/importCallExpressionES5UMD.js +++ b/tests/baselines/reference/importCallExpressionES5UMD.js @@ -44,13 +44,6 @@ export class D { exports.foo = foo; }); //// [1.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -63,20 +56,20 @@ var __importStar = (this && this.__importStar) || function (mod) { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; Object.defineProperty(exports, "__esModule", { value: true }); - __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }).then(__importStar); - var p1 = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }).then(__importStar); + __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }); + var p1 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); }); p1.then(function (zero) { return zero.foo(); }); - exports.p2 = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }).then(__importStar); + exports.p2 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); }); function foo() { - var p2 = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }).then(__importStar); + var p2 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_4, reject_4) { require(["./0"], resolve_4, reject_4); }); } var C = /** @class */ (function () { function C() { } C.prototype.method = function () { - var loadAsync = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_5, reject_5) { require(["./0"], resolve_5, reject_5); }).then(__importStar); + var loadAsync = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_5, reject_5) { require(["./0"], resolve_5, reject_5); }); }; return C; }()); @@ -84,7 +77,7 @@ var __importStar = (this && this.__importStar) || function (mod) { function D() { } D.prototype.method = function () { - var loadAsync = __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./0")); }) : new Promise(function (resolve_6, reject_6) { require(["./0"], resolve_6, reject_6); }).then(__importStar); + var loadAsync = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_6, reject_6) { require(["./0"], resolve_6, reject_6); }); }; return D; }()); diff --git a/tests/baselines/reference/importCallExpressionES6AMD.js b/tests/baselines/reference/importCallExpressionES6AMD.js index fdd95ca998605..1c5430c9f04b9 100644 --- a/tests/baselines/reference/importCallExpressionES6AMD.js +++ b/tests/baselines/reference/importCallExpressionES6AMD.js @@ -36,33 +36,26 @@ define(["require", "exports"], function (require, exports) { exports.foo = foo; }); //// [1.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar); - var p1 = new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }).then(__importStar); + new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); + var p1 = new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); p1.then(zero => { return zero.foo(); }); - exports.p2 = new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }).then(__importStar); + exports.p2 = new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }); function foo() { - const p2 = new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }).then(__importStar); + const p2 = new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); } class C { method() { - const loadAsync = new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }).then(__importStar); + const loadAsync = new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }); } } class D { method() { - const loadAsync = new Promise((resolve_6, reject_6) => { require(["./0"], resolve_6, reject_6); }).then(__importStar); + const loadAsync = new Promise((resolve_6, reject_6) => { require(["./0"], resolve_6, reject_6); }); } } exports.D = D; diff --git a/tests/baselines/reference/importCallExpressionES6CJS.js b/tests/baselines/reference/importCallExpressionES6CJS.js index 140e93a24ab17..a1d8108bdeac4 100644 --- a/tests/baselines/reference/importCallExpressionES6CJS.js +++ b/tests/baselines/reference/importCallExpressionES6CJS.js @@ -35,31 +35,24 @@ function foo() { return "foo"; } exports.foo = foo; //// [1.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -Promise.resolve().then(() => __importStar(require("./0"))); -var p1 = Promise.resolve().then(() => __importStar(require("./0"))); +Promise.resolve().then(() => require("./0")); +var p1 = Promise.resolve().then(() => require("./0")); p1.then(zero => { return zero.foo(); }); -exports.p2 = Promise.resolve().then(() => __importStar(require("./0"))); +exports.p2 = Promise.resolve().then(() => require("./0")); function foo() { - const p2 = Promise.resolve().then(() => __importStar(require("./0"))); + const p2 = Promise.resolve().then(() => require("./0")); } class C { method() { - const loadAsync = Promise.resolve().then(() => __importStar(require("./0"))); + const loadAsync = Promise.resolve().then(() => require("./0")); } } class D { method() { - const loadAsync = Promise.resolve().then(() => __importStar(require("./0"))); + const loadAsync = Promise.resolve().then(() => require("./0")); } } exports.D = D; diff --git a/tests/baselines/reference/importCallExpressionES6UMD.js b/tests/baselines/reference/importCallExpressionES6UMD.js index ff31bd189c7ab..750a1a7cc0c8c 100644 --- a/tests/baselines/reference/importCallExpressionES6UMD.js +++ b/tests/baselines/reference/importCallExpressionES6UMD.js @@ -44,13 +44,6 @@ export class D { exports.foo = foo; }); //// [1.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -63,23 +56,23 @@ var __importStar = (this && this.__importStar) || function (mod) { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; Object.defineProperty(exports, "__esModule", { value: true }); - __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar); - var p1 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }).then(__importStar); + __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); + var p1 = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); p1.then(zero => { return zero.foo(); }); - exports.p2 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }).then(__importStar); + exports.p2 = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }); function foo() { - const p2 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }).then(__importStar); + const p2 = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); } class C { method() { - const loadAsync = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }).then(__importStar); + const loadAsync = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }); } } class D { method() { - const loadAsync = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_6, reject_6) => { require(["./0"], resolve_6, reject_6); }).then(__importStar); + const loadAsync = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_6, reject_6) => { require(["./0"], resolve_6, reject_6); }); } } exports.D = D; diff --git a/tests/baselines/reference/importCallExpressionGrammarError.js b/tests/baselines/reference/importCallExpressionGrammarError.js index 366b2b80ff1b7..435eab35d4ea5 100644 --- a/tests/baselines/reference/importCallExpressionGrammarError.js +++ b/tests/baselines/reference/importCallExpressionGrammarError.js @@ -11,16 +11,9 @@ const p3 = import(,); const p4 = import("pathToModule", "secondModule"); //// [importCallExpressionGrammarError.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} var a = ["./0"]; -Promise.resolve().then(() => __importStar(require(...["PathModule"]))); -var p1 = Promise.resolve().then(() => __importStar(require(...a))); -const p2 = Promise.resolve().then(() => __importStar(require())); -const p3 = Promise.resolve().then(() => __importStar(require())); -const p4 = Promise.resolve().then(() => __importStar(require("pathToModule"))); +Promise.resolve().then(() => require(...["PathModule"])); +var p1 = Promise.resolve().then(() => require(...a)); +const p2 = Promise.resolve().then(() => require()); +const p3 = Promise.resolve().then(() => require()); +const p4 = Promise.resolve().then(() => require("pathToModule")); diff --git a/tests/baselines/reference/importCallExpressionInAMD1.js b/tests/baselines/reference/importCallExpressionInAMD1.js index 26e84a57ccce8..64e5aee2ddae5 100644 --- a/tests/baselines/reference/importCallExpressionInAMD1.js +++ b/tests/baselines/reference/importCallExpressionInAMD1.js @@ -24,23 +24,16 @@ define(["require", "exports"], function (require, exports) { exports.foo = foo; }); //// [1.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar); - var p1 = new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }).then(__importStar); + new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); + var p1 = new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); p1.then(zero => { return zero.foo(); }); - exports.p2 = new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }).then(__importStar); + exports.p2 = new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }); function foo() { - const p2 = new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }).then(__importStar); + const p2 = new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); } }); diff --git a/tests/baselines/reference/importCallExpressionInAMD2.js b/tests/baselines/reference/importCallExpressionInAMD2.js index 19406c444b2a5..0d3f0e08d216e 100644 --- a/tests/baselines/reference/importCallExpressionInAMD2.js +++ b/tests/baselines/reference/importCallExpressionInAMD2.js @@ -26,13 +26,6 @@ define(["require", "exports"], function (require, exports) { exports.B = B; }); //// [2.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports"], function (require, exports) { "use strict"; // We use Promise for now as there is no way to specify shape of module object @@ -42,5 +35,5 @@ define(["require", "exports"], function (require, exports) { b.print(); }); } - foo(new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar)); + foo(new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); })); }); diff --git a/tests/baselines/reference/importCallExpressionInAMD3.js b/tests/baselines/reference/importCallExpressionInAMD3.js index 537d68cd078e4..07e7e92254189 100644 --- a/tests/baselines/reference/importCallExpressionInAMD3.js +++ b/tests/baselines/reference/importCallExpressionInAMD3.js @@ -23,17 +23,10 @@ define(["require", "exports"], function (require, exports) { exports.B = B; }); //// [2.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports"], function (require, exports) { "use strict"; async function foo() { - class C extends (await new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar)).B { + class C extends (await new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); })).B { } var c = new C(); c.print(); diff --git a/tests/baselines/reference/importCallExpressionInAMD4.js b/tests/baselines/reference/importCallExpressionInAMD4.js index 4a06bb82c8b54..2fe29e5ae065a 100644 --- a/tests/baselines/reference/importCallExpressionInAMD4.js +++ b/tests/baselines/reference/importCallExpressionInAMD4.js @@ -59,42 +59,35 @@ define(["require", "exports"], function (require, exports) { exports.backup = backup; }); //// [2.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class C { constructor() { - this.myModule = new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar); + this.myModule = new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); } method() { - const loadAsync = new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }).then(__importStar); + const loadAsync = new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { console.log(err); - let one = await new Promise((resolve_3, reject_3) => { require(["./1"], resolve_3, reject_3); }).then(__importStar); + let one = await new Promise((resolve_3, reject_3) => { require(["./1"], resolve_3, reject_3); }); console.log(one.backup()); }); } } class D { constructor() { - this.myModule = new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }).then(__importStar); + this.myModule = new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); } method() { - const loadAsync = new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }).then(__importStar); + const loadAsync = new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { console.log(err); - let one = await new Promise((resolve_6, reject_6) => { require(["./1"], resolve_6, reject_6); }).then(__importStar); + let one = await new Promise((resolve_6, reject_6) => { require(["./1"], resolve_6, reject_6); }); console.log(one.backup()); }); } diff --git a/tests/baselines/reference/importCallExpressionInCJS1.js b/tests/baselines/reference/importCallExpressionInCJS1.js index 355d2d869bc36..c814f5e567133 100644 --- a/tests/baselines/reference/importCallExpressionInCJS1.js +++ b/tests/baselines/reference/importCallExpressionInCJS1.js @@ -23,20 +23,13 @@ function foo() { return "foo"; } exports.foo = foo; //// [1.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -Promise.resolve().then(() => __importStar(require("./0"))); -var p1 = Promise.resolve().then(() => __importStar(require("./0"))); +Promise.resolve().then(() => require("./0")); +var p1 = Promise.resolve().then(() => require("./0")); p1.then(zero => { return zero.foo(); }); -exports.p2 = Promise.resolve().then(() => __importStar(require("./0"))); +exports.p2 = Promise.resolve().then(() => require("./0")); function foo() { - const p2 = Promise.resolve().then(() => __importStar(require("./0"))); + const p2 = Promise.resolve().then(() => require("./0")); } diff --git a/tests/baselines/reference/importCallExpressionInCJS2.js b/tests/baselines/reference/importCallExpressionInCJS2.js index 0a4d3c24b4103..fb559cb11937a 100644 --- a/tests/baselines/reference/importCallExpressionInCJS2.js +++ b/tests/baselines/reference/importCallExpressionInCJS2.js @@ -29,19 +29,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); function backup() { return "backup"; } exports.backup = backup; //// [2.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} async function compute(promise) { let j = await promise; if (!j) { - j = await Promise.resolve().then(() => __importStar(require("./1"))); + j = await Promise.resolve().then(() => require("./1")); return j.backup(); } return j.foo(); } -compute(Promise.resolve().then(() => __importStar(require("./0")))); +compute(Promise.resolve().then(() => require("./0"))); diff --git a/tests/baselines/reference/importCallExpressionInCJS3.js b/tests/baselines/reference/importCallExpressionInCJS3.js index 70929e011014a..616fbc9c3f9f5 100644 --- a/tests/baselines/reference/importCallExpressionInCJS3.js +++ b/tests/baselines/reference/importCallExpressionInCJS3.js @@ -24,13 +24,6 @@ class B { } exports.B = B; //// [2.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} // We use Promise for now as there is no way to specify shape of module object function foo(x) { x.then(value => { @@ -38,4 +31,4 @@ function foo(x) { b.print(); }); } -foo(Promise.resolve().then(() => __importStar(require("./0")))); +foo(Promise.resolve().then(() => require("./0"))); diff --git a/tests/baselines/reference/importCallExpressionInCJS4.js b/tests/baselines/reference/importCallExpressionInCJS4.js index b1e98619cb6cd..b88295110b83a 100644 --- a/tests/baselines/reference/importCallExpressionInCJS4.js +++ b/tests/baselines/reference/importCallExpressionInCJS4.js @@ -21,15 +21,8 @@ class B { } exports.B = B; //// [2.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} async function foo() { - class C extends (await Promise.resolve().then(() => __importStar(require("./0")))).B { + class C extends (await Promise.resolve().then(() => require("./0"))).B { } var c = new C(); c.print(); diff --git a/tests/baselines/reference/importCallExpressionInCJS5.js b/tests/baselines/reference/importCallExpressionInCJS5.js index 46a4687efa954..b32b0e52c50f7 100644 --- a/tests/baselines/reference/importCallExpressionInCJS5.js +++ b/tests/baselines/reference/importCallExpressionInCJS5.js @@ -56,40 +56,33 @@ function backup() { return "backup"; } exports.backup = backup; //// [2.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); class C { constructor() { - this.myModule = Promise.resolve().then(() => __importStar(require("./0"))); + this.myModule = Promise.resolve().then(() => require("./0")); } method() { - const loadAsync = Promise.resolve().then(() => __importStar(require("./0"))); + const loadAsync = Promise.resolve().then(() => require("./0")); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { console.log(err); - let one = await Promise.resolve().then(() => __importStar(require("./1"))); + let one = await Promise.resolve().then(() => require("./1")); console.log(one.backup()); }); } } class D { constructor() { - this.myModule = Promise.resolve().then(() => __importStar(require("./0"))); + this.myModule = Promise.resolve().then(() => require("./0")); } method() { - const loadAsync = Promise.resolve().then(() => __importStar(require("./0"))); + const loadAsync = Promise.resolve().then(() => require("./0")); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { console.log(err); - let one = await Promise.resolve().then(() => __importStar(require("./1"))); + let one = await Promise.resolve().then(() => require("./1")); console.log(one.backup()); }); } diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsAMD.js b/tests/baselines/reference/importCallExpressionInExportEqualsAMD.js index dab90d6baf75e..1fcef2bde3941 100644 --- a/tests/baselines/reference/importCallExpressionInExportEqualsAMD.js +++ b/tests/baselines/reference/importCallExpressionInExportEqualsAMD.js @@ -14,16 +14,9 @@ define(["require", "exports"], function (require, exports) { return 42; }); //// [index.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports"], function (require, exports) { "use strict"; return async function () { - const something = await new Promise((resolve_1, reject_1) => { require(["./something"], resolve_1, reject_1); }).then(__importStar); + const something = await new Promise((resolve_1, reject_1) => { require(["./something"], resolve_1, reject_1); }); }; }); diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsAMD.types b/tests/baselines/reference/importCallExpressionInExportEqualsAMD.types index e9f48d1165cb6..b590130d1cff5 100644 --- a/tests/baselines/reference/importCallExpressionInExportEqualsAMD.types +++ b/tests/baselines/reference/importCallExpressionInExportEqualsAMD.types @@ -6,9 +6,9 @@ export = async function() { >async function() { const something = await import("./something");} : () => Promise const something = await import("./something"); ->something : { default: 42; } ->await import("./something") : { default: 42; } ->import("./something") : Promise<{ default: 42; }> +>something : 42 +>await import("./something") : 42 +>import("./something") : Promise<42> >"./something" : "./something" }; diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsCJS.js b/tests/baselines/reference/importCallExpressionInExportEqualsCJS.js index b76d8ae474b64..72e3a0ec0af9b 100644 --- a/tests/baselines/reference/importCallExpressionInExportEqualsCJS.js +++ b/tests/baselines/reference/importCallExpressionInExportEqualsCJS.js @@ -13,13 +13,6 @@ export = async function() { module.exports = 42; //// [index.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} module.exports = async function () { - const something = await Promise.resolve().then(() => __importStar(require("./something"))); + const something = await Promise.resolve().then(() => require("./something")); }; diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsCJS.types b/tests/baselines/reference/importCallExpressionInExportEqualsCJS.types index e9f48d1165cb6..b590130d1cff5 100644 --- a/tests/baselines/reference/importCallExpressionInExportEqualsCJS.types +++ b/tests/baselines/reference/importCallExpressionInExportEqualsCJS.types @@ -6,9 +6,9 @@ export = async function() { >async function() { const something = await import("./something");} : () => Promise const something = await import("./something"); ->something : { default: 42; } ->await import("./something") : { default: 42; } ->import("./something") : Promise<{ default: 42; }> +>something : 42 +>await import("./something") : 42 +>import("./something") : Promise<42> >"./something" : "./something" }; diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsUMD.js b/tests/baselines/reference/importCallExpressionInExportEqualsUMD.js index 0e04e4ef88f83..5f70891b09e8e 100644 --- a/tests/baselines/reference/importCallExpressionInExportEqualsUMD.js +++ b/tests/baselines/reference/importCallExpressionInExportEqualsUMD.js @@ -22,13 +22,6 @@ export = async function() { return 42; }); //// [index.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -41,6 +34,6 @@ var __importStar = (this && this.__importStar) || function (mod) { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; return async function () { - const something = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./something"))) : new Promise((resolve_1, reject_1) => { require(["./something"], resolve_1, reject_1); }).then(__importStar)); + const something = await (__syncRequire ? Promise.resolve().then(() => require("./something")) : new Promise((resolve_1, reject_1) => { require(["./something"], resolve_1, reject_1); })); }; }); diff --git a/tests/baselines/reference/importCallExpressionInExportEqualsUMD.types b/tests/baselines/reference/importCallExpressionInExportEqualsUMD.types index e9f48d1165cb6..b590130d1cff5 100644 --- a/tests/baselines/reference/importCallExpressionInExportEqualsUMD.types +++ b/tests/baselines/reference/importCallExpressionInExportEqualsUMD.types @@ -6,9 +6,9 @@ export = async function() { >async function() { const something = await import("./something");} : () => Promise const something = await import("./something"); ->something : { default: 42; } ->await import("./something") : { default: 42; } ->import("./something") : Promise<{ default: 42; }> +>something : 42 +>await import("./something") : 42 +>import("./something") : Promise<42> >"./something" : "./something" }; diff --git a/tests/baselines/reference/importCallExpressionInScriptContext1.js b/tests/baselines/reference/importCallExpressionInScriptContext1.js index a155ef32b7301..53c6118f61bf1 100644 --- a/tests/baselines/reference/importCallExpressionInScriptContext1.js +++ b/tests/baselines/reference/importCallExpressionInScriptContext1.js @@ -13,12 +13,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); function foo() { return "foo"; } exports.foo = foo; //// [1.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} -var p1 = Promise.resolve().then(() => __importStar(require("./0"))); +var p1 = Promise.resolve().then(() => require("./0")); function arguments() { } // this is allow as the file doesn't have implicit "use strict" diff --git a/tests/baselines/reference/importCallExpressionInScriptContext2.js b/tests/baselines/reference/importCallExpressionInScriptContext2.js index 39f360ae27091..4a0d4a1bf5a98 100644 --- a/tests/baselines/reference/importCallExpressionInScriptContext2.js +++ b/tests/baselines/reference/importCallExpressionInScriptContext2.js @@ -15,12 +15,5 @@ function foo() { return "foo"; } exports.foo = foo; //// [1.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} -var p1 = Promise.resolve().then(() => __importStar(require("./0"))); +var p1 = Promise.resolve().then(() => require("./0")); function arguments() { } diff --git a/tests/baselines/reference/importCallExpressionInUMD1.js b/tests/baselines/reference/importCallExpressionInUMD1.js index 1621aafa9108d..597e68e2d6f71 100644 --- a/tests/baselines/reference/importCallExpressionInUMD1.js +++ b/tests/baselines/reference/importCallExpressionInUMD1.js @@ -32,13 +32,6 @@ function foo() { exports.foo = foo; }); //// [1.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -51,13 +44,13 @@ var __importStar = (this && this.__importStar) || function (mod) { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; Object.defineProperty(exports, "__esModule", { value: true }); - __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar); - var p1 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }).then(__importStar); + __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); + var p1 = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); p1.then(zero => { return zero.foo(); }); - exports.p2 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }).then(__importStar); + exports.p2 = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_3, reject_3) => { require(["./0"], resolve_3, reject_3); }); function foo() { - const p2 = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }).then(__importStar); + const p2 = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); } }); diff --git a/tests/baselines/reference/importCallExpressionInUMD2.js b/tests/baselines/reference/importCallExpressionInUMD2.js index 81fb031391619..516800968c13d 100644 --- a/tests/baselines/reference/importCallExpressionInUMD2.js +++ b/tests/baselines/reference/importCallExpressionInUMD2.js @@ -34,13 +34,6 @@ foo(import("./0")); exports.B = B; }); //// [2.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -59,5 +52,5 @@ var __importStar = (this && this.__importStar) || function (mod) { b.print(); }); } - foo(__syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar)); + foo(__syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); })); }); diff --git a/tests/baselines/reference/importCallExpressionInUMD3.js b/tests/baselines/reference/importCallExpressionInUMD3.js index 6c591e6fbebec..57d200ca70ca3 100644 --- a/tests/baselines/reference/importCallExpressionInUMD3.js +++ b/tests/baselines/reference/importCallExpressionInUMD3.js @@ -31,13 +31,6 @@ foo(); exports.B = B; }); //// [2.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -50,7 +43,7 @@ var __importStar = (this && this.__importStar) || function (mod) { "use strict"; var __syncRequire = typeof module === "object" && typeof module.exports === "object"; async function foo() { - class C extends (await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar))).B { + class C extends (await (__syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }))).B { } var c = new C(); c.print(); diff --git a/tests/baselines/reference/importCallExpressionInUMD4.js b/tests/baselines/reference/importCallExpressionInUMD4.js index 5fd5e16f6c735..70a574f03028e 100644 --- a/tests/baselines/reference/importCallExpressionInUMD4.js +++ b/tests/baselines/reference/importCallExpressionInUMD4.js @@ -75,13 +75,6 @@ export class D { exports.backup = backup; }); //// [2.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -96,30 +89,30 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); class C { constructor() { - this.myModule = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }).then(__importStar); + this.myModule = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_1, reject_1) => { require(["./0"], resolve_1, reject_1); }); } method() { - const loadAsync = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }).then(__importStar); + const loadAsync = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_2, reject_2) => { require(["./0"], resolve_2, reject_2); }); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { console.log(err); - let one = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./1"))) : new Promise((resolve_3, reject_3) => { require(["./1"], resolve_3, reject_3); }).then(__importStar)); + let one = await (__syncRequire ? Promise.resolve().then(() => require("./1")) : new Promise((resolve_3, reject_3) => { require(["./1"], resolve_3, reject_3); })); console.log(one.backup()); }); } } class D { constructor() { - this.myModule = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }).then(__importStar); + this.myModule = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_4, reject_4) => { require(["./0"], resolve_4, reject_4); }); } method() { - const loadAsync = __syncRequire ? Promise.resolve().then(() => __importStar(require("./0"))) : new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }).then(__importStar); + const loadAsync = __syncRequire ? Promise.resolve().then(() => require("./0")) : new Promise((resolve_5, reject_5) => { require(["./0"], resolve_5, reject_5); }); this.myModule.then(Zero => { console.log(Zero.foo()); }, async (err) => { console.log(err); - let one = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./1"))) : new Promise((resolve_6, reject_6) => { require(["./1"], resolve_6, reject_6); }).then(__importStar)); + let one = await (__syncRequire ? Promise.resolve().then(() => require("./1")) : new Promise((resolve_6, reject_6) => { require(["./1"], resolve_6, reject_6); })); console.log(one.backup()); }); } diff --git a/tests/baselines/reference/importCallExpressionNestedAMD.js b/tests/baselines/reference/importCallExpressionNestedAMD.js index 66b2b0f36a0c5..dc211d4400378 100644 --- a/tests/baselines/reference/importCallExpressionNestedAMD.js +++ b/tests/baselines/reference/importCallExpressionNestedAMD.js @@ -23,18 +23,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports"], function (require, exports) { "use strict"; function foo() { return __awaiter(this, void 0, void 0, function* () { - return yield new Promise((resolve_1, reject_1) => { require([(yield new Promise((resolve_2, reject_2) => { require(["./foo"], resolve_2, reject_2); }).then(__importStar)).default], resolve_1, reject_1); }).then(__importStar); + return yield new Promise((resolve_1, reject_1) => { require([(yield new Promise((resolve_2, reject_2) => { require(["./foo"], resolve_2, reject_2); })).default], resolve_1, reject_1); }); }); } }); diff --git a/tests/baselines/reference/importCallExpressionNestedAMD2.js b/tests/baselines/reference/importCallExpressionNestedAMD2.js index e5db7bb7cb6a7..1e159af2180a6 100644 --- a/tests/baselines/reference/importCallExpressionNestedAMD2.js +++ b/tests/baselines/reference/importCallExpressionNestedAMD2.js @@ -50,21 +50,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports"], function (require, exports) { "use strict"; function foo() { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, new Promise(function (resolve_1, reject_1) { require(["./foo"], resolve_1, reject_1); }).then(__importStar)]; - case 1: return [4 /*yield*/, new Promise(function (resolve_2, reject_2) { require([(_a.sent()).default], resolve_2, reject_2); }).then(__importStar)]; + case 0: return [4 /*yield*/, new Promise(function (resolve_1, reject_1) { require(["./foo"], resolve_1, reject_1); })]; + case 1: return [4 /*yield*/, new Promise(function (resolve_2, reject_2) { require([(_a.sent()).default], resolve_2, reject_2); })]; case 2: return [2 /*return*/, _a.sent()]; } }); diff --git a/tests/baselines/reference/importCallExpressionNestedCJS.js b/tests/baselines/reference/importCallExpressionNestedCJS.js index ccb0862913152..07c0f234bf7dc 100644 --- a/tests/baselines/reference/importCallExpressionNestedCJS.js +++ b/tests/baselines/reference/importCallExpressionNestedCJS.js @@ -21,15 +21,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} function foo() { return __awaiter(this, void 0, void 0, function* () { - return yield Promise.resolve().then(() => __importStar(require((yield Promise.resolve().then(() => __importStar(require("./foo")))).default))); + return yield Promise.resolve().then(() => require((yield Promise.resolve().then(() => require("./foo"))).default)); }); } diff --git a/tests/baselines/reference/importCallExpressionNestedCJS2.js b/tests/baselines/reference/importCallExpressionNestedCJS2.js index eda6dacb0c824..c76044ec05c2e 100644 --- a/tests/baselines/reference/importCallExpressionNestedCJS2.js +++ b/tests/baselines/reference/importCallExpressionNestedCJS2.js @@ -48,19 +48,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} function foo() { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./foo")); })]; - case 1: return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require((_a.sent()).default)); })]; + case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require("./foo"); })]; + case 1: return [4 /*yield*/, Promise.resolve().then(function () { return require((_a.sent()).default); })]; case 2: return [2 /*return*/, _a.sent()]; } }); diff --git a/tests/baselines/reference/importCallExpressionNestedUMD.js b/tests/baselines/reference/importCallExpressionNestedUMD.js index be1b520658c43..0b1d20af8a421 100644 --- a/tests/baselines/reference/importCallExpressionNestedUMD.js +++ b/tests/baselines/reference/importCallExpressionNestedUMD.js @@ -31,13 +31,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -51,7 +44,7 @@ var __importStar = (this && this.__importStar) || function (mod) { var __syncRequire = typeof module === "object" && typeof module.exports === "object"; function foo() { return __awaiter(this, void 0, void 0, function* () { - return yield _a = (yield __syncRequire ? Promise.resolve().then(() => __importStar(require("./foo"))) : new Promise((resolve_1, reject_1) => { require(["./foo"], resolve_1, reject_1); }).then(__importStar)).default, __syncRequire ? Promise.resolve().then(() => __importStar(require(_a))) : new Promise((resolve_2, reject_2) => { require([_a], resolve_2, reject_2); }).then(__importStar); + return yield _a = (yield __syncRequire ? Promise.resolve().then(() => require("./foo")) : new Promise((resolve_1, reject_1) => { require(["./foo"], resolve_1, reject_1); })).default, __syncRequire ? Promise.resolve().then(() => require(_a)) : new Promise((resolve_2, reject_2) => { require([_a], resolve_2, reject_2); }); var _a; }); } diff --git a/tests/baselines/reference/importCallExpressionNestedUMD2.js b/tests/baselines/reference/importCallExpressionNestedUMD2.js index 07f795c17451d..86fd0bfa8f1f8 100644 --- a/tests/baselines/reference/importCallExpressionNestedUMD2.js +++ b/tests/baselines/reference/importCallExpressionNestedUMD2.js @@ -58,13 +58,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); @@ -80,8 +73,8 @@ var __importStar = (this && this.__importStar) || function (mod) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return __importStar(require("./foo")); }) : new Promise(function (resolve_1, reject_1) { require(["./foo"], resolve_1, reject_1); }).then(__importStar)]; - case 1: return [4 /*yield*/, (_b = (_a.sent()).default, __syncRequire ? Promise.resolve().then(function () { return __importStar(require(_b)); }) : new Promise(function (resolve_2, reject_2) { require([_b], resolve_2, reject_2); }).then(__importStar))]; + case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require("./foo"); }) : new Promise(function (resolve_1, reject_1) { require(["./foo"], resolve_1, reject_1); })]; + case 1: return [4 /*yield*/, (_b = (_a.sent()).default, __syncRequire ? Promise.resolve().then(function () { return require(_b); }) : new Promise(function (resolve_2, reject_2) { require([_b], resolve_2, reject_2); }))]; case 2: return [2 /*return*/, _a.sent()]; } var _b; diff --git a/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.js b/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.js index 7b467a669d3dc..3135a4066fd39 100644 --- a/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.js +++ b/tests/baselines/reference/importCallExpressionNoModuleKindSpecified.js @@ -79,20 +79,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} var C = /** @class */ (function () { function C() { - this.myModule = Promise.resolve().then(function () { return __importStar(require("./0")); }); + this.myModule = Promise.resolve().then(function () { return require("./0"); }); } C.prototype.method = function () { var _this = this; - var loadAsync = Promise.resolve().then(function () { return __importStar(require("./0")); }); + var loadAsync = Promise.resolve().then(function () { return require("./0"); }); this.myModule.then(function (Zero) { console.log(Zero.foo()); }, function (err) { return __awaiter(_this, void 0, void 0, function () { @@ -101,7 +94,7 @@ var C = /** @class */ (function () { switch (_a.label) { case 0: console.log(err); - return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require("./1")); })]; + return [4 /*yield*/, Promise.resolve().then(function () { return require("./1"); })]; case 1: one = _a.sent(); console.log(one.backup()); diff --git a/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.js b/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.js index 16367f49510a7..8c94510b6095b 100644 --- a/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.js +++ b/tests/baselines/reference/importCallExpressionReturnPromiseOfAny.js @@ -41,28 +41,21 @@ class C { exports.C = C; //// [1.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -Promise.resolve().then(() => __importStar(require(`${directory}\${moduleFile}`))); -Promise.resolve().then(() => __importStar(require(getSpecifier()))); -var p1 = Promise.resolve().then(() => __importStar(require(ValidSomeCondition() ? "./0" : "externalModule"))); -var p1 = Promise.resolve().then(() => __importStar(require(getSpecifier()))); -var p11 = Promise.resolve().then(() => __importStar(require(getSpecifier()))); -const p2 = Promise.resolve().then(() => __importStar(require(whatToLoad ? getSpecifier() : "defaulPath"))); +Promise.resolve().then(() => require(`${directory}\${moduleFile}`)); +Promise.resolve().then(() => require(getSpecifier())); +var p1 = Promise.resolve().then(() => require(ValidSomeCondition() ? "./0" : "externalModule")); +var p1 = Promise.resolve().then(() => require(getSpecifier())); +var p11 = Promise.resolve().then(() => require(getSpecifier())); +const p2 = Promise.resolve().then(() => require(whatToLoad ? getSpecifier() : "defaulPath")); p1.then(zero => { return zero.foo(); // ok, zero is any }); let j; -var p3 = Promise.resolve().then(() => __importStar(require(j = getSpecifier()))); +var p3 = Promise.resolve().then(() => require(j = getSpecifier())); function* loadModule(directories) { for (const directory of directories) { const path = `${directory}\moduleFile`; - Promise.resolve().then(() => __importStar(require(yield path))); + Promise.resolve().then(() => require(yield path)); } } diff --git a/tests/baselines/reference/importCallExpressionSpecifierNotStringTypeError.js b/tests/baselines/reference/importCallExpressionSpecifierNotStringTypeError.js index f47755acac0d3..5e2ace1c4017f 100644 --- a/tests/baselines/reference/importCallExpressionSpecifierNotStringTypeError.js +++ b/tests/baselines/reference/importCallExpressionSpecifierNotStringTypeError.js @@ -14,19 +14,12 @@ var p3 = import(["path1", "path2"]); var p4 = import(()=>"PathToModule"); //// [importCallExpressionSpecifierNotStringTypeError.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} // Error specifier is not assignable to string -Promise.resolve().then(() => __importStar(require(getSpecifier()))); -var p1 = Promise.resolve().then(() => __importStar(require(getSpecifier()))); -const p2 = Promise.resolve().then(() => __importStar(require(whatToLoad ? getSpecifier() : "defaulPath"))); +Promise.resolve().then(() => require(getSpecifier())); +var p1 = Promise.resolve().then(() => require(getSpecifier())); +const p2 = Promise.resolve().then(() => require(whatToLoad ? getSpecifier() : "defaulPath")); p1.then(zero => { return zero.foo(); // ok, zero is any }); -var p3 = Promise.resolve().then(() => __importStar(require(["path1", "path2"]))); -var p4 = Promise.resolve().then(() => __importStar(require(() => "PathToModule"))); +var p3 = Promise.resolve().then(() => require(["path1", "path2"])); +var p4 = Promise.resolve().then(() => require(() => "PathToModule")); diff --git a/tests/baselines/reference/importCallExpressionWithTypeArgument.js b/tests/baselines/reference/importCallExpressionWithTypeArgument.js index 0f057e85a2a57..885992a798b73 100644 --- a/tests/baselines/reference/importCallExpressionWithTypeArgument.js +++ b/tests/baselines/reference/importCallExpressionWithTypeArgument.js @@ -15,12 +15,5 @@ function foo() { return "foo"; } exports.foo = foo; //// [1.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} -var p1 = Promise.resolve().then(() => __importStar(require("./0"))); // error -var p2 = Promise.resolve().then(() => __importStar(require("./0"))); // error +var p1 = Promise.resolve().then(() => require("./0")); // error +var p2 = Promise.resolve().then(() => require("./0")); // error diff --git a/tests/baselines/reference/importWithTrailingSlash.js b/tests/baselines/reference/importWithTrailingSlash.js index 6242f5d8c5705..9df01dcee66fd 100644 --- a/tests/baselines/reference/importWithTrailingSlash.js +++ b/tests/baselines/reference/importWithTrailingSlash.js @@ -29,21 +29,15 @@ exports.__esModule = true; exports["default"] = { aIndex: 0 }; //// [test.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var _1 = __importDefault(require(".")); -var _2 = __importDefault(require("./")); +var _1 = require("."); +var _2 = require("./"); _1["default"].a; _2["default"].aIndex; //// [test.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var __1 = __importDefault(require("..")); -var _1 = __importDefault(require("../")); +var __1 = require(".."); +var _1 = require("../"); __1["default"].a; _1["default"].aIndex; diff --git a/tests/baselines/reference/importsImplicitlyReadonly.js b/tests/baselines/reference/importsImplicitlyReadonly.js index 38e1b21354188..724b8c14e5322 100644 --- a/tests/baselines/reference/importsImplicitlyReadonly.js +++ b/tests/baselines/reference/importsImplicitlyReadonly.js @@ -28,16 +28,9 @@ var y = 1; exports.y = y; //// [b.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; var a_1 = require("./a"); -var a1 = __importStar(require("./a")); +var a1 = require("./a"); var a2 = require("./a"); var a3 = a1; a_1.x = 1; // Error diff --git a/tests/baselines/reference/inferredIndexerOnNamespaceImport.js b/tests/baselines/reference/inferredIndexerOnNamespaceImport.js index 1d1209c6e3168..10fbc0890b7dc 100644 --- a/tests/baselines/reference/inferredIndexerOnNamespaceImport.js +++ b/tests/baselines/reference/inferredIndexerOnNamespaceImport.js @@ -20,15 +20,8 @@ exports.x = 3; exports.y = 5; //// [bar.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var foo = __importStar(require("./foo")); +var foo = require("./foo"); function f(map) { // ... } diff --git a/tests/baselines/reference/invalidSyntaxNamespaceImportWithCommonjs.js b/tests/baselines/reference/invalidSyntaxNamespaceImportWithCommonjs.js index 0d35a5bd549a3..29b8c50c4c555 100644 --- a/tests/baselines/reference/invalidSyntaxNamespaceImportWithCommonjs.js +++ b/tests/baselines/reference/invalidSyntaxNamespaceImportWithCommonjs.js @@ -17,14 +17,7 @@ var C = /** @class */ (function () { exports.C = C; //// [1.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var from = __importStar(require()); +var from = require(); from; "./0"; diff --git a/tests/baselines/reference/isolatedModulesImportExportElision.js b/tests/baselines/reference/isolatedModulesImportExportElision.js index ddd010afd4381..7c5fac47706e1 100644 --- a/tests/baselines/reference/isolatedModulesImportExportElision.js +++ b/tests/baselines/reference/isolatedModulesImportExportElision.js @@ -24,17 +24,10 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); var module_1 = require("module"); var module_2 = require("module"); -var ns = __importStar(require("module")); +var ns = require("module"); var C = /** @class */ (function (_super) { __extends(C, _super); function C() { diff --git a/tests/baselines/reference/isolatedModulesReExportType.js b/tests/baselines/reference/isolatedModulesReExportType.js index b2bf479f5d207..f057395fc3039 100644 --- a/tests/baselines/reference/isolatedModulesReExportType.js +++ b/tests/baselines/reference/isolatedModulesReExportType.js @@ -58,17 +58,10 @@ var C = /** @class */ (function () { exports.C = C; //// [user.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; // OK, has a value side var exportValue_1 = require("./exportValue"); exports.C = exportValue_1.C; // OK, even though the namespace it exports is only types. -var NS = __importStar(require("./exportT")); +var NS = require("./exportT"); exports.NS = NS; diff --git a/tests/baselines/reference/jsxImportInAttribute.js b/tests/baselines/reference/jsxImportInAttribute.js index 162e1e7a71a90..b249d88a6c2b4 100644 --- a/tests/baselines/reference/jsxImportInAttribute.js +++ b/tests/baselines/reference/jsxImportInAttribute.js @@ -15,11 +15,8 @@ let x = Test; // emit test_1.default //// [consumer.jsx] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; /// -var Test_1 = __importDefault(require("Test")); +var Test_1 = require("Test"); var x = Test_1["default"]; // emit test_1.default ; // ? diff --git a/tests/baselines/reference/jsxViaImport.2.js b/tests/baselines/reference/jsxViaImport.2.js index a0fd3145aa337..ba6bde70086b1 100644 --- a/tests/baselines/reference/jsxViaImport.2.js +++ b/tests/baselines/reference/jsxViaImport.2.js @@ -34,12 +34,9 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; /// -var BaseComponent_1 = __importDefault(require("BaseComponent")); +var BaseComponent_1 = require("BaseComponent"); var TestComponent = /** @class */ (function (_super) { __extends(TestComponent, _super); function TestComponent() { diff --git a/tests/baselines/reference/mergedDeclarations7.js b/tests/baselines/reference/mergedDeclarations7.js index 8eaaf916c15fc..8fa3f2d0731f5 100644 --- a/tests/baselines/reference/mergedDeclarations7.js +++ b/tests/baselines/reference/mergedDeclarations7.js @@ -24,13 +24,6 @@ let p: Passport = passport.use(); //// [test.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var passport = __importStar(require("passport")); +var passport = require("passport"); var p = passport.use(); diff --git a/tests/baselines/reference/moduleElementsInWrongContext.types b/tests/baselines/reference/moduleElementsInWrongContext.types index 85fffcf28f19c..0f9a802758cb8 100644 --- a/tests/baselines/reference/moduleElementsInWrongContext.types +++ b/tests/baselines/reference/moduleElementsInWrongContext.types @@ -55,7 +55,7 @@ >Foo : typeof Foo import bar from "ambient"; ->bar : typeof Foo +>bar : any import { baz } from "ambient"; >baz : any diff --git a/tests/baselines/reference/moduleMergeConstructor.js b/tests/baselines/reference/moduleMergeConstructor.js index 783b02860df87..1b02e37549cbc 100644 --- a/tests/baselines/reference/moduleMergeConstructor.js +++ b/tests/baselines/reference/moduleMergeConstructor.js @@ -27,17 +27,9 @@ class Test { //// [index.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "foo"], function (require, exports, foo) { "use strict"; exports.__esModule = true; - foo = __importStar(foo); var Test = /** @class */ (function () { function Test() { this.bar = new foo.Foo(); diff --git a/tests/baselines/reference/multipleDefaultExports01.js b/tests/baselines/reference/multipleDefaultExports01.js index 90fb796c681df..0156ff8c309c9 100644 --- a/tests/baselines/reference/multipleDefaultExports01.js +++ b/tests/baselines/reference/multipleDefaultExports01.js @@ -33,9 +33,6 @@ var x = 10; exports.default = x; //// [m2.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} Object.defineProperty(exports, "__esModule", { value: true }); -var m1_1 = __importDefault(require("./m1")); +var m1_1 = require("./m1"); m1_1.default(); diff --git a/tests/baselines/reference/multipleDefaultExports02.js b/tests/baselines/reference/multipleDefaultExports02.js index 0e13ebe5f76bc..e2827120da2e6 100644 --- a/tests/baselines/reference/multipleDefaultExports02.js +++ b/tests/baselines/reference/multipleDefaultExports02.js @@ -25,9 +25,6 @@ function bar() { exports.default = bar; //// [m2.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} Object.defineProperty(exports, "__esModule", { value: true }); -var m1_1 = __importDefault(require("./m1")); +var m1_1 = require("./m1"); m1_1.default(); diff --git a/tests/baselines/reference/narrowedImports.js b/tests/baselines/reference/narrowedImports.js index cffc6859fb547..5dba68e84e5be 100644 --- a/tests/baselines/reference/narrowedImports.js +++ b/tests/baselines/reference/narrowedImports.js @@ -26,19 +26,9 @@ if (b1) x = b1; //// [x.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var a_1 = __importDefault(require("./a")); -var b0 = __importStar(require("./b")); +var a_1 = require("./a"); +var b0 = require("./b"); var b1 = require("./b"); var x; if (a_1["default"]) diff --git a/tests/baselines/reference/noCrashOnImportShadowing.js b/tests/baselines/reference/noCrashOnImportShadowing.js index 733f95b1f9ede..7ca2116954d6f 100644 --- a/tests/baselines/reference/noCrashOnImportShadowing.js +++ b/tests/baselines/reference/noCrashOnImportShadowing.js @@ -32,29 +32,15 @@ exports.__esModule = true; exports.zzz = 123; //// [a.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var B = __importStar(require("./b")); +var B = require("./b"); var x = { x: "" }; B.zzz; //// [index.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; var x = { x: "" }; B.zzz; -var OriginalB = __importStar(require("./b")); +var OriginalB = require("./b"); OriginalB.zzz; var y = x; diff --git a/tests/baselines/reference/outFilerootDirModuleNamesAmd.js b/tests/baselines/reference/outFilerootDirModuleNamesAmd.js index 4afd572b53eb9..9166551315309 100644 --- a/tests/baselines/reference/outFilerootDirModuleNamesAmd.js +++ b/tests/baselines/reference/outFilerootDirModuleNamesAmd.js @@ -11,20 +11,15 @@ export default function foo() { new Foo(); } //// [output.js] -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} define("b", ["require", "exports", "a"], function (require, exports, a_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - a_1 = __importDefault(a_1); function foo() { new a_1.default(); } exports.default = foo; }); define("a", ["require", "exports", "b"], function (require, exports, b_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - b_1 = __importDefault(b_1); class Foo { } exports.default = Foo; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js index ff1c22a16689d..c372e3558b1be 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js @@ -7,17 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "angular2/core"], function (require, exports, ng) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - ng = __importStar(ng); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js index 29a0f61fad2f1..24bd0b20bc424 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js @@ -8,15 +8,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -var ng = __importStar(require("angular2/core")); +var ng = require("angular2/core"); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js index ff1c22a16689d..c372e3558b1be 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js @@ -7,17 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "angular2/core"], function (require, exports, ng) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - ng = __importStar(ng); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js index 29a0f61fad2f1..24bd0b20bc424 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js @@ -8,15 +8,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -var ng = __importStar(require("angular2/core")); +var ng = require("angular2/core"); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js index ff1c22a16689d..c372e3558b1be 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js @@ -7,17 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "angular2/core"], function (require, exports, ng) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - ng = __importStar(ng); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js index 29a0f61fad2f1..24bd0b20bc424 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js @@ -8,15 +8,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -var ng = __importStar(require("angular2/core")); +var ng = require("angular2/core"); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js index ff1c22a16689d..c372e3558b1be 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js @@ -7,17 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "angular2/core"], function (require, exports, ng) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - ng = __importStar(ng); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js index 29a0f61fad2f1..24bd0b20bc424 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js @@ -8,15 +8,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -var ng = __importStar(require("angular2/core")); +var ng = require("angular2/core"); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js index ff1c22a16689d..c372e3558b1be 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js @@ -7,17 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "angular2/core"], function (require, exports, ng) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - ng = __importStar(ng); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js index 29a0f61fad2f1..24bd0b20bc424 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js @@ -8,15 +8,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -var ng = __importStar(require("angular2/core")); +var ng = require("angular2/core"); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/amd/importHigher/root.js b/tests/baselines/reference/project/nodeModulesImportHigher/amd/importHigher/root.js index 2e5f93d503ac1..65e3b33be1a80 100644 --- a/tests/baselines/reference/project/nodeModulesImportHigher/amd/importHigher/root.js +++ b/tests/baselines/reference/project/nodeModulesImportHigher/amd/importHigher/root.js @@ -1,14 +1,6 @@ -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; exports.__esModule = true; - m1 = __importStar(m1); m1.f1("test"); m1.f2.a = 10; m1.f2.person.age = "10"; // Error: Should be number (if direct import of m2 made the m3 module visible). diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js b/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js index 2613f56dbcc44..4fc36cd0222e6 100644 --- a/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js +++ b/tests/baselines/reference/project/nodeModulesImportHigher/node/importHigher/root.js @@ -1,13 +1,6 @@ "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var m1 = __importStar(require("m1")); +var m1 = require("m1"); m1.f1("test"); m1.f2.a = 10; m1.f2.person.age = "10"; // Error: Should be number (if direct import of m2 made the m3 module visible). diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/maxDepthExceeded/built/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/maxDepthExceeded/built/root.js index 884cbebb56568..493e1b9636e3d 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/maxDepthExceeded/built/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/maxDepthExceeded/built/root.js @@ -1,14 +1,6 @@ -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "m1"], function (require, exports, m1) { "use strict"; exports.__esModule = true; - m1 = __importStar(m1); m1.f1("test"); m1.f2.a = "10"; // Error: Should be number m1.rel = 42; // Error: Should be boolean diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/built/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/built/root.js index 0ab840d7b9a7e..5137083683789 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/built/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/maxDepthExceeded/built/root.js @@ -1,13 +1,6 @@ "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var m1 = __importStar(require("m1")); +var m1 = require("m1"); m1.f1("test"); m1.f2.a = "10"; // Error: Should be number m1.rel = 42; // Error: Should be boolean diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js index 8ce337db37eb5..948a6d68b8338 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/maxDepthIncreased/root.js @@ -1,15 +1,6 @@ -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "m1", "m4"], function (require, exports, m1, m4) { "use strict"; exports.__esModule = true; - m1 = __importStar(m1); - m4 = __importStar(m4); m1.f1("test"); m1.f2.a = 10; m1.f2.person.age = "10"; // Should error if loaded the .js files correctly diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js index c3b40e22780a2..50feab5d27f86 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/maxDepthIncreased/root.js @@ -1,14 +1,7 @@ "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var m1 = __importStar(require("m1")); -var m4 = __importStar(require("m4")); +var m1 = require("m1"); +var m4 = require("m4"); m1.f1("test"); m1.f2.a = 10; m1.f2.person.age = "10"; // Should error if loaded the .js files correctly diff --git a/tests/baselines/reference/reExportDefaultExport.js b/tests/baselines/reference/reExportDefaultExport.js index e8f817899c6dd..ef9386da32a63 100644 --- a/tests/baselines/reference/reExportDefaultExport.js +++ b/tests/baselines/reference/reExportDefaultExport.js @@ -22,11 +22,8 @@ exports.default = f; exports.f = f; //// [m2.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} Object.defineProperty(exports, "__esModule", { value: true }); -var m1_1 = __importDefault(require("./m1")); +var m1_1 = require("./m1"); var m1_2 = require("./m1"); m1_2.f(); m1_1.default(); diff --git a/tests/baselines/reference/reactNamespaceImportPresevation.js b/tests/baselines/reference/reactNamespaceImportPresevation.js index 2f55351445b63..a3e9ac800fee4 100644 --- a/tests/baselines/reference/reactNamespaceImportPresevation.js +++ b/tests/baselines/reference/reactNamespaceImportPresevation.js @@ -15,13 +15,6 @@ declare var foo: any; //// [test.jsx] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var myReactLib = __importStar(require("my-React-Lib")); // should not be elided +var myReactLib = require("my-React-Lib"); // should not be elided ; diff --git a/tests/baselines/reference/requireAsFunctionInExternalModule.js b/tests/baselines/reference/requireAsFunctionInExternalModule.js index 30f72f61edd1d..f4eac77052a0b 100644 --- a/tests/baselines/reference/requireAsFunctionInExternalModule.js +++ b/tests/baselines/reference/requireAsFunctionInExternalModule.js @@ -25,11 +25,8 @@ function has(a) { return true; } exports.has = has; //// [m.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var c_1 = __importDefault(require("./c")); +var c_1 = require("./c"); function hello() { } exports.hello = hello; if (c_1.has('ember-debug')) { diff --git a/tests/baselines/reference/transformNestedGeneratorsWithTry.errors.txt b/tests/baselines/reference/transformNestedGeneratorsWithTry.errors.txt deleted file mode 100644 index e3b982f0ec624..0000000000000 --- a/tests/baselines/reference/transformNestedGeneratorsWithTry.errors.txt +++ /dev/null @@ -1,37 +0,0 @@ -tests/cases/compiler/main.ts(2,1): error TS7004: Import is called or constructed, which is not valid ES2015 module usage, and will fail at runtime. -tests/cases/compiler/main.ts(3,21): error TS1055: Type '{ readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; }' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. -tests/cases/compiler/main.ts(3,21): error TS1055: Type '{ readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; }' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. - Type '{ readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; }' provides no match for the signature 'new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): PromiseLike'. -tests/cases/compiler/main.ts(5,35): error TS1055: Type '{ readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; }' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. - - -==== tests/cases/compiler/main.ts (4 errors) ==== - // https://github.com/Microsoft/TypeScript/issues/11177 - import * as Bluebird from 'bluebird'; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS7004: Import is called or constructed, which is not valid ES2015 module usage, and will fail at runtime. - async function a(): Bluebird { - ~~~~~~~~~~~~~~ -!!! error TS1055: Type '{ readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; }' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. - ~~~~~~~~~~~~~~ -!!! error TS1055: Type '{ readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; }' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. -!!! error TS1055: Type '{ readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; }' provides no match for the signature 'new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): PromiseLike'. - try { - const b = async function b(): Bluebird { - ~~~~~~~~~~~~~~ -!!! error TS1055: Type '{ readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; }' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value. - try { - await Bluebird.resolve(); // -- remove this and it compiles - } catch (error) { } - }; - - await b(); // -- or remove this and it compiles - } catch (error) { } - } - -==== tests/cases/compiler/bluebird.d.ts (0 errors) ==== - declare module "bluebird" { - type Bluebird = Promise; - const Bluebird: typeof Promise; - export = Bluebird; - } \ No newline at end of file diff --git a/tests/baselines/reference/transformNestedGeneratorsWithTry.js b/tests/baselines/reference/transformNestedGeneratorsWithTry.js index a93f09b04d513..28f405e47b9cd 100644 --- a/tests/baselines/reference/transformNestedGeneratorsWithTry.js +++ b/tests/baselines/reference/transformNestedGeneratorsWithTry.js @@ -59,25 +59,18 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); // https://github.com/Microsoft/TypeScript/issues/11177 -var Bluebird = __importStar(require("bluebird")); +var Bluebird = require("bluebird"); function a() { - return __awaiter(this, void 0, void 0, function () { + return __awaiter(this, void 0, Bluebird, function () { var b, error_1; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); b = function b() { - return __awaiter(this, void 0, void 0, function () { + return __awaiter(this, void 0, Bluebird, function () { var error_2; return __generator(this, function (_a) { switch (_a.label) { diff --git a/tests/baselines/reference/transformNestedGeneratorsWithTry.types b/tests/baselines/reference/transformNestedGeneratorsWithTry.types index 6d8c318cdcbaf..3e4ef3f0852cf 100644 --- a/tests/baselines/reference/transformNestedGeneratorsWithTry.types +++ b/tests/baselines/reference/transformNestedGeneratorsWithTry.types @@ -1,7 +1,7 @@ === tests/cases/compiler/main.ts === // https://github.com/Microsoft/TypeScript/issues/11177 import * as Bluebird from 'bluebird'; ->Bluebird : { readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; } +>Bluebird : PromiseConstructor async function a(): Bluebird { >a : () => Promise @@ -19,7 +19,7 @@ async function a(): Bluebird { >await Bluebird.resolve() : void >Bluebird.resolve() : Promise >Bluebird.resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->Bluebird : { readonly [Symbol.species]: Function; all(values: Iterable>): Promise; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; all(values: (T | PromiseLike)[]): Promise; race(values: Iterable>): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; race(values: (T | PromiseLike)[]): Promise; readonly prototype: Promise; reject(reason: any): Promise; reject(reason: any): Promise; resolve(value: T | PromiseLike): Promise; resolve(): Promise; } +>Bluebird : PromiseConstructor >resolve : { (value: T | PromiseLike): Promise; (): Promise; } } catch (error) { } diff --git a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js index 7dd1a0d89946f..2b52d660f4e54 100644 --- a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js +++ b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.js @@ -8,15 +8,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -var ng = __importStar(require("angular2/core")); +var ng = require("angular2/core"); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.oldTranspile.js b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.oldTranspile.js index 7dd1a0d89946f..2b52d660f4e54 100644 --- a/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.oldTranspile.js +++ b/tests/baselines/reference/transpile/Correctly serialize metadata when transpile with CommonJS option.oldTranspile.js @@ -8,15 +8,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} Object.defineProperty(exports, "__esModule", { value: true }); -var ng = __importStar(require("angular2/core")); +var ng = require("angular2/core"); var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index 08887fc6c943f..21a0897ac2b3f 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -40,6 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + // "strictESM": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index ca2b4aa408785..ebbff16a4895e 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -40,6 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + // "strictESM": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index 9437685c295c4..04a9d8d154369 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -40,6 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + // "strictESM": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index d2e7e85ad55cd..0443b20cb53ef 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -40,6 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + // "strictESM": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 3f4100033d017..46844c3019401 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -40,6 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + // "strictESM": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index 08887fc6c943f..21a0897ac2b3f 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -40,6 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + // "strictESM": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index 22cb0444209e6..5f0df725f93d3 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -40,6 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + // "strictESM": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index fc3321600fe96..2ece32caee996 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -40,6 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ "types": ["jquery","mocha"] /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ + // "strictESM": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsconfigMapOptionsAreCaseInsensitive.js b/tests/baselines/reference/tsconfigMapOptionsAreCaseInsensitive.js index f631751c59860..be1f2323a13b6 100644 --- a/tests/baselines/reference/tsconfigMapOptionsAreCaseInsensitive.js +++ b/tests/baselines/reference/tsconfigMapOptionsAreCaseInsensitive.js @@ -17,13 +17,9 @@ define(["require", "exports"], function (require, exports) { exports["default"] = 42; }); //// [index.js] -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} define(["require", "exports", "./other.js"], function (require, exports, other_js_1) { "use strict"; exports.__esModule = true; - other_js_1 = __importDefault(other_js_1); var x = 10 + other_js_1["default"]; exports.x = x; }); diff --git a/tests/baselines/reference/tsxDynamicTagName5.js b/tests/baselines/reference/tsxDynamicTagName5.js index 59146ec07add7..3014c8857de1a 100644 --- a/tests/baselines/reference/tsxDynamicTagName5.js +++ b/tests/baselines/reference/tsxDynamicTagName5.js @@ -30,15 +30,8 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var React = __importStar(require("react")); +var React = require("react"); var Text = /** @class */ (function (_super) { __extends(Text, _super); function Text() { diff --git a/tests/baselines/reference/tsxDynamicTagName7.js b/tests/baselines/reference/tsxDynamicTagName7.js index dcc893fec832c..1a845130b4d5d 100644 --- a/tests/baselines/reference/tsxDynamicTagName7.js +++ b/tests/baselines/reference/tsxDynamicTagName7.js @@ -30,15 +30,8 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var React = __importStar(require("react")); +var React = require("react"); var Text = /** @class */ (function (_super) { __extends(Text, _super); function Text() { diff --git a/tests/baselines/reference/tsxDynamicTagName8.js b/tests/baselines/reference/tsxDynamicTagName8.js index 7722a7c18254c..b35c1b88bcffb 100644 --- a/tests/baselines/reference/tsxDynamicTagName8.js +++ b/tests/baselines/reference/tsxDynamicTagName8.js @@ -30,15 +30,8 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var React = __importStar(require("react")); +var React = require("react"); var Text = /** @class */ (function (_super) { __extends(Text, _super); function Text() { diff --git a/tests/baselines/reference/tsxDynamicTagName9.js b/tests/baselines/reference/tsxDynamicTagName9.js index 11d4ed9639579..113629006f6e8 100644 --- a/tests/baselines/reference/tsxDynamicTagName9.js +++ b/tests/baselines/reference/tsxDynamicTagName9.js @@ -30,15 +30,8 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var React = __importStar(require("react")); +var React = require("react"); var Text = /** @class */ (function (_super) { __extends(Text, _super); function Text() { diff --git a/tests/baselines/reference/tsxElementResolution19.js b/tests/baselines/reference/tsxElementResolution19.js index a65f4ab9c702d..60b72237354e9 100644 --- a/tests/baselines/reference/tsxElementResolution19.js +++ b/tests/baselines/reference/tsxElementResolution19.js @@ -31,16 +31,8 @@ define(["require", "exports"], function (require, exports) { exports.MyClass = MyClass; }); //// [file2.js] -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} define(["require", "exports", "react", "./file1"], function (require, exports, React, file1_1) { "use strict"; exports.__esModule = true; - React = __importStar(React); React.createElement(file1_1.MyClass, null); }); diff --git a/tests/baselines/reference/tsxExternalModuleEmit1.js b/tests/baselines/reference/tsxExternalModuleEmit1.js index dc0c17d603c48..941da1971d554 100644 --- a/tests/baselines/reference/tsxExternalModuleEmit1.js +++ b/tests/baselines/reference/tsxExternalModuleEmit1.js @@ -42,15 +42,8 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var React = __importStar(require("react")); +var React = require("react"); var Button = /** @class */ (function (_super) { __extends(Button, _super); function Button() { @@ -74,15 +67,8 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var React = __importStar(require("react")); +var React = require("react"); // Should see var button_1 = require('./button') here var button_1 = require("./button"); var App = /** @class */ (function (_super) { diff --git a/tests/baselines/reference/tsxExternalModuleEmit2.js b/tests/baselines/reference/tsxExternalModuleEmit2.js index 980367d790216..adf5ed2aaa633 100644 --- a/tests/baselines/reference/tsxExternalModuleEmit2.js +++ b/tests/baselines/reference/tsxExternalModuleEmit2.js @@ -26,11 +26,8 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { } return t; }; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var mod_1 = __importDefault(require("mod")); +var mod_1 = require("mod"); // Should see mod_1['default'] in emit here React.createElement(Foo, { handler: mod_1["default"] }); // Should see mod_1['default'] in emit here diff --git a/tests/baselines/reference/umd-augmentation-1.js b/tests/baselines/reference/umd-augmentation-1.js index 63ec83f792e59..e7f7ae5bad5f3 100644 --- a/tests/baselines/reference/umd-augmentation-1.js +++ b/tests/baselines/reference/umd-augmentation-1.js @@ -40,16 +40,9 @@ var t = p.x; //// [b.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; /// -var m = __importStar(require("math2d")); +var m = require("math2d"); var v = new m.Vector(3, 2); var magnitude = m.getLength(v); var p = v.translate(5, 5); diff --git a/tests/baselines/reference/umd-augmentation-3.js b/tests/baselines/reference/umd-augmentation-3.js index a928c801e5338..f0fb1fe0f4270 100644 --- a/tests/baselines/reference/umd-augmentation-3.js +++ b/tests/baselines/reference/umd-augmentation-3.js @@ -46,16 +46,9 @@ var t = p.x; //// [b.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; /// -var m = __importStar(require("math2d")); +var m = require("math2d"); var v = new m.Vector(3, 2); var magnitude = m.getLength(v); var p = v.translate(5, 5); diff --git a/tests/baselines/reference/umd3.js b/tests/baselines/reference/umd3.js index 2f76d50e6498a..59b0e0ef2c29e 100644 --- a/tests/baselines/reference/umd3.js +++ b/tests/baselines/reference/umd3.js @@ -15,15 +15,8 @@ let y: number = x.n; //// [a.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var Foo = __importStar(require("./foo")); +var Foo = require("./foo"); Foo.fn(); var x; var y = x.n; diff --git a/tests/baselines/reference/umd4.js b/tests/baselines/reference/umd4.js index 54f60b0966c0e..2f17ee04858c1 100644 --- a/tests/baselines/reference/umd4.js +++ b/tests/baselines/reference/umd4.js @@ -15,15 +15,8 @@ let y: number = x.n; //// [a.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var Bar = __importStar(require("./foo")); +var Bar = require("./foo"); Bar.fn(); var x; var y = x.n; diff --git a/tests/baselines/reference/umd5.js b/tests/baselines/reference/umd5.js index ffce0fc4528f8..868243d4fd074 100644 --- a/tests/baselines/reference/umd5.js +++ b/tests/baselines/reference/umd5.js @@ -17,15 +17,8 @@ let z = Foo; //// [a.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var Bar = __importStar(require("./foo")); +var Bar = require("./foo"); Bar.fn(); var x; var y = x.n; diff --git a/tests/baselines/reference/umd8.symbols b/tests/baselines/reference/umd8.symbols index 99c5a40be728b..704019209fdeb 100644 --- a/tests/baselines/reference/umd8.symbols +++ b/tests/baselines/reference/umd8.symbols @@ -8,9 +8,9 @@ let y: Foo; // OK in type position >Foo : Symbol(Foo, Decl(foo.d.ts, 6, 15)) y.foo(); ->y.foo : Symbol(Thing.foo, Decl(foo.d.ts, 0, 21)) +>y.foo : Symbol(ff.foo, Decl(foo.d.ts, 0, 21)) >y : Symbol(y, Decl(a.ts, 3, 3)) ->foo : Symbol(Thing.foo, Decl(foo.d.ts, 0, 21)) +>foo : Symbol(ff.foo, Decl(foo.d.ts, 0, 21)) let z: Foo.SubThing; // OK in ns position >z : Symbol(z, Decl(a.ts, 5, 3)) diff --git a/tests/baselines/reference/umd8.types b/tests/baselines/reference/umd8.types index 3489266ebc936..d2fa4dbc34ab6 100644 --- a/tests/baselines/reference/umd8.types +++ b/tests/baselines/reference/umd8.types @@ -4,13 +4,13 @@ import * as ff from './foo'; >ff : typeof ff let y: Foo; // OK in type position ->y : Thing ->Foo : Thing +>y : ff +>Foo : ff y.foo(); >y.foo() : number >y.foo : () => number ->y : Thing +>y : ff >foo : () => number let z: Foo.SubThing; // OK in ns position @@ -20,7 +20,7 @@ let z: Foo.SubThing; // OK in ns position let x: any = Foo; // Not OK in value position >x : any ->Foo : typeof Thing +>Foo : typeof ff === tests/cases/conformance/externalModules/foo.d.ts === declare class Thing { diff --git a/tests/baselines/reference/untypedModuleImport.js b/tests/baselines/reference/untypedModuleImport.js index fef9cd0d08dde..90fb9ab5f4386 100644 --- a/tests/baselines/reference/untypedModuleImport.js +++ b/tests/baselines/reference/untypedModuleImport.js @@ -23,15 +23,8 @@ foo(bar()); //// [a.js] "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; -var foo = __importStar(require("foo")); +var foo = require("foo"); foo.bar(); //// [b.js] "use strict"; @@ -40,11 +33,8 @@ var foo = require("foo"); foo(); //// [c.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var foo_1 = __importDefault(require("foo")); +var foo_1 = require("foo"); require("./a"); require("./b"); foo_1["default"](foo_1.bar()); diff --git a/tests/baselines/reference/untypedModuleImport_allowJs.js b/tests/baselines/reference/untypedModuleImport_allowJs.js index 1fb13250b7022..5d60df6687c4b 100644 --- a/tests/baselines/reference/untypedModuleImport_allowJs.js +++ b/tests/baselines/reference/untypedModuleImport_allowJs.js @@ -12,9 +12,6 @@ foo.bar(); //// [a.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} exports.__esModule = true; -var foo_1 = __importDefault(require("foo")); +var foo_1 = require("foo"); foo_1["default"].bar(); diff --git a/tests/baselines/reference/unusedImports11.js b/tests/baselines/reference/unusedImports11.js index f4b8211d36fba..198dc10e75823 100644 --- a/tests/baselines/reference/unusedImports11.js +++ b/tests/baselines/reference/unusedImports11.js @@ -29,20 +29,10 @@ exports.Member = Member; exports["default"] = Member; //// [a.js] "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -} -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; - result["default"] = mod; - return result; -} exports.__esModule = true; var b_1 = require("./b"); -var b_2 = __importDefault(require("./b")); -var ns = __importStar(require("./b")); +var b_2 = require("./b"); +var ns = require("./b"); var r = require("./b"); new b_1.Member(); new b_2["default"](); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import1.ts b/tests/cases/fourslash/codeFixCalledES2015Import1.ts index 71d57c73e57e6..2b6d655c24fd7 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import1.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import1.ts @@ -1,5 +1,5 @@ /// - +// @strictESM: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import2.ts b/tests/cases/fourslash/codeFixCalledES2015Import2.ts index 42726d13bbaa3..b5f1be10848c3 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import2.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import2.ts @@ -1,5 +1,5 @@ /// - +// @strictESM: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import3.ts b/tests/cases/fourslash/codeFixCalledES2015Import3.ts index 50a8827e28b4c..6361f19103d12 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import3.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import3.ts @@ -1,5 +1,5 @@ /// - +// @strictESM: true // @module: amd // @Filename: foo.d.ts ////declare function foo(): void; diff --git a/tests/cases/fourslash/codeFixCalledES2015Import4.ts b/tests/cases/fourslash/codeFixCalledES2015Import4.ts index 10bf47fec10d8..7adf073f7d735 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import4.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import4.ts @@ -1,5 +1,5 @@ /// - +// @strictESM: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import5.ts b/tests/cases/fourslash/codeFixCalledES2015Import5.ts index fd0f4b87cae1c..72cba3f521e62 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import5.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import5.ts @@ -1,5 +1,5 @@ /// - +// @strictESM: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import6.ts b/tests/cases/fourslash/codeFixCalledES2015Import6.ts index 9b2105c9970d6..4c481c2cddaa9 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import6.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import6.ts @@ -1,5 +1,5 @@ /// - +// @strictESM: true // @module: amd // @Filename: foo.d.ts ////declare function foo(): void; diff --git a/tests/cases/fourslash/codeFixCalledES2015Import7.ts b/tests/cases/fourslash/codeFixCalledES2015Import7.ts index 758d769fc245e..c1814f21b3050 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import7.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import7.ts @@ -1,5 +1,5 @@ /// - +// @strictESM: true // @Filename: foo.d.ts ////declare class foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import8.ts b/tests/cases/fourslash/codeFixCalledES2015Import8.ts index af3781127188a..7df397169a50e 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import8.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import8.ts @@ -1,5 +1,5 @@ /// - +// @strictESM: true // @Filename: foo.d.ts ////declare class foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import9.ts b/tests/cases/fourslash/codeFixCalledES2015Import9.ts index e1840cdcfa234..e6c0a6c1b63b9 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import9.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import9.ts @@ -1,5 +1,5 @@ /// - +// @strictESM: true // @module: amd // @Filename: foo.d.ts ////declare class foo(): void; diff --git a/tests/cases/fourslash/javascriptModules24.ts b/tests/cases/fourslash/javascriptModules24.ts index 6ee379cc9f046..5a0dd892db7b3 100644 --- a/tests/cases/fourslash/javascriptModules24.ts +++ b/tests/cases/fourslash/javascriptModules24.ts @@ -16,6 +16,6 @@ goTo.marker('1'); /**** BUG: Should be an error to invoke a call signature on a namespace import ****/ //verify.errorExistsBeforeMarker('1'); -verify.quickInfoIs("import foo"); +verify.quickInfoIs("(alias) foo(): number\nimport foo"); goTo.marker('2'); verify.signatureHelpArgumentCountIs(1); From 3b33df03d9440498313ef50f5ef56afc455c6808 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 6 Nov 2017 16:40:20 -0800 Subject: [PATCH 09/26] Rename strictESM to ESMInterop --- src/compiler/checker.ts | 4 ++-- src/compiler/commandLineParser.ts | 2 +- src/compiler/transformers/module/module.ts | 6 +++--- src/compiler/types.ts | 2 +- tests/baselines/reference/api/tsserverlibrary.d.ts | 2 +- tests/baselines/reference/api/typescript.d.ts | 2 +- .../tsConfig/Default initialized TSConfig/tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../Initialized TSConfig with files options/tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- tests/cases/fourslash/codeFixCalledES2015Import1.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import2.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import3.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import4.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import5.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import6.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import7.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import8.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import9.ts | 2 +- 23 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5a0dbbda796bc..03a39660a7e55 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -66,7 +66,7 @@ namespace ts { const languageVersion = getEmitScriptTarget(compilerOptions); const modulekind = getEmitModuleKind(compilerOptions); const noUnusedIdentifiers = !!compilerOptions.noUnusedLocals || !!compilerOptions.noUnusedParameters; - const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : compilerOptions.strictESM ? (modulekind && modulekind < ModuleKind.ES2015) : modulekind === ModuleKind.System; + const allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : compilerOptions.ESMInterop ? (modulekind && modulekind < ModuleKind.ES2015) : modulekind === ModuleKind.System; const strictNullChecks = getStrictOptionValue(compilerOptions, "strictNullChecks"); const strictFunctionTypes = getStrictOptionValue(compilerOptions, "strictFunctionTypes"); const noImplicitAny = getStrictOptionValue(compilerOptions, "noImplicitAny"); @@ -1889,7 +1889,7 @@ namespace ts { error(moduleReferenceExpression, Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } - if (compilerOptions.strictESM) { + if (compilerOptions.ESMInterop) { const referenceParent = moduleReferenceExpression.parent; if ( (referenceParent.kind === SyntaxKind.ImportDeclaration && getNamespaceDeclarationNode(referenceParent as ImportDeclaration)) || diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index d55ec05214b37..cbb81994aac8d 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -392,7 +392,7 @@ namespace ts { description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, { - name: "strictESM", + name: "ESMInterop", type: "boolean", category: Diagnostics.Module_Resolution_Options, description: Diagnostics.Create_namespace_objects_for_ECMAScript_imports_which_are_neither_callable_nor_constructable_implies_allowSyntheticDefaultImports diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 890b5da6ea524..3e922985551ac 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -639,7 +639,7 @@ namespace ts { } const promise = createNew(createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); - if (compilerOptions.strictESM) { + if (compilerOptions.ESMInterop) { context.requestEmitHelper(importStarHelper); return createCall(createPropertyAccess(promise, createIdentifier("then")), /*typeArguments*/ undefined, [getHelperName("__importStar")]); } @@ -654,7 +654,7 @@ namespace ts { // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately const promiseResolveCall = createCall(createPropertyAccess(createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []); let requireCall = createCall(createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); - if (compilerOptions.strictESM) { + if (compilerOptions.ESMInterop) { context.requestEmitHelper(importStarHelper); requireCall = createCall(getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } @@ -692,7 +692,7 @@ namespace ts { function getHelperExpressionForImport(node: ImportDeclaration, innerExpr: Expression) { - if (!compilerOptions.strictESM || node.transformFlags & TransformFlags.NeverApplyImportHelper) { + if (!compilerOptions.ESMInterop || node.transformFlags & TransformFlags.NeverApplyImportHelper) { return innerExpr; } if (getNamespaceDeclarationNode(node)) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 88e5fd98c5e99..b8adcc131118a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3800,7 +3800,7 @@ namespace ts { typeRoots?: string[]; /*@internal*/ version?: boolean; /*@internal*/ watch?: boolean; - strictESM?: boolean; + ESMInterop?: boolean; [option: string]: CompilerOptionsValue | JsonSourceFile | undefined; } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index c91cc5bce3e59..257ed9fbc1f8d 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2285,7 +2285,7 @@ declare namespace ts { types?: string[]; /** Paths used to compute primary types search locations */ typeRoots?: string[]; - strictESM?: boolean; + ESMInterop?: boolean; [option: string]: CompilerOptionsValue | JsonSourceFile | undefined; } interface TypeAcquisition { diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index ba86e4f4ada40..ec00894b1bcd6 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2285,7 +2285,7 @@ declare namespace ts { types?: string[]; /** Paths used to compute primary types search locations */ typeRoots?: string[]; - strictESM?: boolean; + ESMInterop?: boolean; [option: string]: CompilerOptionsValue | JsonSourceFile | undefined; } interface TypeAcquisition { diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index 21a0897ac2b3f..37d36e3c18f02 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -40,7 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "strictESM": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + // "ESMInterop": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index ebbff16a4895e..c7ebf0105a302 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -40,7 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "strictESM": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + // "ESMInterop": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index 04a9d8d154369..b3b2922d207a5 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -40,7 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "strictESM": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + // "ESMInterop": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index 0443b20cb53ef..315404e201804 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -40,7 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "strictESM": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + // "ESMInterop": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 46844c3019401..318ced428e078 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -40,7 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "strictESM": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + // "ESMInterop": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index 21a0897ac2b3f..37d36e3c18f02 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -40,7 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "strictESM": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + // "ESMInterop": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index 5f0df725f93d3..ae7bfe94e638a 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -40,7 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "strictESM": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + // "ESMInterop": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index 2ece32caee996..82fa78b4d5f0f 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -40,7 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ "types": ["jquery","mocha"] /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "strictESM": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + // "ESMInterop": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/cases/fourslash/codeFixCalledES2015Import1.ts b/tests/cases/fourslash/codeFixCalledES2015Import1.ts index 2b6d655c24fd7..f41611e31d08c 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import1.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import1.ts @@ -1,5 +1,5 @@ /// -// @strictESM: true +// @ESMInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import2.ts b/tests/cases/fourslash/codeFixCalledES2015Import2.ts index b5f1be10848c3..7d2b8c7a009b4 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import2.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import2.ts @@ -1,5 +1,5 @@ /// -// @strictESM: true +// @ESMInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import3.ts b/tests/cases/fourslash/codeFixCalledES2015Import3.ts index 6361f19103d12..c992399b1d9c5 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import3.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import3.ts @@ -1,5 +1,5 @@ /// -// @strictESM: true +// @ESMInterop: true // @module: amd // @Filename: foo.d.ts ////declare function foo(): void; diff --git a/tests/cases/fourslash/codeFixCalledES2015Import4.ts b/tests/cases/fourslash/codeFixCalledES2015Import4.ts index 7adf073f7d735..82b248f09de71 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import4.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import4.ts @@ -1,5 +1,5 @@ /// -// @strictESM: true +// @ESMInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import5.ts b/tests/cases/fourslash/codeFixCalledES2015Import5.ts index 72cba3f521e62..0ebe8f8fa8574 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import5.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import5.ts @@ -1,5 +1,5 @@ /// -// @strictESM: true +// @ESMInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import6.ts b/tests/cases/fourslash/codeFixCalledES2015Import6.ts index 4c481c2cddaa9..3f942facae4ef 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import6.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import6.ts @@ -1,5 +1,5 @@ /// -// @strictESM: true +// @ESMInterop: true // @module: amd // @Filename: foo.d.ts ////declare function foo(): void; diff --git a/tests/cases/fourslash/codeFixCalledES2015Import7.ts b/tests/cases/fourslash/codeFixCalledES2015Import7.ts index c1814f21b3050..39bdd54c0925e 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import7.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import7.ts @@ -1,5 +1,5 @@ /// -// @strictESM: true +// @ESMInterop: true // @Filename: foo.d.ts ////declare class foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import8.ts b/tests/cases/fourslash/codeFixCalledES2015Import8.ts index 7df397169a50e..7421ad89712d6 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import8.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import8.ts @@ -1,5 +1,5 @@ /// -// @strictESM: true +// @ESMInterop: true // @Filename: foo.d.ts ////declare class foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import9.ts b/tests/cases/fourslash/codeFixCalledES2015Import9.ts index e6c0a6c1b63b9..67fa3e47c660d 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import9.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import9.ts @@ -1,5 +1,5 @@ /// -// @strictESM: true +// @ESMInterop: true // @module: amd // @Filename: foo.d.ts ////declare class foo(): void; From bcafdba5bc9b36fc9d0a74922f56a801f2d6e396 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 10 Nov 2017 14:20:32 -0800 Subject: [PATCH 10/26] ESMInterop -> ESModuleInterop, make default for tsc --init --- src/compiler/checker.ts | 2 +- src/compiler/commandLineParser.ts | 5 +++-- src/compiler/core.ts | 2 +- src/compiler/types.ts | 2 +- tests/baselines/reference/api/tsserverlibrary.d.ts | 2 +- tests/baselines/reference/api/typescript.d.ts | 2 +- .../tsConfig/Default initialized TSConfig/tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../Initialized TSConfig with files options/tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- .../tsconfig.json | 4 ++-- tests/cases/fourslash/codeFixCalledES2015Import1.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import2.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import3.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import4.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import5.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import6.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import7.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import8.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import9.ts | 2 +- 23 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1052148f33c5d..a0a43e1ae05fa 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1889,7 +1889,7 @@ namespace ts { error(moduleReferenceExpression, Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } - if (compilerOptions.ESMInterop) { + if (compilerOptions.ESModuleInterop) { const referenceParent = moduleReferenceExpression.parent; if ( (referenceParent.kind === SyntaxKind.ImportDeclaration && getNamespaceDeclarationNode(referenceParent as ImportDeclaration)) || diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index b8d0f3981b244..c51c01f53aad2 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -392,7 +392,7 @@ namespace ts { description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, { - name: "ESMInterop", + name: "ESModuleInterop", type: "boolean", category: Diagnostics.Module_Resolution_Options, description: Diagnostics.Create_namespace_objects_for_ECMAScript_imports_which_are_neither_callable_nor_constructable_implies_allowSyntheticDefaultImports @@ -699,7 +699,8 @@ namespace ts { export const defaultInitCompilerOptions: CompilerOptions = { module: ModuleKind.CommonJS, target: ScriptTarget.ES5, - strict: true + strict: true, + ESModuleInterop: true }; let optionNameMapCache: OptionNameMap; diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 5589552e4d63b..43a8ab5d3ce37 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1920,7 +1920,7 @@ namespace ts { const moduleKind = getEmitModuleKind(compilerOptions); return compilerOptions.allowSyntheticDefaultImports !== undefined ? compilerOptions.allowSyntheticDefaultImports - : compilerOptions.ESMInterop + : compilerOptions.ESModuleInterop ? !!moduleKind && moduleKind < ModuleKind.ES2015 : moduleKind === ModuleKind.System; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a6f2b2df025c6..1eb93ca7ccdb3 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3820,7 +3820,7 @@ namespace ts { typeRoots?: string[]; /*@internal*/ version?: boolean; /*@internal*/ watch?: boolean; - ESMInterop?: boolean; + ESModuleInterop?: boolean; [option: string]: CompilerOptionsValue | JsonSourceFile | undefined; } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 48211db7df37f..501d677c2215f 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2286,7 +2286,7 @@ declare namespace ts { types?: string[]; /** Paths used to compute primary types search locations */ typeRoots?: string[]; - ESMInterop?: boolean; + ESModuleInterop?: boolean; [option: string]: CompilerOptionsValue | JsonSourceFile | undefined; } interface TypeAcquisition { diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 5193f1778afc5..1e182dc0fa0ad 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2286,7 +2286,7 @@ declare namespace ts { types?: string[]; /** Paths used to compute primary types search locations */ typeRoots?: string[]; - ESMInterop?: boolean; + ESModuleInterop?: boolean; [option: string]: CompilerOptionsValue | JsonSourceFile | undefined; } interface TypeAcquisition { diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index 37d36e3c18f02..6e59940253f5f 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -19,7 +19,7 @@ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */ + "strict": true, /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ // "strictFunctionTypes": true, /* Enable strict checking of function types. */ @@ -40,7 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "ESMInterop": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index c7ebf0105a302..e22499cf544c6 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -27,7 +27,7 @@ // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ /* Additional Checks */ - "noUnusedLocals": true /* Report errors on unused locals. */ + "noUnusedLocals": true, /* Report errors on unused locals. */ // "noUnusedParameters": true, /* Report errors on unused parameters. */ // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ @@ -40,7 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "ESMInterop": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index b3b2922d207a5..bac7d6716df76 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -19,7 +19,7 @@ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */ + "strict": true, /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ // "strictFunctionTypes": true, /* Enable strict checking of function types. */ @@ -40,7 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "ESMInterop": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index 315404e201804..2fa6e643a7d58 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -19,7 +19,7 @@ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */ + "strict": true, /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ // "strictFunctionTypes": true, /* Enable strict checking of function types. */ @@ -40,7 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "ESMInterop": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 318ced428e078..99040839d23e4 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -19,7 +19,7 @@ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */ + "strict": true, /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ // "strictFunctionTypes": true, /* Enable strict checking of function types. */ @@ -40,7 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "ESMInterop": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index 37d36e3c18f02..6e59940253f5f 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -19,7 +19,7 @@ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */ + "strict": true, /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ // "strictFunctionTypes": true, /* Enable strict checking of function types. */ @@ -40,7 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "ESMInterop": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index ae7bfe94e638a..e50307d1bd104 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -19,7 +19,7 @@ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */ + "strict": true, /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ // "strictFunctionTypes": true, /* Enable strict checking of function types. */ @@ -40,7 +40,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "ESMInterop": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index 82fa78b4d5f0f..07693c2001f49 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -38,9 +38,9 @@ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */ - "types": ["jquery","mocha"] /* Type declaration files to be included in compilation. */ + "types": ["jquery","mocha"], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - // "ESMInterop": true, /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/cases/fourslash/codeFixCalledES2015Import1.ts b/tests/cases/fourslash/codeFixCalledES2015Import1.ts index f41611e31d08c..dad2798a101c9 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import1.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import1.ts @@ -1,5 +1,5 @@ /// -// @ESMInterop: true +// @ESModuleInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import2.ts b/tests/cases/fourslash/codeFixCalledES2015Import2.ts index 7d2b8c7a009b4..2bacfe28c5e92 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import2.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import2.ts @@ -1,5 +1,5 @@ /// -// @ESMInterop: true +// @ESModuleInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import3.ts b/tests/cases/fourslash/codeFixCalledES2015Import3.ts index c992399b1d9c5..c9b07ede38cdd 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import3.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import3.ts @@ -1,5 +1,5 @@ /// -// @ESMInterop: true +// @ESModuleInterop: true // @module: amd // @Filename: foo.d.ts ////declare function foo(): void; diff --git a/tests/cases/fourslash/codeFixCalledES2015Import4.ts b/tests/cases/fourslash/codeFixCalledES2015Import4.ts index 82b248f09de71..f706a759e3de6 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import4.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import4.ts @@ -1,5 +1,5 @@ /// -// @ESMInterop: true +// @ESModuleInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import5.ts b/tests/cases/fourslash/codeFixCalledES2015Import5.ts index 0ebe8f8fa8574..17c30f31100d4 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import5.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import5.ts @@ -1,5 +1,5 @@ /// -// @ESMInterop: true +// @ESModuleInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import6.ts b/tests/cases/fourslash/codeFixCalledES2015Import6.ts index 3f942facae4ef..d0422fe4eeb29 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import6.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import6.ts @@ -1,5 +1,5 @@ /// -// @ESMInterop: true +// @ESModuleInterop: true // @module: amd // @Filename: foo.d.ts ////declare function foo(): void; diff --git a/tests/cases/fourslash/codeFixCalledES2015Import7.ts b/tests/cases/fourslash/codeFixCalledES2015Import7.ts index 39bdd54c0925e..543613673f629 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import7.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import7.ts @@ -1,5 +1,5 @@ /// -// @ESMInterop: true +// @ESModuleInterop: true // @Filename: foo.d.ts ////declare class foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import8.ts b/tests/cases/fourslash/codeFixCalledES2015Import8.ts index 7421ad89712d6..9539398816ebd 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import8.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import8.ts @@ -1,5 +1,5 @@ /// -// @ESMInterop: true +// @ESModuleInterop: true // @Filename: foo.d.ts ////declare class foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import9.ts b/tests/cases/fourslash/codeFixCalledES2015Import9.ts index 67fa3e47c660d..d509bb90e7c46 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import9.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import9.ts @@ -1,5 +1,5 @@ /// -// @ESMInterop: true +// @ESModuleInterop: true // @module: amd // @Filename: foo.d.ts ////declare class foo(): void; From 29c731c3d571842d60eadcda665f23777ee2787c Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 17 Nov 2017 15:10:37 -0800 Subject: [PATCH 11/26] Rename ESMInterop -> ESModuleInterop in module.ts, add emit test (since fourslash doesnt do that) --- src/compiler/transformers/module/module.ts | 6 +-- tests/baselines/reference/esModuleInterop.js | 39 +++++++++++++++++++ .../reference/esModuleInterop.symbols | 37 ++++++++++++++++++ .../baselines/reference/esModuleInterop.types | 38 ++++++++++++++++++ tests/cases/compiler/esModuleInterop.ts | 17 ++++++++ 5 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/esModuleInterop.js create mode 100644 tests/baselines/reference/esModuleInterop.symbols create mode 100644 tests/baselines/reference/esModuleInterop.types create mode 100644 tests/cases/compiler/esModuleInterop.ts diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index faeedf241bd8a..770d6a3da9b20 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -639,7 +639,7 @@ namespace ts { } const promise = createNew(createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); - if (compilerOptions.ESMInterop) { + if (compilerOptions.ESModuleInterop) { context.requestEmitHelper(importStarHelper); return createCall(createPropertyAccess(promise, createIdentifier("then")), /*typeArguments*/ undefined, [getHelperName("__importStar")]); } @@ -654,7 +654,7 @@ namespace ts { // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately const promiseResolveCall = createCall(createPropertyAccess(createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []); let requireCall = createCall(createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); - if (compilerOptions.ESMInterop) { + if (compilerOptions.ESModuleInterop) { context.requestEmitHelper(importStarHelper); requireCall = createCall(getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } @@ -692,7 +692,7 @@ namespace ts { function getHelperExpressionForImport(node: ImportDeclaration, innerExpr: Expression) { - if (!compilerOptions.ESMInterop || node.transformFlags & TransformFlags.NeverApplyImportHelper) { + if (!compilerOptions.ESModuleInterop || node.transformFlags & TransformFlags.NeverApplyImportHelper) { return innerExpr; } if (getNamespaceDeclarationNode(node)) { diff --git a/tests/baselines/reference/esModuleInterop.js b/tests/baselines/reference/esModuleInterop.js new file mode 100644 index 0000000000000..5f879f2378d01 --- /dev/null +++ b/tests/baselines/reference/esModuleInterop.js @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/esModuleInterop.ts] //// + +//// [index.d.ts] +export function sayHello(): string; +//// [path.d.ts] +declare const anything: any; +export = anything; +//// [fs.d.ts] +declare const anything: any; +export = anything; +//// [mjts.ts] +import { sayHello } from "./hybrid"; +import path from "./path"; +import * as fs from "./fs"; + +path; +sayHello(); +fs; + + +//// [mjts.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +} +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + result["default"] = mod; + return result; +} +exports.__esModule = true; +var hybrid_1 = require("./hybrid"); +var path_1 = __importDefault(require("./path")); +var fs = __importStar(require("./fs")); +path_1["default"]; +hybrid_1.sayHello(); +fs; diff --git a/tests/baselines/reference/esModuleInterop.symbols b/tests/baselines/reference/esModuleInterop.symbols new file mode 100644 index 0000000000000..8e173220d4344 --- /dev/null +++ b/tests/baselines/reference/esModuleInterop.symbols @@ -0,0 +1,37 @@ +=== tests/cases/compiler/hybrid/index.d.ts === +export function sayHello(): string; +>sayHello : Symbol(sayHello, Decl(index.d.ts, 0, 0)) + +=== tests/cases/compiler/path.d.ts === +declare const anything: any; +>anything : Symbol(anything, Decl(path.d.ts, 0, 13)) + +export = anything; +>anything : Symbol(anything, Decl(path.d.ts, 0, 13)) + +=== tests/cases/compiler/fs.d.ts === +declare const anything: any; +>anything : Symbol(anything, Decl(fs.d.ts, 0, 13)) + +export = anything; +>anything : Symbol(anything, Decl(fs.d.ts, 0, 13)) + +=== tests/cases/compiler/mjts.ts === +import { sayHello } from "./hybrid"; +>sayHello : Symbol(sayHello, Decl(mjts.ts, 0, 8)) + +import path from "./path"; +>path : Symbol(path, Decl(mjts.ts, 1, 6)) + +import * as fs from "./fs"; +>fs : Symbol(fs, Decl(mjts.ts, 2, 6)) + +path; +>path : Symbol(path, Decl(mjts.ts, 1, 6)) + +sayHello(); +>sayHello : Symbol(sayHello, Decl(mjts.ts, 0, 8)) + +fs; +>fs : Symbol(fs, Decl(mjts.ts, 2, 6)) + diff --git a/tests/baselines/reference/esModuleInterop.types b/tests/baselines/reference/esModuleInterop.types new file mode 100644 index 0000000000000..98e39f596a871 --- /dev/null +++ b/tests/baselines/reference/esModuleInterop.types @@ -0,0 +1,38 @@ +=== tests/cases/compiler/hybrid/index.d.ts === +export function sayHello(): string; +>sayHello : () => string + +=== tests/cases/compiler/path.d.ts === +declare const anything: any; +>anything : any + +export = anything; +>anything : any + +=== tests/cases/compiler/fs.d.ts === +declare const anything: any; +>anything : any + +export = anything; +>anything : any + +=== tests/cases/compiler/mjts.ts === +import { sayHello } from "./hybrid"; +>sayHello : () => string + +import path from "./path"; +>path : any + +import * as fs from "./fs"; +>fs : any + +path; +>path : any + +sayHello(); +>sayHello() : string +>sayHello : () => string + +fs; +>fs : any + diff --git a/tests/cases/compiler/esModuleInterop.ts b/tests/cases/compiler/esModuleInterop.ts new file mode 100644 index 0000000000000..d8123990ac6f8 --- /dev/null +++ b/tests/cases/compiler/esModuleInterop.ts @@ -0,0 +1,17 @@ +// @ESModuleInterop: true +// @filename: hybrid/index.d.ts +export function sayHello(): string; +// @filename: path.d.ts +declare const anything: any; +export = anything; +// @filename: fs.d.ts +declare const anything: any; +export = anything; +// @filename: mjts.ts +import { sayHello } from "./hybrid"; +import path from "./path"; +import * as fs from "./fs"; + +path; +sayHello(); +fs; From e20a548ec36ca75a39f402588bdcf3ff87f2cb53 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 17 Nov 2017 17:39:48 -0800 Subject: [PATCH 12/26] Remove erroneous semicolons from helper --- src/compiler/transformers/module/module.ts | 2 +- tests/baselines/reference/esModuleInterop.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 770d6a3da9b20..d53dfc989cfe6 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -1726,7 +1726,7 @@ namespace ts { var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }` diff --git a/tests/baselines/reference/esModuleInterop.js b/tests/baselines/reference/esModuleInterop.js index 5f879f2378d01..9a04ab01be69d 100644 --- a/tests/baselines/reference/esModuleInterop.js +++ b/tests/baselines/reference/esModuleInterop.js @@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null); for (var k in mod); if (Object.hasOwnProperty.call(mod, k)); result[k] = mod[k]; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; } From dfe5675c1f6a9d8e9a0973a515f9e4fae8702fd5 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 28 Nov 2017 16:37:05 -0800 Subject: [PATCH 13/26] Reword diagnostic --- src/compiler/commandLineParser.ts | 3 ++- src/compiler/diagnosticMessages.json | 2 +- .../tsConfig/Default initialized TSConfig/tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../Initialized TSConfig with files options/tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- 10 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 9c030adac3d70..270606bfbe721 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -401,8 +401,9 @@ namespace ts { { name: "ESModuleInterop", type: "boolean", + showInSimplifiedHelpView: true, category: Diagnostics.Module_Resolution_Options, - description: Diagnostics.Create_namespace_objects_for_ECMAScript_imports_which_are_neither_callable_nor_constructable_implies_allowSyntheticDefaultImports + description: Diagnostics.Enables_emit_interoperability_bewteen_commonjs_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports }, { name: "preserveSymlinks", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index e234a182a3326..cea35b4bcc815 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3519,7 +3519,7 @@ "category": "Error", "code": 7036 }, - "Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`.": { + "Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`.": { "category": "Message", "code": 7037 }, diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index 5af2f486b954c..569d4b5b46b2e 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index 3bbd4ba17bbc8..853146a77e929 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index 5c772e2e7d4c0..2cf3e4a11707f 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index e2f13e1735224..6327c86cf2a96 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index e596dec5e803e..6f57091dbf2bc 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index 5af2f486b954c..569d4b5b46b2e 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index d2b7f617a10ff..a5a81dacc880f 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index a948f8de46cfc..dadc78de4a750 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ "types": ["jquery","mocha"], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Create namespace objects for ECMAScript imports which are neither callable nor constructable, implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ From 8c6c3130d4ec8376e8b13008e74dd2092789dc9b Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 28 Nov 2017 16:41:51 -0800 Subject: [PATCH 14/26] Change style --- src/compiler/core.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index f5ccad47aced9..0e82fc974f381 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1967,7 +1967,7 @@ namespace ts { return compilerOptions.allowSyntheticDefaultImports !== undefined ? compilerOptions.allowSyntheticDefaultImports : compilerOptions.ESModuleInterop - ? !!moduleKind && moduleKind < ModuleKind.ES2015 + ? moduleKind !== ModuleKind.None && moduleKind < ModuleKind.ES2015 : moduleKind === ModuleKind.System; } From 3d996d7e2a7421815c27e64ef1f523dda7bb81ab Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 28 Nov 2017 16:49:49 -0800 Subject: [PATCH 15/26] Edit followup diagnostic --- src/compiler/checker.ts | 4 ++-- src/compiler/diagnosticMessages.json | 2 +- src/services/codefixes/fixInvalidImportSyntax.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0c32ff04ccddb..7158e4bdf5365 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9355,7 +9355,7 @@ namespace ts { const helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, /*errorNode*/ undefined); if (helpfulRetry) { // Likely an incorrect import. Issue a helpful diagnostic to produce a quickfix to change the import - diagnostics.add(createDiagnosticForNode(links.originatingImport, Diagnostics.Import_is_called_or_constructed_which_is_not_valid_ES2015_module_usage_and_will_fail_at_runtime)); + diagnostics.add(createDiagnosticForNode(links.originatingImport, Diagnostics.A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime)); } } } @@ -17321,7 +17321,7 @@ namespace ts { if (importNode && !isImportCall(importNode)) { const sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind); if (!sigs || !sigs.length) return; - error(importNode, Diagnostics.Import_is_called_or_constructed_which_is_not_valid_ES2015_module_usage_and_will_fail_at_runtime); + error(importNode, Diagnostics.A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index cea35b4bcc815..f82f26cf35cc0 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3523,7 +3523,7 @@ "category": "Message", "code": 7037 }, - "Import is called or constructed, which is not valid ES2015 module usage, and will fail at runtime.": { + "A namespace-style import cannot be called or constructed, and will cause a failure at runtime.": { "category": "Error", "code": 7038 }, diff --git a/src/services/codefixes/fixInvalidImportSyntax.ts b/src/services/codefixes/fixInvalidImportSyntax.ts index 37c3ba1a73633..03485cbcc09bc 100644 --- a/src/services/codefixes/fixInvalidImportSyntax.ts +++ b/src/services/codefixes/fixInvalidImportSyntax.ts @@ -1,7 +1,7 @@ /* @internal */ namespace ts.codefix { registerCodeFix({ - errorCodes: [Diagnostics.Import_is_called_or_constructed_which_is_not_valid_ES2015_module_usage_and_will_fail_at_runtime.code], + errorCodes: [Diagnostics.A_namespace_style_import_cannot_be_called_or_constructed_and_will_cause_a_failure_at_runtime.code], getCodeActions: getActionsForInvalidImport }); From 2f9c240eac37ec549c9dc891d8c636ec58b76d87 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 29 Nov 2017 11:17:24 -0800 Subject: [PATCH 16/26] Add secondary quickfix for call sites, tests forthcoming --- src/compiler/diagnosticMessages.json | 4 ++ .../codefixes/fixInvalidImportSyntax.ts | 41 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index f82f26cf35cc0..2a0125bd59c5b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3898,5 +3898,9 @@ "Replace import with '{0}'.": { "category": "Message", "code": 95015 + }, + "Use synthetic 'default' member.": { + "category": "Message", + "code": 95016 } } diff --git a/src/services/codefixes/fixInvalidImportSyntax.ts b/src/services/codefixes/fixInvalidImportSyntax.ts index 03485cbcc09bc..30d190f7f9c6f 100644 --- a/src/services/codefixes/fixInvalidImportSyntax.ts +++ b/src/services/codefixes/fixInvalidImportSyntax.ts @@ -12,6 +12,11 @@ namespace ts.codefix { // import * as Bluebird from 'bluebird'; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const node = getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false).parent as ImportDeclaration; + return getCodeFixesForImportDeclaration(context, node); + } + + function getCodeFixesForImportDeclaration(context: CodeFixContext, node: ImportDeclaration) { + const sourceFile = getSourceFileOfNode(node); const namespace = getNamespaceDeclarationNode(node) as NamespaceImport; const opts = context.program.getCompilerOptions(); const variations: CodeAction[] = []; @@ -49,4 +54,40 @@ namespace ts.codefix { return variations; } + + registerCodeFix({ + errorCodes: [ + Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code, + Diagnostics.Cannot_use_new_with_an_expression_whose_type_lacks_a_call_or_construct_signature.code, + ], + getCodeActions: getActionsForUsageOfInvalidImport + }); + + function getActionsForUsageOfInvalidImport(context: CodeFixContext): CodeAction[] | undefined { + const sourceFile = context.sourceFile; + const targetKind = Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? SyntaxKind.CallExpression : SyntaxKind.NewExpression; + let node = findAncestor(getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false), a => a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length)) as CallExpression | NewExpression; + if (!node) { + return []; + } + const expr = node.expression; + const type = context.program.getTypeChecker().getTypeAtLocation(expr); + if (!(type.symbol && (type.symbol as TransientSymbol).originatingImport)) { + return []; + } + const fixes: CodeAction[] = []; + const relatedImport = (type.symbol as TransientSymbol).originatingImport; + if (!isImportCall(relatedImport)) { + addRange(fixes, getCodeFixesForImportDeclaration(context, relatedImport)); + } + const propertyAccess = createPropertyAccess(expr, "default"); + const changeTracker = textChanges.ChangeTracker.fromContext(context); + changeTracker.replaceNode(sourceFile, expr, propertyAccess, {}); + const changes = changeTracker.getChanges(); + fixes.push({ + description: getLocaleSpecificMessage(Diagnostics.Use_synthetic_default_member), + changes + }) + return fixes; + } } From 2361f37ca34b0c1f6ae6aa321d78bd91809e329b Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 29 Nov 2017 13:10:55 -0800 Subject: [PATCH 17/26] Add synth default to namespace import type, enhance quickfix --- src/compiler/checker.ts | 5 ++- .../codefixes/fixInvalidImportSyntax.ts | 41 +++++++++++-------- .../fourslash/codeFixCalledES2015Import1.ts | 2 +- .../fourslash/codeFixCalledES2015Import10.ts | 18 ++++++++ .../fourslash/codeFixCalledES2015Import11.ts | 18 ++++++++ .../fourslash/codeFixCalledES2015Import12.ts | 18 ++++++++ .../fourslash/codeFixCalledES2015Import13.ts | 18 ++++++++ .../fourslash/codeFixCalledES2015Import2.ts | 2 +- .../fourslash/codeFixCalledES2015Import4.ts | 2 +- .../fourslash/codeFixCalledES2015Import5.ts | 2 +- .../fourslash/codeFixCalledES2015Import7.ts | 2 +- .../fourslash/codeFixCalledES2015Import8.ts | 2 +- 12 files changed, 104 insertions(+), 26 deletions(-) create mode 100644 tests/cases/fourslash/codeFixCalledES2015Import10.ts create mode 100644 tests/cases/fourslash/codeFixCalledES2015Import11.ts create mode 100644 tests/cases/fourslash/codeFixCalledES2015Import12.ts create mode 100644 tests/cases/fourslash/codeFixCalledES2015Import13.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7158e4bdf5365..44c66d1cd00a0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1924,6 +1924,7 @@ namespace ts { sigs = getSignaturesOfStructuredType(type, SignatureKind.Construct); } if (sigs && sigs.length) { + const moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol); // Create a new symbol which has the module's type less the call and construct signatures const result = createSymbol(symbol.flags, symbol.escapedName); result.declarations = symbol.declarations ? symbol.declarations.slice() : []; @@ -1934,8 +1935,8 @@ namespace ts { if (symbol.constEnumOnlyModule) result.constEnumOnlyModule = true; if (symbol.members) result.members = cloneMap(symbol.members); if (symbol.exports) result.exports = cloneMap(symbol.exports); - const moduleType = resolveStructuredTypeMembers(type as StructuredType); // Should already be resolved from the signature checks above - result.type = createAnonymousType(result, moduleType.members, emptyArray, emptyArray, moduleType.stringIndexInfo, moduleType.numberIndexInfo); + const resolvedModuleType = resolveStructuredTypeMembers(moduleType as StructuredType); // Should already be resolved from the signature checks above + result.type = createAnonymousType(result, resolvedModuleType.members, emptyArray, emptyArray, resolvedModuleType.stringIndexInfo, resolvedModuleType.numberIndexInfo); return result; } } diff --git a/src/services/codefixes/fixInvalidImportSyntax.ts b/src/services/codefixes/fixInvalidImportSyntax.ts index 30d190f7f9c6f..f98f1eaea7cc9 100644 --- a/src/services/codefixes/fixInvalidImportSyntax.ts +++ b/src/services/codefixes/fixInvalidImportSyntax.ts @@ -12,6 +12,10 @@ namespace ts.codefix { // import * as Bluebird from 'bluebird'; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ const node = getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false).parent as ImportDeclaration; + if (!isImportDeclaration(node)) { + // No import quick fix for import calls + return []; + } return getCodeFixesForImportDeclaration(context, node); } @@ -20,22 +24,6 @@ namespace ts.codefix { const namespace = getNamespaceDeclarationNode(node) as NamespaceImport; const opts = context.program.getCompilerOptions(); const variations: CodeAction[] = []; - if (opts.module === ModuleKind.CommonJS || (!opts.module && opts.target < ScriptTarget.ES2015)) { - // import Bluebird = require("bluebird"); - const replacement = createImportEqualsDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, - namespace.name, - createExternalModuleReference(node.moduleSpecifier) - ); - const changeTracker = textChanges.ChangeTracker.fromContext(context); - changeTracker.replaceNode(sourceFile, node, replacement, { useNonAdjustedEndPosition: true }); - const changes = changeTracker.getChanges(); - variations.push({ - description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Replace_import_with_0), [changes[0].textChanges[0].newText]), - changes - }); - } // import Bluebird from "bluebird"; const replacement = createImportDeclaration( @@ -52,6 +40,23 @@ namespace ts.codefix { changes }); + if (getEmitModuleKind(opts) === ModuleKind.CommonJS) { + // import Bluebird = require("bluebird"); + const replacement = createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + namespace.name, + createExternalModuleReference(node.moduleSpecifier) + ); + const changeTracker = textChanges.ChangeTracker.fromContext(context); + changeTracker.replaceNode(sourceFile, node, replacement, { useNonAdjustedEndPosition: true }); + const changes = changeTracker.getChanges(); + variations.push({ + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Replace_import_with_0), [changes[0].textChanges[0].newText]), + changes + }); + } + return variations; } @@ -66,7 +71,7 @@ namespace ts.codefix { function getActionsForUsageOfInvalidImport(context: CodeFixContext): CodeAction[] | undefined { const sourceFile = context.sourceFile; const targetKind = Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures.code === context.errorCode ? SyntaxKind.CallExpression : SyntaxKind.NewExpression; - let node = findAncestor(getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false), a => a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length)) as CallExpression | NewExpression; + const node = findAncestor(getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false), a => a.kind === targetKind && a.getStart() === context.span.start && a.getEnd() === (context.span.start + context.span.length)) as CallExpression | NewExpression; if (!node) { return []; } @@ -87,7 +92,7 @@ namespace ts.codefix { fixes.push({ description: getLocaleSpecificMessage(Diagnostics.Use_synthetic_default_member), changes - }) + }); return fixes; } } diff --git a/tests/cases/fourslash/codeFixCalledES2015Import1.ts b/tests/cases/fourslash/codeFixCalledES2015Import1.ts index dad2798a101c9..21ee169c1835c 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import1.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import1.ts @@ -14,5 +14,5 @@ goTo.file(1); verify.codeFix({ description: `Replace import with 'import foo = require("./foo");'.`, newRangeContent: `import foo = require("./foo");`, - index: 0, + index: 1, }); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import10.ts b/tests/cases/fourslash/codeFixCalledES2015Import10.ts new file mode 100644 index 0000000000000..273c81d45c98e --- /dev/null +++ b/tests/cases/fourslash/codeFixCalledES2015Import10.ts @@ -0,0 +1,18 @@ +/// +// @ESModuleInterop: true +// @Filename: foo.d.ts +////declare function foo(): void; +////declare namespace foo {} +////export = foo; + +// @Filename: index.ts +////import * as foo from "./foo"; +////[|foo()|]; + +goTo.file(1); +verify.codeFix({ + description: `Replace import with 'import foo = require("./foo");'.`, + newFileContent: `import foo = require("./foo"); +foo();`, + index: 1, +}); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import11.ts b/tests/cases/fourslash/codeFixCalledES2015Import11.ts new file mode 100644 index 0000000000000..6e9036ae05308 --- /dev/null +++ b/tests/cases/fourslash/codeFixCalledES2015Import11.ts @@ -0,0 +1,18 @@ +/// +// @ESModuleInterop: true +// @Filename: foo.d.ts +////declare function foo(): void; +////declare namespace foo {} +////export = foo; + +// @Filename: index.ts +////import * as foo from "./foo"; +////[|foo()|]; + +goTo.file(1); +verify.codeFix({ + description: `Replace import with 'import foo from "./foo";'.`, + newFileContent: `import foo from "./foo"; +foo();`, + index: 0, +}); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import12.ts b/tests/cases/fourslash/codeFixCalledES2015Import12.ts new file mode 100644 index 0000000000000..753a1751c451b --- /dev/null +++ b/tests/cases/fourslash/codeFixCalledES2015Import12.ts @@ -0,0 +1,18 @@ +/// +// @ESModuleInterop: true +// @Filename: foo.d.ts +////declare function foo(): void; +////declare namespace foo {} +////export = foo; + +// @Filename: index.ts +////import * as foo from "./foo"; +////[|foo()|]; + +goTo.file(1); +verify.codeFix({ + description: `Use synthetic 'default' member.`, + newFileContent: `import * as foo from "./foo"; +foo.default();`, + index: 4, +}); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import13.ts b/tests/cases/fourslash/codeFixCalledES2015Import13.ts new file mode 100644 index 0000000000000..8e1ea3d1e4287 --- /dev/null +++ b/tests/cases/fourslash/codeFixCalledES2015Import13.ts @@ -0,0 +1,18 @@ +/// +// @ESModuleInterop: true +// @Filename: foo.d.ts +////declare function foo(): void; +////declare namespace foo {} +////export = foo; + +// @Filename: index.ts +////import * as Foo from "./foo"; +////[|new Foo()|]; + +goTo.file(1); +verify.codeFix({ + description: `Use synthetic 'default' member.`, + newFileContent: `import * as Foo from "./foo"; +new Foo.default();`, + index: 2, +}); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import2.ts b/tests/cases/fourslash/codeFixCalledES2015Import2.ts index 2bacfe28c5e92..4b896db55164c 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import2.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import2.ts @@ -14,5 +14,5 @@ goTo.file(1); verify.codeFix({ description: `Replace import with 'import foo from "./foo";'.`, newRangeContent: `import foo from "./foo";`, - index: 1, + index: 0, }); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import4.ts b/tests/cases/fourslash/codeFixCalledES2015Import4.ts index f706a759e3de6..c812c3fd1fceb 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import4.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import4.ts @@ -13,5 +13,5 @@ goTo.file(1); verify.codeFix({ description: `Replace import with 'import foo = require("./foo");'.`, newRangeContent: `import foo = require("./foo");`, - index: 0, + index: 1, }); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import5.ts b/tests/cases/fourslash/codeFixCalledES2015Import5.ts index 17c30f31100d4..4b5f8b94f502b 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import5.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import5.ts @@ -13,5 +13,5 @@ goTo.file(1); verify.codeFix({ description: `Replace import with 'import foo from "./foo";'.`, newRangeContent: `import foo from "./foo";`, - index: 1, + index: 0, }); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import7.ts b/tests/cases/fourslash/codeFixCalledES2015Import7.ts index 543613673f629..664256a1a5fec 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import7.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import7.ts @@ -13,5 +13,5 @@ goTo.file(1); verify.codeFix({ description: `Replace import with 'import foo = require("./foo");'.`, newRangeContent: `import foo = require("./foo");`, - index: 0, + index: 1, }); diff --git a/tests/cases/fourslash/codeFixCalledES2015Import8.ts b/tests/cases/fourslash/codeFixCalledES2015Import8.ts index 9539398816ebd..842b6ca032c5f 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import8.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import8.ts @@ -13,5 +13,5 @@ goTo.file(1); verify.codeFix({ description: `Replace import with 'import foo from "./foo";'.`, newRangeContent: `import foo from "./foo";`, - index: 1, + index: 0, }); From 357996b5a8914036d807544445bc041a07a030fd Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 29 Nov 2017 13:19:11 -0800 Subject: [PATCH 18/26] Pair of spare tests for good measure --- .../reference/esModuleInteropImportCall.js | 23 ++++++++++++++++ .../esModuleInteropImportCall.symbols | 23 ++++++++++++++++ .../reference/esModuleInteropImportCall.types | 26 +++++++++++++++++++ .../esModuleInteropImportNamespace.js | 24 +++++++++++++++++ .../esModuleInteropImportNamespace.symbols | 19 ++++++++++++++ .../esModuleInteropImportNamespace.types | 19 ++++++++++++++ .../compiler/esModuleInteropImportCall.ts | 11 ++++++++ .../esModuleInteropImportNamespace.ts | 9 +++++++ 8 files changed, 154 insertions(+) create mode 100644 tests/baselines/reference/esModuleInteropImportCall.js create mode 100644 tests/baselines/reference/esModuleInteropImportCall.symbols create mode 100644 tests/baselines/reference/esModuleInteropImportCall.types create mode 100644 tests/baselines/reference/esModuleInteropImportNamespace.js create mode 100644 tests/baselines/reference/esModuleInteropImportNamespace.symbols create mode 100644 tests/baselines/reference/esModuleInteropImportNamespace.types create mode 100644 tests/cases/compiler/esModuleInteropImportCall.ts create mode 100644 tests/cases/compiler/esModuleInteropImportNamespace.ts diff --git a/tests/baselines/reference/esModuleInteropImportCall.js b/tests/baselines/reference/esModuleInteropImportCall.js new file mode 100644 index 0000000000000..2aa681ded7f92 --- /dev/null +++ b/tests/baselines/reference/esModuleInteropImportCall.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/esModuleInteropImportCall.ts] //// + +//// [foo.d.ts] +declare function foo(): void; +declare namespace foo {} +export = foo; + +//// [index.ts] +import("./foo").then(f => { + f.default; +}); + +//// [index.js] +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +} +Promise.resolve().then(function () { return __importStar(require("./foo")); }).then(function (f) { + f["default"]; +}); diff --git a/tests/baselines/reference/esModuleInteropImportCall.symbols b/tests/baselines/reference/esModuleInteropImportCall.symbols new file mode 100644 index 0000000000000..58c5e066f863a --- /dev/null +++ b/tests/baselines/reference/esModuleInteropImportCall.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/foo.d.ts === +declare function foo(): void; +>foo : Symbol(foo, Decl(foo.d.ts, 0, 0), Decl(foo.d.ts, 0, 29)) + +declare namespace foo {} +>foo : Symbol(foo, Decl(foo.d.ts, 0, 0), Decl(foo.d.ts, 0, 29)) + +export = foo; +>foo : Symbol(foo, Decl(foo.d.ts, 0, 0), Decl(foo.d.ts, 0, 29)) + +=== tests/cases/compiler/index.ts === +import("./foo").then(f => { +>import("./foo").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>"./foo" : Symbol("tests/cases/compiler/foo", Decl(foo.d.ts, 0, 0)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>f : Symbol(f, Decl(index.ts, 0, 21)) + + f.default; +>f.default : Symbol(default) +>f : Symbol(f, Decl(index.ts, 0, 21)) +>default : Symbol(default) + +}); diff --git a/tests/baselines/reference/esModuleInteropImportCall.types b/tests/baselines/reference/esModuleInteropImportCall.types new file mode 100644 index 0000000000000..c194af96c53d6 --- /dev/null +++ b/tests/baselines/reference/esModuleInteropImportCall.types @@ -0,0 +1,26 @@ +=== tests/cases/compiler/foo.d.ts === +declare function foo(): void; +>foo : () => void + +declare namespace foo {} +>foo : () => void + +export = foo; +>foo : () => void + +=== tests/cases/compiler/index.ts === +import("./foo").then(f => { +>import("./foo").then(f => { f.default;}) : Promise +>import("./foo").then : void; }, TResult2 = never>(onfulfilled?: (value: { default: () => void; }) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>import("./foo") : Promise<{ default: () => void; }> +>"./foo" : "./foo" +>then : void; }, TResult2 = never>(onfulfilled?: (value: { default: () => void; }) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>f => { f.default;} : (f: { default: () => void; }) => void +>f : { default: () => void; } + + f.default; +>f.default : () => void +>f : { default: () => void; } +>default : () => void + +}); diff --git a/tests/baselines/reference/esModuleInteropImportNamespace.js b/tests/baselines/reference/esModuleInteropImportNamespace.js new file mode 100644 index 0000000000000..605976faaaa78 --- /dev/null +++ b/tests/baselines/reference/esModuleInteropImportNamespace.js @@ -0,0 +1,24 @@ +//// [tests/cases/compiler/esModuleInteropImportNamespace.ts] //// + +//// [foo.d.ts] +declare function foo(): void; +declare namespace foo {} +export = foo; + +//// [index.ts] +import * as foo from "./foo"; +foo.default; + + +//// [index.js] +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +} +exports.__esModule = true; +var foo = __importStar(require("./foo")); +foo["default"]; diff --git a/tests/baselines/reference/esModuleInteropImportNamespace.symbols b/tests/baselines/reference/esModuleInteropImportNamespace.symbols new file mode 100644 index 0000000000000..d381d55356855 --- /dev/null +++ b/tests/baselines/reference/esModuleInteropImportNamespace.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/foo.d.ts === +declare function foo(): void; +>foo : Symbol(foo, Decl(foo.d.ts, 0, 0), Decl(foo.d.ts, 0, 29)) + +declare namespace foo {} +>foo : Symbol(foo, Decl(foo.d.ts, 0, 0), Decl(foo.d.ts, 0, 29)) + +export = foo; +>foo : Symbol(foo, Decl(foo.d.ts, 0, 0), Decl(foo.d.ts, 0, 29)) + +=== tests/cases/compiler/index.ts === +import * as foo from "./foo"; +>foo : Symbol(foo, Decl(index.ts, 0, 6)) + +foo.default; +>foo.default : Symbol(default) +>foo : Symbol(foo, Decl(index.ts, 0, 6)) +>default : Symbol(default) + diff --git a/tests/baselines/reference/esModuleInteropImportNamespace.types b/tests/baselines/reference/esModuleInteropImportNamespace.types new file mode 100644 index 0000000000000..e0a49db2794c0 --- /dev/null +++ b/tests/baselines/reference/esModuleInteropImportNamespace.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/foo.d.ts === +declare function foo(): void; +>foo : () => void + +declare namespace foo {} +>foo : () => void + +export = foo; +>foo : () => void + +=== tests/cases/compiler/index.ts === +import * as foo from "./foo"; +>foo : { default: () => void; } + +foo.default; +>foo.default : () => void +>foo : { default: () => void; } +>default : () => void + diff --git a/tests/cases/compiler/esModuleInteropImportCall.ts b/tests/cases/compiler/esModuleInteropImportCall.ts new file mode 100644 index 0000000000000..6fee4a84cb7e4 --- /dev/null +++ b/tests/cases/compiler/esModuleInteropImportCall.ts @@ -0,0 +1,11 @@ +// @ESModuleInterop: true +// @lib: es6 +// @Filename: foo.d.ts +declare function foo(): void; +declare namespace foo {} +export = foo; + +// @Filename: index.ts +import("./foo").then(f => { + f.default; +}); \ No newline at end of file diff --git a/tests/cases/compiler/esModuleInteropImportNamespace.ts b/tests/cases/compiler/esModuleInteropImportNamespace.ts new file mode 100644 index 0000000000000..e99909ea2bc06 --- /dev/null +++ b/tests/cases/compiler/esModuleInteropImportNamespace.ts @@ -0,0 +1,9 @@ +// @ESModuleInterop: true +// @Filename: foo.d.ts +declare function foo(): void; +declare namespace foo {} +export = foo; + +// @Filename: index.ts +import * as foo from "./foo"; +foo.default; From 6e9e87453f3b11f3288dc8cb2677fcb203f6dfc7 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 5 Jan 2018 10:00:06 -0800 Subject: [PATCH 19/26] Fix typos in diagnostic message --- src/compiler/commandLineParser.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- .../cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 780500a14f0a7..1c9c5b8a65e28 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -405,7 +405,7 @@ namespace ts { type: "boolean", showInSimplifiedHelpView: true, category: Diagnostics.Module_Resolution_Options, - description: Diagnostics.Enables_emit_interoperability_bewteen_commonjs_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports + description: Diagnostics.Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports }, { name: "preserveSymlinks", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 6e9a541c54730..34e0e70c44b73 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3536,7 +3536,7 @@ "category": "Error", "code": 7036 }, - "Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`.": { + "Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'.": { "category": "Message", "code": 7037 }, diff --git a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter index 9c8f67f596e23..40bdb4eadabc9 160000 --- a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter +++ b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter @@ -1 +1 @@ -Subproject commit 9c8f67f596e23283f7fe452d67372233d2e4e5d6 +Subproject commit 40bdb4eadabc9fbed7d83e3f26817a931c0763b6 From a654b822b8cbcabd62be6091ead160107559715f Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 5 Jan 2018 10:01:31 -0800 Subject: [PATCH 20/26] Improve comment clarity --- src/compiler/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 65ac32ca99d70..8725652f1d60b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3225,7 +3225,7 @@ namespace ts { bindingElement?: BindingElement; // Binding element associated with property symbol exportsSomeValue?: boolean; // True if module exports some value (not just types) enumKind?: EnumKind; // Enum declaration classification - originatingImport?: ImportDeclaration | ImportCall; // Import declaration which produced the symbol, present if the symbol is poisoned + originatingImport?: ImportDeclaration | ImportCall; // Import declaration which produced the symbol, present if the symbol is marked as uncallable but had call signatures in `resolveESModuleSymbol` lateSymbol?: Symbol; // Late-bound symbol for a computed property } From ef6faf19ffce6dbbf49a8451cc7bc52379b11fa8 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Sun, 7 Jan 2018 20:11:02 -0800 Subject: [PATCH 21/26] Actually accept the updated changes to the esmodule interop description --- .../tsConfig/Default initialized TSConfig/tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../Initialized TSConfig with files options/tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index 984a54373a07a..7cb40e899d6b5 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index 45e0292cea450..362a2693e1216 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index c08a98bcad294..98e677450f608 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index 621791b12ac28..362dde2fc5453 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index fde3c0c68d76b..30ce690c3c2a8 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index 984a54373a07a..7cb40e899d6b5 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index 60e4bc94c5525..7314b420a5433 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index ef6de1234feea..38882d20360ea 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ "types": ["jquery","mocha"], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Enables emit interoperability bewteen commonjs and ES Modules via creation of namespace objects for all imports. Implies `allowSyntheticDefaultImports`. */ + "ESModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ From a8233b37ab2cae59358b689eb7805854ab06fbfd Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Sun, 7 Jan 2018 20:46:58 -0800 Subject: [PATCH 22/26] ESModule -> esModule --- src/compiler/checker.ts | 2 +- src/compiler/commandLineParser.ts | 4 ++-- src/compiler/core.ts | 2 +- src/compiler/transformers/module/module.ts | 6 +++--- src/compiler/types.ts | 2 +- tests/baselines/reference/api/tsserverlibrary.d.ts | 2 +- tests/baselines/reference/api/typescript.d.ts | 2 +- .../tsConfig/Default initialized TSConfig/tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../Initialized TSConfig with files options/tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- tests/cases/compiler/esModuleInterop.ts | 2 +- tests/cases/compiler/esModuleInteropImportCall.ts | 2 +- tests/cases/compiler/esModuleInteropImportNamespace.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import1.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import10.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import11.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import12.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import13.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import2.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import3.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import4.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import5.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import6.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import7.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import8.ts | 2 +- tests/cases/fourslash/codeFixCalledES2015Import9.ts | 2 +- 31 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6c9e0834b75fa..c794adefc334c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1928,7 +1928,7 @@ namespace ts { error(moduleReferenceExpression, Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); return symbol; } - if (compilerOptions.ESModuleInterop) { + if (compilerOptions.esModuleInterop) { const referenceParent = moduleReferenceExpression.parent; if ( (referenceParent.kind === SyntaxKind.ImportDeclaration && getNamespaceDeclarationNode(referenceParent as ImportDeclaration)) || diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 1c9c5b8a65e28..d173059a549c5 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -401,7 +401,7 @@ namespace ts { description: Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking }, { - name: "ESModuleInterop", + name: "esModuleInterop", type: "boolean", showInSimplifiedHelpView: true, category: Diagnostics.Module_Resolution_Options, @@ -710,7 +710,7 @@ namespace ts { module: ModuleKind.CommonJS, target: ScriptTarget.ES5, strict: true, - ESModuleInterop: true + esModuleInterop: true }; let optionNameMapCache: OptionNameMap; diff --git a/src/compiler/core.ts b/src/compiler/core.ts index cc4a283fdc815..c94b36372ec6f 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2016,7 +2016,7 @@ namespace ts { const moduleKind = getEmitModuleKind(compilerOptions); return compilerOptions.allowSyntheticDefaultImports !== undefined ? compilerOptions.allowSyntheticDefaultImports - : compilerOptions.ESModuleInterop + : compilerOptions.esModuleInterop ? moduleKind !== ModuleKind.None && moduleKind < ModuleKind.ES2015 : moduleKind === ModuleKind.System; } diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index d53dfc989cfe6..7fc645490978b 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -639,7 +639,7 @@ namespace ts { } const promise = createNew(createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); - if (compilerOptions.ESModuleInterop) { + if (compilerOptions.esModuleInterop) { context.requestEmitHelper(importStarHelper); return createCall(createPropertyAccess(promise, createIdentifier("then")), /*typeArguments*/ undefined, [getHelperName("__importStar")]); } @@ -654,7 +654,7 @@ namespace ts { // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately const promiseResolveCall = createCall(createPropertyAccess(createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []); let requireCall = createCall(createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); - if (compilerOptions.ESModuleInterop) { + if (compilerOptions.esModuleInterop) { context.requestEmitHelper(importStarHelper); requireCall = createCall(getHelperName("__importStar"), /*typeArguments*/ undefined, [requireCall]); } @@ -692,7 +692,7 @@ namespace ts { function getHelperExpressionForImport(node: ImportDeclaration, innerExpr: Expression) { - if (!compilerOptions.ESModuleInterop || node.transformFlags & TransformFlags.NeverApplyImportHelper) { + if (!compilerOptions.esModuleInterop || node.transformFlags & TransformFlags.NeverApplyImportHelper) { return innerExpr; } if (getNamespaceDeclarationNode(node)) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 8725652f1d60b..2abd2931eb270 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3942,7 +3942,7 @@ namespace ts { typeRoots?: string[]; /*@internal*/ version?: boolean; /*@internal*/ watch?: boolean; - ESModuleInterop?: boolean; + esModuleInterop?: boolean; [option: string]: CompilerOptionsValue | JsonSourceFile | undefined; } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 51e3856c6ef9b..08d93eb2ace10 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2294,7 +2294,7 @@ declare namespace ts { types?: string[]; /** Paths used to compute primary types search locations */ typeRoots?: string[]; - ESModuleInterop?: boolean; + esModuleInterop?: boolean; [option: string]: CompilerOptionsValue | JsonSourceFile | undefined; } interface TypeAcquisition { diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 1214665578f30..6a71244f84ca7 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2294,7 +2294,7 @@ declare namespace ts { types?: string[]; /** Paths used to compute primary types search locations */ typeRoots?: string[]; - ESModuleInterop?: boolean; + esModuleInterop?: boolean; [option: string]: CompilerOptionsValue | JsonSourceFile | undefined; } interface TypeAcquisition { diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index 7cb40e899d6b5..26cf24cc2e46d 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index 362a2693e1216..5d7960c825419 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index 98e677450f608..353cb68ea959f 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index 362dde2fc5453..4a28e6f2491a0 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 30ce690c3c2a8..46ae199430d0b 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index 7cb40e899d6b5..26cf24cc2e46d 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index 7314b420a5433..069305e2d35b5 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index 38882d20360ea..9e1c409f56e1b 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -41,7 +41,7 @@ // "typeRoots": [], /* List of folders to include type definitions from. */ "types": ["jquery","mocha"], /* Type declaration files to be included in compilation. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "ESModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ + "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ /* Source Map Options */ diff --git a/tests/cases/compiler/esModuleInterop.ts b/tests/cases/compiler/esModuleInterop.ts index d8123990ac6f8..7dfd8ff8611d0 100644 --- a/tests/cases/compiler/esModuleInterop.ts +++ b/tests/cases/compiler/esModuleInterop.ts @@ -1,4 +1,4 @@ -// @ESModuleInterop: true +// @esModuleInterop: true // @filename: hybrid/index.d.ts export function sayHello(): string; // @filename: path.d.ts diff --git a/tests/cases/compiler/esModuleInteropImportCall.ts b/tests/cases/compiler/esModuleInteropImportCall.ts index 6fee4a84cb7e4..759d4f3f9368b 100644 --- a/tests/cases/compiler/esModuleInteropImportCall.ts +++ b/tests/cases/compiler/esModuleInteropImportCall.ts @@ -1,4 +1,4 @@ -// @ESModuleInterop: true +// @esModuleInterop: true // @lib: es6 // @Filename: foo.d.ts declare function foo(): void; diff --git a/tests/cases/compiler/esModuleInteropImportNamespace.ts b/tests/cases/compiler/esModuleInteropImportNamespace.ts index e99909ea2bc06..0b3c92577ef6c 100644 --- a/tests/cases/compiler/esModuleInteropImportNamespace.ts +++ b/tests/cases/compiler/esModuleInteropImportNamespace.ts @@ -1,4 +1,4 @@ -// @ESModuleInterop: true +// @esModuleInterop: true // @Filename: foo.d.ts declare function foo(): void; declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import1.ts b/tests/cases/fourslash/codeFixCalledES2015Import1.ts index 21ee169c1835c..45e88c190478d 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import1.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import1.ts @@ -1,5 +1,5 @@ /// -// @ESModuleInterop: true +// @esModuleInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import10.ts b/tests/cases/fourslash/codeFixCalledES2015Import10.ts index 273c81d45c98e..d82e345c56ce5 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import10.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import10.ts @@ -1,5 +1,5 @@ /// -// @ESModuleInterop: true +// @esModuleInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import11.ts b/tests/cases/fourslash/codeFixCalledES2015Import11.ts index 6e9036ae05308..14b02fa38bcf3 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import11.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import11.ts @@ -1,5 +1,5 @@ /// -// @ESModuleInterop: true +// @esModuleInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import12.ts b/tests/cases/fourslash/codeFixCalledES2015Import12.ts index 753a1751c451b..6c31531d572ef 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import12.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import12.ts @@ -1,5 +1,5 @@ /// -// @ESModuleInterop: true +// @esModuleInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import13.ts b/tests/cases/fourslash/codeFixCalledES2015Import13.ts index 8e1ea3d1e4287..a67371bd46a96 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import13.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import13.ts @@ -1,5 +1,5 @@ /// -// @ESModuleInterop: true +// @esModuleInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import2.ts b/tests/cases/fourslash/codeFixCalledES2015Import2.ts index 4b896db55164c..80040cb419287 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import2.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import2.ts @@ -1,5 +1,5 @@ /// -// @ESModuleInterop: true +// @esModuleInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import3.ts b/tests/cases/fourslash/codeFixCalledES2015Import3.ts index c9b07ede38cdd..82f08fbc22f0b 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import3.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import3.ts @@ -1,5 +1,5 @@ /// -// @ESModuleInterop: true +// @esModuleInterop: true // @module: amd // @Filename: foo.d.ts ////declare function foo(): void; diff --git a/tests/cases/fourslash/codeFixCalledES2015Import4.ts b/tests/cases/fourslash/codeFixCalledES2015Import4.ts index c812c3fd1fceb..ba6d90d6d411f 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import4.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import4.ts @@ -1,5 +1,5 @@ /// -// @ESModuleInterop: true +// @esModuleInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import5.ts b/tests/cases/fourslash/codeFixCalledES2015Import5.ts index 4b5f8b94f502b..63b2137b6efbb 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import5.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import5.ts @@ -1,5 +1,5 @@ /// -// @ESModuleInterop: true +// @esModuleInterop: true // @Filename: foo.d.ts ////declare function foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import6.ts b/tests/cases/fourslash/codeFixCalledES2015Import6.ts index d0422fe4eeb29..b741831bce96b 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import6.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import6.ts @@ -1,5 +1,5 @@ /// -// @ESModuleInterop: true +// @esModuleInterop: true // @module: amd // @Filename: foo.d.ts ////declare function foo(): void; diff --git a/tests/cases/fourslash/codeFixCalledES2015Import7.ts b/tests/cases/fourslash/codeFixCalledES2015Import7.ts index 664256a1a5fec..070a25254cb13 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import7.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import7.ts @@ -1,5 +1,5 @@ /// -// @ESModuleInterop: true +// @esModuleInterop: true // @Filename: foo.d.ts ////declare class foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import8.ts b/tests/cases/fourslash/codeFixCalledES2015Import8.ts index 842b6ca032c5f..41e547c8abb39 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import8.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import8.ts @@ -1,5 +1,5 @@ /// -// @ESModuleInterop: true +// @esModuleInterop: true // @Filename: foo.d.ts ////declare class foo(): void; ////declare namespace foo {} diff --git a/tests/cases/fourslash/codeFixCalledES2015Import9.ts b/tests/cases/fourslash/codeFixCalledES2015Import9.ts index d509bb90e7c46..1ce110f056a0b 100644 --- a/tests/cases/fourslash/codeFixCalledES2015Import9.ts +++ b/tests/cases/fourslash/codeFixCalledES2015Import9.ts @@ -1,5 +1,5 @@ /// -// @ESModuleInterop: true +// @esModuleInterop: true // @module: amd // @Filename: foo.d.ts ////declare class foo(): void; From f4f4e84829f6bde7acfc08eb46592222773a00ca Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Sun, 7 Jan 2018 21:19:28 -0800 Subject: [PATCH 23/26] Use find and not forEach --- src/compiler/checker.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c794adefc334c..10e57ea614178 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1513,7 +1513,7 @@ namespace ts { exportDefaultSymbol = resolveExportByName(moduleSymbol, InternalSymbolName.Default, dontResolveAlias); } - const file = forEach(moduleSymbol.declarations, sourceFileOrUndefined); + const file = find(moduleSymbol.declarations, isSourceFile); const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias); if (!exportDefaultSymbol && !hasSyntheticDefault) { error(node.name, Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); @@ -1526,10 +1526,6 @@ namespace ts { } } - function sourceFileOrUndefined(d: Declaration) { - return isSourceFile(d) ? d : undefined; - } - function getTargetOfNamespaceImport(node: NamespaceImport, dontResolveAlias: boolean): Symbol { const moduleSpecifier = (node.parent.parent).moduleSpecifier; return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); @@ -17839,7 +17835,8 @@ namespace ts { if (allowSyntheticDefaultImports && type && type !== unknownType) { const synthType = type as SyntheticDefaultModuleType; if (!synthType.syntheticType) { - const hasSyntheticDefault = canHaveSyntheticDefault(forEach(originalSymbol.declarations, sourceFileOrUndefined), originalSymbol, /*dontResolveAlias*/ false); + const file = find(originalSymbol.declarations, isSourceFile); + const hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false); if (hasSyntheticDefault) { const memberTable = createSymbolTable(); const newSymbol = createSymbol(SymbolFlags.Alias, InternalSymbolName.Default); From 386c54db476c9db8844089c499247df2c4b3f2fa Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Sun, 7 Jan 2018 21:26:37 -0800 Subject: [PATCH 24/26] Use guard --- src/compiler/checker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 10e57ea614178..02d3064fd60aa 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1927,7 +1927,7 @@ namespace ts { if (compilerOptions.esModuleInterop) { const referenceParent = moduleReferenceExpression.parent; if ( - (referenceParent.kind === SyntaxKind.ImportDeclaration && getNamespaceDeclarationNode(referenceParent as ImportDeclaration)) || + (isImportDeclaration(referenceParent) && getNamespaceDeclarationNode(referenceParent)) || isImportCall(referenceParent) ) { const type = getTypeOfSymbol(symbol); @@ -1942,7 +1942,7 @@ namespace ts { result.declarations = symbol.declarations ? symbol.declarations.slice() : []; result.parent = symbol.parent; result.target = symbol; - result.originatingImport = referenceParent as ImportDeclaration | ImportCall; + result.originatingImport = referenceParent; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; if (symbol.constEnumOnlyModule) result.constEnumOnlyModule = true; if (symbol.members) result.members = cloneMap(symbol.members); From 2663db76b7b91652b6666bf2d517ace7f8c7236d Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Sun, 7 Jan 2018 21:51:00 -0800 Subject: [PATCH 25/26] Rely on implicit falsiness of Result.False --- src/compiler/checker.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 02d3064fd60aa..0089854f0b8a5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9470,9 +9470,8 @@ namespace ts { diagnostics.add(createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); } - const answer = result !== Ternary.False; // Check if we should issue an extra diagnostic to produce a quickfix for a slightly incorrect import statement - if (headMessage && errorNode && !answer && source.symbol) { + if (headMessage && errorNode && !result && source.symbol) { const links = getSymbolLinks(source.symbol); if (links.originatingImport && !isImportCall(links.originatingImport)) { const helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, /*errorNode*/ undefined); @@ -9482,7 +9481,7 @@ namespace ts { } } } - return answer; + return result !== Ternary.False; function reportError(message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): void { Debug.assert(!!errorNode); From 8068e2e6ff3b4589a8a39b42f1b9b069df3347e3 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Sun, 7 Jan 2018 22:20:31 -0800 Subject: [PATCH 26/26] These should have been emit flags --- src/compiler/program.ts | 2 +- src/compiler/transformers/module/es2015.ts | 2 +- src/compiler/transformers/module/module.ts | 2 +- src/compiler/transformers/utilities.ts | 2 +- src/compiler/types.ts | 3 +-- src/compiler/visitor.ts | 2 -- 6 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index eee1eaab22544..ad24281f67b9d 100755 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1589,7 +1589,7 @@ namespace ts { // synthesize 'import "tslib"' declaration const externalHelpersModuleReference = createLiteral(externalHelpersModuleNameText); const importDecl = createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined); - importDecl.transformFlags |= TransformFlags.NeverApplyImportHelper; + addEmitFlags(importDecl, EmitFlags.NeverApplyImportHelper); externalHelpersModuleReference.parent = importDecl; importDecl.parent = file; imports = [externalHelpersModuleReference]; diff --git a/src/compiler/transformers/module/es2015.ts b/src/compiler/transformers/module/es2015.ts index c583ccf277afc..4f218e4fdcf11 100644 --- a/src/compiler/transformers/module/es2015.ts +++ b/src/compiler/transformers/module/es2015.ts @@ -31,7 +31,7 @@ namespace ts { createImportClause(/*name*/ undefined, createNamespaceImport(externalHelpersModuleName)), createLiteral(externalHelpersModuleNameText) ); - tslibImport.transformFlags |= TransformFlags.NeverApplyImportHelper; + addEmitFlags(tslibImport, EmitFlags.NeverApplyImportHelper); append(statements, tslibImport); addRange(statements, visitNodes(node.statements, visitor, isStatement, statementOffset)); diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 7fc645490978b..0d4e5b6864acf 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -692,7 +692,7 @@ namespace ts { function getHelperExpressionForImport(node: ImportDeclaration, innerExpr: Expression) { - if (!compilerOptions.esModuleInterop || node.transformFlags & TransformFlags.NeverApplyImportHelper) { + if (!compilerOptions.esModuleInterop || getEmitFlags(node) & EmitFlags.NeverApplyImportHelper) { return innerExpr; } if (getNamespaceDeclarationNode(node)) { diff --git a/src/compiler/transformers/utilities.ts b/src/compiler/transformers/utilities.ts index ef53781028af6..15e91d755caf7 100644 --- a/src/compiler/transformers/utilities.ts +++ b/src/compiler/transformers/utilities.ts @@ -143,7 +143,7 @@ namespace ts { createLiteral(externalHelpersModuleNameText)); if (externalHelpersImportDeclaration) { - externalHelpersImportDeclaration.transformFlags |= TransformFlags.NeverApplyImportHelper; + addEmitFlags(externalHelpersImportDeclaration, EmitFlags.NeverApplyImportHelper); externalImports.unshift(externalHelpersImportDeclaration); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 2abd2931eb270..ac8ded7c3b2c9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4413,7 +4413,6 @@ namespace ts { ContainsYield = 1 << 24, ContainsHoistedDeclarationOrCompletion = 1 << 25, ContainsDynamicImport = 1 << 26, - NeverApplyImportHelper = 1 << 27, // Indicates the node should never be wrapped with an import star helper (because, for example, it import tslib itself) // Please leave this as 1 << 29. // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system. @@ -4453,7 +4452,6 @@ namespace ts { // - Additional bitmasks TypeScriptClassSyntaxMask = ContainsParameterPropertyAssignments | ContainsPropertyInitializer | ContainsDecorators, ES2015FunctionSyntaxMask = ContainsCapturedLexicalThis | ContainsDefaultValueAssignments, - StickyFlags = NeverApplyImportHelper, // Flags which once set are retained by `aggregateTransformFlags` instead of overwritten } export interface SourceMapRange extends TextRange { @@ -4512,6 +4510,7 @@ namespace ts { Iterator = 1 << 23, // The expression to a `yield*` should be treated as an Iterator when down-leveling, not an Iterable. NoAsciiEscaping = 1 << 24, // When synthesizing nodes that lack an original node or textSourceNode, we want to write the text on the node with ASCII escaping substitutions. /*@internal*/ TypeScriptClassWrapper = 1 << 25, // The node is an IIFE class wrapper created by the ts transform. + /*@internal*/ NeverApplyImportHelper = 1 << 26, // Indicates the node should never be wrapped with an import star helper (because, for example, it imports tslib itself) } export interface EmitHelper { diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index f04c3b567af41..0b40e20a7b7c1 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -1466,9 +1466,7 @@ namespace ts { * Aggregates the TransformFlags for a Node and its subtree. */ export function aggregateTransformFlags(node: T): T { - const stickyFlags = node.transformFlags & TransformFlags.StickyFlags; aggregateTransformFlagsForNode(node); - node.transformFlags |= stickyFlags; return node; }