From bc50c7536eabacca7de134f861d9fbb9933f31ca Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 13 Dec 2023 16:36:00 -0800 Subject: [PATCH 01/31] Add --module preserve --- src/compiler/checker.ts | 3 +- src/compiler/commandLineParser.ts | 1 + src/compiler/diagnosticMessages.json | 4 +-- src/compiler/program.ts | 9 +++--- src/compiler/transformer.ts | 1 + .../transformers/module/esnextAnd2015.ts | 28 +++++++++++++++++-- src/compiler/types.ts | 3 ++ src/compiler/utilities.ts | 18 ++++++------ src/services/codefixes/importFixes.ts | 1 + tests/baselines/reference/modulePreserve1.js | 25 +++++++++++++++++ .../reference/modulePreserve1.symbols | 21 ++++++++++++++ .../baselines/reference/modulePreserve1.types | 22 +++++++++++++++ tests/cases/compiler/modulePreserve1.ts | 13 +++++++++ 13 files changed, 128 insertions(+), 21 deletions(-) create mode 100644 tests/baselines/reference/modulePreserve1.js create mode 100644 tests/baselines/reference/modulePreserve1.symbols create mode 100644 tests/baselines/reference/modulePreserve1.types create mode 100644 tests/cases/compiler/modulePreserve1.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 34454f3906edc..810c91b334b96 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -45849,7 +45849,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } else { - if (moduleKind >= ModuleKind.ES2015 && getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & NodeFlags.Ambient)) { + if (moduleKind >= ModuleKind.ES2015 && moduleKind !== ModuleKind.Preserve && getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & NodeFlags.Ambient)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -46135,6 +46135,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Forbid export= in esm implementation files, and esm mode declaration files if ( moduleKind >= ModuleKind.ES2015 && + moduleKind !== ModuleKind.Preserve && ((node.flags & NodeFlags.Ambient && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.ESNext) || (!(node.flags & NodeFlags.Ambient) && getSourceFileOfNode(node).impliedNodeFormat !== ModuleKind.CommonJS)) ) { diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index decc8751453a6..359587bdeb669 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -556,6 +556,7 @@ export const moduleOptionDeclaration: CommandLineOptionOfCustomType = { esnext: ModuleKind.ESNext, node16: ModuleKind.Node16, nodenext: ModuleKind.NodeNext, + preserve: ModuleKind.Preserve, })), affectsSourceFile: true, affectsModuleResolution: true, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8a16147b63381..e2e45a5911769 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4293,7 +4293,7 @@ "category": "Error", "code": 5070 }, - "Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'.": { + "Option '--resolveJsonModule' cannot be specified when 'module' is set to 'none', 'system', or 'umd'.": { "category": "Error", "code": 5071 }, @@ -4385,7 +4385,7 @@ "category": "Error", "code": 5094 }, - "Option '{0}' can only be used when 'module' is set to 'es2015' or later.": { + "Option '{0}' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.": { "category": "Error", "code": 5095 }, diff --git a/src/compiler/program.ts b/src/compiler/program.ts index b92bfa27b6576..cfc2de0a0f4ed 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -4323,9 +4323,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg if (getEmitModuleResolutionKind(options) === ModuleResolutionKind.Classic) { createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_cannot_be_specified_when_moduleResolution_is_set_to_classic, "resolveJsonModule"); } - // Any emit other than common js, amd, es2015 or esnext is error else if (!hasJsonModuleEmitEnabled(options)) { - createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module"); + createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_cannot_be_specified_when_module_is_set_to_none_system_or_umd, "resolveJsonModule", "module"); } } @@ -4411,7 +4410,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg } if (options.preserveValueImports && getEmitModuleKind(options) < ModuleKind.ES2015) { - createDiagnosticForOptionName(Diagnostics.Option_0_can_only_be_used_when_module_is_set_to_es2015_or_later, "preserveValueImports"); + createDiagnosticForOptionName(Diagnostics.Option_0_can_only_be_used_when_module_is_set_to_preserve_or_to_es2015_or_later, "preserveValueImports"); } const moduleKind = getEmitModuleKind(options); @@ -4442,8 +4441,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg createDiagnosticForOptionName(Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler, "customConditions"); } - if (moduleResolution === ModuleResolutionKind.Bundler && !emitModuleKindIsNonNodeESM(moduleKind)) { - createOptionValueDiagnostic("moduleResolution", Diagnostics.Option_0_can_only_be_used_when_module_is_set_to_es2015_or_later, "bundler"); + if (moduleResolution === ModuleResolutionKind.Bundler && !emitModuleKindIsNonNodeESM(moduleKind) && moduleKind !== ModuleKind.Preserve) { + createOptionValueDiagnostic("moduleResolution", Diagnostics.Option_0_can_only_be_used_when_module_is_set_to_preserve_or_to_es2015_or_later, "bundler"); } if ( diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 3a37fe0f2d3f4..bb49cee8e4735 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -82,6 +82,7 @@ function getModuleTransformer(moduleKind: ModuleKind): TransformerFactory { - // Elide `export=` as it is not legal with --module ES6 - return node.isExportEquals ? undefined : node; + function visitExportAssignment(node: ExportAssignment): VisitResult { + if (node.isExportEquals) { + if (getEmitModuleKind(compilerOptions) === ModuleKind.Preserve) { + const statement = setOriginalNode( + factory.createExpressionStatement( + factory.createAssignment( + factory.createPropertyAccessExpression( + factory.createIdentifier("module"), + "exports", + ), + node.expression, + ), + ), + node, + ); + return statement; + } + // Elide `export=` as it is not legal with --module ES6 + return undefined; + } + return node; } function visitExportDeclaration(node: ExportDeclaration) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6b7548280c60f..69c8800cef93b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -7294,6 +7294,9 @@ export enum ModuleKind { // Node16+ is an amalgam of commonjs (albeit updated) and es2022+, and represents a distinct module system from es2020/esnext Node16 = 100, NodeNext = 199, + + // Emit as written + Preserve = 200, } export const enum JsxEmit { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 347be386b6b32..12a7905047f66 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -8633,6 +8633,9 @@ export const computedOptions = createComputedCompilerOptions({ case ModuleKind.NodeNext: moduleResolution = ModuleResolutionKind.NodeNext; break; + case ModuleKind.Preserve: + moduleResolution = ModuleResolutionKind.Bundler; + break; default: moduleResolution = ModuleResolutionKind.Classic; break; @@ -8664,6 +8667,7 @@ export const computedOptions = createComputedCompilerOptions({ switch (computedOptions.module.computeValue(compilerOptions)) { case ModuleKind.Node16: case ModuleKind.NodeNext: + case ModuleKind.Preserve: return true; } return false; @@ -8856,18 +8860,12 @@ export function emitModuleKindIsNonNodeESM(moduleKind: ModuleKind) { /** @internal */ export function hasJsonModuleEmitEnabled(options: CompilerOptions) { switch (getEmitModuleKind(options)) { - case ModuleKind.CommonJS: - case ModuleKind.AMD: - case ModuleKind.ES2015: - case ModuleKind.ES2020: - case ModuleKind.ES2022: - case ModuleKind.ESNext: - case ModuleKind.Node16: - case ModuleKind.NodeNext: - return true; - default: + case ModuleKind.None: + case ModuleKind.System: + case ModuleKind.UMD: return false; } + return true; } /** @internal */ diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 97c5bca540b54..98b9a46ef2b82 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -1159,6 +1159,7 @@ function getUmdImportKind(importingFile: SourceFile, compilerOptions: CompilerOp case ModuleKind.ES2022: case ModuleKind.ESNext: case ModuleKind.None: + case ModuleKind.Preserve: // Fall back to the `import * as ns` style import. return ImportKind.Namespace; case ModuleKind.Node16: diff --git a/tests/baselines/reference/modulePreserve1.js b/tests/baselines/reference/modulePreserve1.js new file mode 100644 index 0000000000000..8cb4e5237baaf --- /dev/null +++ b/tests/baselines/reference/modulePreserve1.js @@ -0,0 +1,25 @@ +//// [tests/cases/compiler/modulePreserve1.ts] //// + +//// [a.ts] +export class A {} + +//// [b.ts] +export = class B {} + +//// [main.ts] +import { A } from "./a"; +import B = require("./b"); +export { A, B }; + + +//// [a.js] +export class A { +} +//// [b.js] +module.exports = class B { +}; +export {}; +//// [main.js] +import { A } from "./a"; +const B = require("./b"); +export { A, B }; diff --git a/tests/baselines/reference/modulePreserve1.symbols b/tests/baselines/reference/modulePreserve1.symbols new file mode 100644 index 0000000000000..2e5f426bdf6a9 --- /dev/null +++ b/tests/baselines/reference/modulePreserve1.symbols @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/modulePreserve1.ts] //// + +=== /main.ts === +import { A } from "./a"; +>A : Symbol(A, Decl(main.ts, 0, 8)) + +import B = require("./b"); +>B : Symbol(B, Decl(main.ts, 0, 24)) + +export { A, B }; +>A : Symbol(A, Decl(main.ts, 2, 8)) +>B : Symbol(B, Decl(main.ts, 2, 11)) + +=== /a.ts === +export class A {} +>A : Symbol(A, Decl(a.ts, 0, 0)) + +=== /b.ts === +export = class B {} +>B : Symbol(B, Decl(b.ts, 0, 8)) + diff --git a/tests/baselines/reference/modulePreserve1.types b/tests/baselines/reference/modulePreserve1.types new file mode 100644 index 0000000000000..1cd6b13296fea --- /dev/null +++ b/tests/baselines/reference/modulePreserve1.types @@ -0,0 +1,22 @@ +//// [tests/cases/compiler/modulePreserve1.ts] //// + +=== /main.ts === +import { A } from "./a"; +>A : typeof A + +import B = require("./b"); +>B : typeof B + +export { A, B }; +>A : typeof A +>B : typeof B + +=== /a.ts === +export class A {} +>A : A + +=== /b.ts === +export = class B {} +>class B {} : typeof B +>B : typeof B + diff --git a/tests/cases/compiler/modulePreserve1.ts b/tests/cases/compiler/modulePreserve1.ts new file mode 100644 index 0000000000000..e0e854ac76760 --- /dev/null +++ b/tests/cases/compiler/modulePreserve1.ts @@ -0,0 +1,13 @@ +// @module: preserve +// @target: esnext + +// @Filename: /a.ts +export class A {} + +// @Filename: /b.ts +export = class B {} + +// @Filename: /main.ts +import { A } from "./a"; +import B = require("./b"); +export { A, B }; From 1fb3d750a88a9cf61f04ffd14ee63e150444810c Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 13 Dec 2023 16:45:15 -0800 Subject: [PATCH 02/31] Update diagnostic wording in baselines --- ...sions(moduleresolution=bundler).errors.txt | 4 +-- tests/baselines/reference/api/typescript.d.ts | 1 + .../reference/bundlerOptionsCompat.errors.txt | 4 +-- ...lback(moduleresolution=bundler).errors.txt | 4 +-- .../Parse empty options of --module.js | 2 +- ...odule to compiler-options with json api.js | 2 +- ...ompiler-options with jsonSourceFile api.js | 2 +- ...esolvepackagejsonexports=false).errors.txt | 4 +-- ...resolvepackagejsonexports=true).errors.txt | 4 +-- ...ersWithLocalCollisions(module=preserve).js | 26 +++++++++++++++++++ ...ority(moduleresolution=bundler).errors.txt | 4 +-- ...irect(moduleresolution=bundler).errors.txt | 4 +-- ...ompat(moduleresolution=bundler).errors.txt | 4 +-- ...ValueImports_module(module=amd).errors.txt | 4 +-- ...Imports_module(module=commonjs).errors.txt | 4 +-- ...ueImports_module(module=system).errors.txt | 4 +-- ...ithModuleNodeResolutionEmitNone.errors.txt | 4 +-- ...hModuleNodeResolutionEmitSystem.errors.txt | 4 +-- ...WithModuleNodeResolutionEmitUmd.errors.txt | 4 +-- ...ield2(moduleresolution=bundler).errors.txt | 4 +-- ...stic1(moduleresolution=bundler).errors.txt | 4 +-- ...ons module-kind is out-of-range.errors.txt | 4 +-- ...nd is out-of-range.oldTranspile.errors.txt | 4 +-- ...s target-script is out-of-range.errors.txt | 4 +-- ...pt is out-of-range.oldTranspile.errors.txt | 4 +-- ...does-not-add-color-when-NO_COLOR-is-set.js | 2 +- ...-when-host-can't-provide-terminal-width.js | 2 +- ...tatus.DiagnosticsPresent_OutputsSkipped.js | 2 +- .../verbatimModuleSyntaxCompat.errors.txt | 4 +-- .../verbatimModuleSyntaxCompat2.errors.txt | 4 +-- .../verbatimModuleSyntaxCompat3.errors.txt | 4 +-- .../verbatimModuleSyntaxCompat4.errors.txt | 4 +-- 32 files changed, 81 insertions(+), 54 deletions(-) create mode 100644 tests/baselines/reference/emitHelpersWithLocalCollisions(module=preserve).js diff --git a/tests/baselines/reference/allowImportingTsExtensions(moduleresolution=bundler).errors.txt b/tests/baselines/reference/allowImportingTsExtensions(moduleresolution=bundler).errors.txt index e9f61d8d6af18..9cd62ffe3c082 100644 --- a/tests/baselines/reference/allowImportingTsExtensions(moduleresolution=bundler).errors.txt +++ b/tests/baselines/reference/allowImportingTsExtensions(moduleresolution=bundler).errors.txt @@ -1,8 +1,8 @@ -error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. /c.ts(1,16): error TS2307: Cannot find module './thisfiledoesnotexist.ts' or its corresponding type declarations. -!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. ==== /ts.ts (0 errors) ==== export {}; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 235f8aeed7c3b..406966ccec78b 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -7633,6 +7633,7 @@ declare namespace ts { ESNext = 99, Node16 = 100, NodeNext = 199, + Preserve = 200, } enum JsxEmit { None = 0, diff --git a/tests/baselines/reference/bundlerOptionsCompat.errors.txt b/tests/baselines/reference/bundlerOptionsCompat.errors.txt index 7e765e198c67d..ad59afcd2e616 100644 --- a/tests/baselines/reference/bundlerOptionsCompat.errors.txt +++ b/tests/baselines/reference/bundlerOptionsCompat.errors.txt @@ -1,4 +1,4 @@ -/tsconfig.json(4,25): error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +/tsconfig.json(4,25): error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. ==== /tsconfig.json (1 errors) ==== @@ -7,7 +7,7 @@ "module": "commonjs", "moduleResolution": "bundler", ~~~~~~~~~ -!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. "noEmit": true } } diff --git a/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=bundler).errors.txt b/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=bundler).errors.txt index 71d5b10190e58..9c25a06c9c103 100644 --- a/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=bundler).errors.txt +++ b/tests/baselines/reference/conditionalExportsResolutionFallback(moduleresolution=bundler).errors.txt @@ -1,7 +1,7 @@ -error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. -!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. ==== /node_modules/dep/package.json (0 errors) ==== // This documents bug https://github.com/microsoft/TypeScript/issues/50762. diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse empty options of --module.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse empty options of --module.js index 6eac025950521..1b39c0ab91dd9 100644 --- a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse empty options of --module.js +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse empty options of --module.js @@ -7,4 +7,4 @@ FileNames:: 0.ts Errors:: error TS6044: Compiler option 'module' expects an argument. -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext', 'preserve'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of module to compiler-options with json api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of module to compiler-options with json api.js index 09dde5cc6ad82..256ff72a951f8 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of module to compiler-options with json api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of module to compiler-options with json api.js @@ -25,5 +25,5 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext', 'preserve'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of module to compiler-options with jsonSourceFile api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of module to compiler-options with jsonSourceFile api.js index 85fd807b94586..c37fd14ef9cc6 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of module to compiler-options with jsonSourceFile api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of module to compiler-options with jsonSourceFile api.js @@ -25,7 +25,7 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -tsconfig.json:3:15 - error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. +tsconfig.json:3:15 - error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext', 'preserve'. 3 "module": "",    ~~ diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).errors.txt b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).errors.txt index 172906d3dc8d5..9e462a35eaf70 100644 --- a/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).errors.txt +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).errors.txt @@ -1,7 +1,7 @@ -error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. -!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. ==== /node_modules/lodash/package.json (0 errors) ==== { "name": "lodash", diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).errors.txt b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).errors.txt index 172906d3dc8d5..9e462a35eaf70 100644 --- a/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).errors.txt +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).errors.txt @@ -1,7 +1,7 @@ -error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. -!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. ==== /node_modules/lodash/package.json (0 errors) ==== { "name": "lodash", diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=preserve).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=preserve).js new file mode 100644 index 0000000000000..47204b7a76f30 --- /dev/null +++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=preserve).js @@ -0,0 +1,26 @@ +//// [tests/cases/compiler/emitHelpersWithLocalCollisions.ts] //// + +//// [a.ts] +declare var dec: any, __decorate: any; +@dec export class A { +} + +const o = { a: 1 }; +const y = { ...o }; + + +//// [a.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +let A = class A { +}; +A = __decorate([ + dec +], A); +export { A }; +const o = { a: 1 }; +const y = Object.assign({}, o); diff --git a/tests/baselines/reference/extensionLoadingPriority(moduleresolution=bundler).errors.txt b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=bundler).errors.txt index bcb61b45b1213..3ce0386d486b0 100644 --- a/tests/baselines/reference/extensionLoadingPriority(moduleresolution=bundler).errors.txt +++ b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=bundler).errors.txt @@ -1,7 +1,7 @@ -error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. -!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. ==== /project/a.js (0 errors) ==== export default "a.js"; diff --git a/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=bundler).errors.txt b/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=bundler).errors.txt index c867a2883059b..b714d536e8100 100644 --- a/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=bundler).errors.txt +++ b/tests/baselines/reference/nestedPackageJsonRedirect(moduleresolution=bundler).errors.txt @@ -1,7 +1,7 @@ -error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. -!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. ==== /node_modules/@restart/hooks/package.json (0 errors) ==== { "name": "@restart/hooks", diff --git a/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=bundler).errors.txt b/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=bundler).errors.txt index 922ab5a9ffeee..06ea252e5b844 100644 --- a/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=bundler).errors.txt +++ b/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=bundler).errors.txt @@ -1,6 +1,6 @@ -error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. -!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. ==== index.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/baselines/reference/preserveValueImports_module(module=amd).errors.txt b/tests/baselines/reference/preserveValueImports_module(module=amd).errors.txt index 84c7e5a0a95a3..cc2e3641f6ab3 100644 --- a/tests/baselines/reference/preserveValueImports_module(module=amd).errors.txt +++ b/tests/baselines/reference/preserveValueImports_module(module=amd).errors.txt @@ -1,9 +1,9 @@ -error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. +error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. Use 'verbatimModuleSyntax' instead. -!!! error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. !!! error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. !!! error TS5101: Use 'verbatimModuleSyntax' instead. ==== preserveValueImports_module.ts (0 errors) ==== diff --git a/tests/baselines/reference/preserveValueImports_module(module=commonjs).errors.txt b/tests/baselines/reference/preserveValueImports_module(module=commonjs).errors.txt index 84c7e5a0a95a3..cc2e3641f6ab3 100644 --- a/tests/baselines/reference/preserveValueImports_module(module=commonjs).errors.txt +++ b/tests/baselines/reference/preserveValueImports_module(module=commonjs).errors.txt @@ -1,9 +1,9 @@ -error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. +error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. Use 'verbatimModuleSyntax' instead. -!!! error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. !!! error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. !!! error TS5101: Use 'verbatimModuleSyntax' instead. ==== preserveValueImports_module.ts (0 errors) ==== diff --git a/tests/baselines/reference/preserveValueImports_module(module=system).errors.txt b/tests/baselines/reference/preserveValueImports_module(module=system).errors.txt index 84c7e5a0a95a3..cc2e3641f6ab3 100644 --- a/tests/baselines/reference/preserveValueImports_module(module=system).errors.txt +++ b/tests/baselines/reference/preserveValueImports_module(module=system).errors.txt @@ -1,9 +1,9 @@ -error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. +error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. Use 'verbatimModuleSyntax' instead. -!!! error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. !!! error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. !!! error TS5101: Use 'verbatimModuleSyntax' instead. ==== preserveValueImports_module.ts (0 errors) ==== diff --git a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitNone.errors.txt b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitNone.errors.txt index 2c4f4e0e6d95d..1cd05c516e62d 100644 --- a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitNone.errors.txt +++ b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitNone.errors.txt @@ -1,8 +1,8 @@ -error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'. +error TS5071: Option '--resolveJsonModule' cannot be specified when 'module' is set to 'none', 'system', or 'umd'. file1.ts(1,1): error TS1148: Cannot use imports, exports, or module augmentations when '--module' is 'none'. -!!! error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'. +!!! error TS5071: Option '--resolveJsonModule' cannot be specified when 'module' is set to 'none', 'system', or 'umd'. ==== file1.ts (1 errors) ==== import * as b from './b.json'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitSystem.errors.txt b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitSystem.errors.txt index d3ae542d34b96..dbae322e4265b 100644 --- a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitSystem.errors.txt +++ b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitSystem.errors.txt @@ -1,7 +1,7 @@ -error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'. +error TS5071: Option '--resolveJsonModule' cannot be specified when 'module' is set to 'none', 'system', or 'umd'. -!!! error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'. +!!! error TS5071: Option '--resolveJsonModule' cannot be specified when 'module' is set to 'none', 'system', or 'umd'. ==== file1.ts (0 errors) ==== import * as b from './b.json'; diff --git a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitUmd.errors.txt b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitUmd.errors.txt index d3ae542d34b96..dbae322e4265b 100644 --- a/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitUmd.errors.txt +++ b/tests/baselines/reference/requireOfJsonFileWithModuleNodeResolutionEmitUmd.errors.txt @@ -1,7 +1,7 @@ -error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'. +error TS5071: Option '--resolveJsonModule' cannot be specified when 'module' is set to 'none', 'system', or 'umd'. -!!! error TS5071: Option '--resolveJsonModule' can only be specified when module code generation is 'commonjs', 'amd', 'es2015' or 'esNext'. +!!! error TS5071: Option '--resolveJsonModule' cannot be specified when 'module' is set to 'none', 'system', or 'umd'. ==== file1.ts (0 errors) ==== import * as b from './b.json'; diff --git a/tests/baselines/reference/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt b/tests/baselines/reference/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt index 1aff00cd4751a..bc87e9cadb7ff 100644 --- a/tests/baselines/reference/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt +++ b/tests/baselines/reference/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt @@ -1,8 +1,8 @@ -error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. test.ts(1,19): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. -!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. ==== tsconfig.json (0 errors) ==== { "compilerOptions": { diff --git a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt index 0668d695d63e3..befdfb5cd9df7 100644 --- a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt +++ b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).errors.txt @@ -1,4 +1,4 @@ -error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. error TS6504: File '/node_modules/bar/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? The file is in the program because: Root file specified for compilation @@ -17,7 +17,7 @@ error TS6504: File '/node_modules/foo/index.mjs' is a JavaScript file. Did you m There are types at '/node_modules/@types/bar/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@types/bar' library may need to update its package.json or typings. -!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. !!! error TS6504: File '/node_modules/bar/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? !!! error TS6504: The file is in the program because: !!! error TS6504: Root file specified for compilation diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt index fad550d1d91ac..9049e0c6b8db3 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt +++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt @@ -1,8 +1,8 @@ error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext', 'preserve'. !!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. -!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. +!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext', 'preserve'. ==== file.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt index fad550d1d91ac..9049e0c6b8db3 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt +++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt @@ -1,8 +1,8 @@ error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext', 'preserve'. !!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. -!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. +!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext', 'preserve'. ==== file.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt index fad550d1d91ac..9049e0c6b8db3 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt +++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt @@ -1,8 +1,8 @@ error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext', 'preserve'. !!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. -!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. +!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext', 'preserve'. ==== file.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt index fad550d1d91ac..9049e0c6b8db3 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt +++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt @@ -1,8 +1,8 @@ error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext', 'preserve'. !!! error TS5107: Option 'target=ES3' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. -!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext'. +!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'es2022', 'esnext', 'node16', 'nodenext', 'preserve'. ==== file.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js b/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js index 144118fae91f8..2c29926a825c1 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js @@ -106,7 +106,7 @@ default: es5 --module, -m Specify what module code is generated. -one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node16, nodenext +one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node16, nodenext, preserve default: undefined --lib diff --git a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js index 4f6bbee5e0aca..4f7ea06a62438 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js @@ -106,7 +106,7 @@ default: es5 --module, -m Specify what module code is generated. -one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node16, nodenext +one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node16, nodenext, preserve default: undefined --lib diff --git a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js index 4f6bbee5e0aca..4f7ea06a62438 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js @@ -106,7 +106,7 @@ default: es5 --module, -m Specify what module code is generated. -one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node16, nodenext +one of: none, commonjs, amd, umd, system, es6/es2015, es2020, es2022, esnext, node16, nodenext, preserve default: undefined --lib diff --git a/tests/baselines/reference/verbatimModuleSyntaxCompat.errors.txt b/tests/baselines/reference/verbatimModuleSyntaxCompat.errors.txt index 020a29d18c454..487bfe2da3b45 100644 --- a/tests/baselines/reference/verbatimModuleSyntaxCompat.errors.txt +++ b/tests/baselines/reference/verbatimModuleSyntaxCompat.errors.txt @@ -1,4 +1,4 @@ -error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. +error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. error TS5101: Option 'importsNotUsedAsValues' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. Use 'verbatimModuleSyntax' instead. error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. @@ -8,7 +8,7 @@ error TS5104: Option 'preserveValueImports' is redundant and cannot be specified error TS5105: Option 'verbatimModuleSyntax' cannot be used when 'module' is set to 'UMD', 'AMD', or 'System'. -!!! error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. !!! error TS5101: Option 'importsNotUsedAsValues' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. !!! error TS5101: Use 'verbatimModuleSyntax' instead. !!! error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. diff --git a/tests/baselines/reference/verbatimModuleSyntaxCompat2.errors.txt b/tests/baselines/reference/verbatimModuleSyntaxCompat2.errors.txt index 2c8fcfcbb1eee..32c7d82cbae39 100644 --- a/tests/baselines/reference/verbatimModuleSyntaxCompat2.errors.txt +++ b/tests/baselines/reference/verbatimModuleSyntaxCompat2.errors.txt @@ -1,4 +1,4 @@ -/tsconfig.json(5,9): error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. +/tsconfig.json(5,9): error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. /tsconfig.json(5,9): error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. Use 'verbatimModuleSyntax' instead. /tsconfig.json(5,9): error TS5104: Option 'preserveValueImports' is redundant and cannot be specified with option 'verbatimModuleSyntax'. @@ -14,7 +14,7 @@ "isolatedModules": true, "preserveValueImports": true, ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. !!! error TS5101: Use 'verbatimModuleSyntax' instead. diff --git a/tests/baselines/reference/verbatimModuleSyntaxCompat3.errors.txt b/tests/baselines/reference/verbatimModuleSyntaxCompat3.errors.txt index 1eabc0a1a8f9a..4b4a31e01fd29 100644 --- a/tests/baselines/reference/verbatimModuleSyntaxCompat3.errors.txt +++ b/tests/baselines/reference/verbatimModuleSyntaxCompat3.errors.txt @@ -1,11 +1,11 @@ -error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. +error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. error TS5101: Option 'importsNotUsedAsValues' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. Use 'verbatimModuleSyntax' instead. error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. Use 'verbatimModuleSyntax' instead. -!!! error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. !!! error TS5101: Option 'importsNotUsedAsValues' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. !!! error TS5101: Use 'verbatimModuleSyntax' instead. !!! error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. diff --git a/tests/baselines/reference/verbatimModuleSyntaxCompat4.errors.txt b/tests/baselines/reference/verbatimModuleSyntaxCompat4.errors.txt index 91ee3baec2087..86b4a0afd35a5 100644 --- a/tests/baselines/reference/verbatimModuleSyntaxCompat4.errors.txt +++ b/tests/baselines/reference/verbatimModuleSyntaxCompat4.errors.txt @@ -1,4 +1,4 @@ -/tsconfig.json(5,9): error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. +/tsconfig.json(5,9): error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. /tsconfig.json(5,9): error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. Use 'verbatimModuleSyntax' instead. /tsconfig.json(5,9): error TS5104: Option 'preserveValueImports' is redundant and cannot be specified with option 'verbatimModuleSyntax'. @@ -14,7 +14,7 @@ "isolatedModules": true, "preserveValueImports": true, ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later. +!!! error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS5101: Option 'preserveValueImports' is deprecated and will stop functioning in TypeScript 5.5. Specify compilerOption '"ignoreDeprecations": "5.0"' to silence this error. !!! error TS5101: Use 'verbatimModuleSyntax' instead. From 76aefde3e2485ddb93027e34319fa39a01101ac5 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 14 Dec 2023 10:12:16 -0800 Subject: [PATCH 03/31] REVERT ME: esnext -> preserve for RWC testing --- src/compiler/commandLineParser.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 359587bdeb669..e4c0f3e30fee5 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -549,11 +549,11 @@ export const moduleOptionDeclaration: CommandLineOptionOfCustomType = { amd: ModuleKind.AMD, system: ModuleKind.System, umd: ModuleKind.UMD, - es6: ModuleKind.ES2015, - es2015: ModuleKind.ES2015, - es2020: ModuleKind.ES2020, - es2022: ModuleKind.ES2022, - esnext: ModuleKind.ESNext, + es6: ModuleKind.Preserve, + es2015: ModuleKind.Preserve, + es2020: ModuleKind.Preserve, + es2022: ModuleKind.Preserve, + esnext: ModuleKind.Preserve, node16: ModuleKind.Node16, nodenext: ModuleKind.NodeNext, preserve: ModuleKind.Preserve, From 9623430af7e0caa0551ee7fff45bf6d631167dad Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 14 Dec 2023 10:15:37 -0800 Subject: [PATCH 04/31] Revert "REVERT ME: esnext -> preserve for RWC testing" This reverts commit 76aefde3e2485ddb93027e34319fa39a01101ac5. --- src/compiler/commandLineParser.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index e4c0f3e30fee5..359587bdeb669 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -549,11 +549,11 @@ export const moduleOptionDeclaration: CommandLineOptionOfCustomType = { amd: ModuleKind.AMD, system: ModuleKind.System, umd: ModuleKind.UMD, - es6: ModuleKind.Preserve, - es2015: ModuleKind.Preserve, - es2020: ModuleKind.Preserve, - es2022: ModuleKind.Preserve, - esnext: ModuleKind.Preserve, + es6: ModuleKind.ES2015, + es2015: ModuleKind.ES2015, + es2020: ModuleKind.ES2020, + es2022: ModuleKind.ES2022, + esnext: ModuleKind.ESNext, node16: ModuleKind.Node16, nodenext: ModuleKind.NodeNext, preserve: ModuleKind.Preserve, From b0aa2388f58a650066b3cc5902d10573106c07fb Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 14 Dec 2023 12:11:50 -0800 Subject: [PATCH 05/31] Resolve ImportEquals as require --- src/compiler/checker.ts | 6 +- src/compiler/moduleNameResolver.ts | 16 +- src/compiler/moduleSpecifiers.ts | 2 +- src/compiler/program.ts | 29 +- src/compiler/resolutionCache.ts | 4 +- src/compiler/utilities.ts | 6 +- src/services/codefixes/convertToEsModule.ts | 2 +- src/services/codefixes/fixSpelling.ts | 2 +- src/services/codefixes/importFixes.ts | 2 +- src/services/findAllReferences.ts | 2 +- src/services/getEditsForFileRename.ts | 2 +- src/services/goToDefinition.ts | 4 +- src/services/refactors/moveToFile.ts | 5 +- src/services/stringCompletions.ts | 2 +- src/services/suggestionDiagnostics.ts | 2 +- tests/baselines/reference/api/typescript.d.ts | 12 +- .../reference/modulePreserve2.symbols | 20 + .../reference/modulePreserve2.trace.json | 866 ++++++++++++++++++ .../baselines/reference/modulePreserve2.types | 20 + tests/cases/compiler/modulePreserve2.ts | 25 + 20 files changed, 979 insertions(+), 50 deletions(-) create mode 100644 tests/baselines/reference/modulePreserve2.symbols create mode 100644 tests/baselines/reference/modulePreserve2.trace.json create mode 100644 tests/baselines/reference/modulePreserve2.types create mode 100644 tests/cases/compiler/modulePreserve2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 810c91b334b96..f0f1ea2168f98 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4054,7 +4054,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function getUsageModeForExpression(usage: Expression) { - return isStringLiteralLike(usage) ? getModeForUsageLocation(getSourceFileOfNode(usage), usage) : undefined; + return isStringLiteralLike(usage) ? getModeForUsageLocation(getSourceFileOfNode(usage), usage, compilerOptions) : undefined; } function isESMFormatImportImportingCommonjsFormatFile(usageMode: ResolutionMode, targetMode: ResolutionMode) { @@ -4068,7 +4068,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function canHaveSyntheticDefault(file: SourceFile | undefined, moduleSymbol: Symbol, dontResolveAlias: boolean, usage: Expression) { const usageMode = file && getUsageModeForExpression(usage); - if (file && usageMode !== undefined) { + if (file && usageMode !== undefined && ModuleKind.Node16 <= moduleKind && moduleKind <= ModuleKind.NodeNext) { const result = isESMFormatImportImportingCommonjsFormatFile(usageMode, file.impliedNodeFormat); if (usageMode === ModuleKind.ESNext || result) { return result; @@ -5006,7 +5006,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { findAncestor(location, isExportDeclaration)?.moduleSpecifier || (isModuleDeclaration(location) ? location : location.parent && isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : undefined)?.name || (isLiteralImportTypeNode(location) ? location : undefined)?.argument.literal; - const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat; + const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? getModeForUsageLocation(currentSourceFile, contextSpecifier, compilerOptions) : currentSourceFile.impliedNodeFormat; const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions); const resolvedModule = host.getResolvedModule(currentSourceFile, moduleReference, mode)?.resolvedModule; const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile); diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 67f821b09213b..dc1e10111e3b2 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -44,7 +44,6 @@ import { getDeclarationEmitExtensionForPath, getDirectoryPath, GetEffectiveTypeRootsHost, - getEmitModuleKind, getEmitModuleResolutionKind, getNormalizedAbsolutePath, getOwnKeys, @@ -1410,20 +1409,7 @@ export function resolveModuleName(moduleName: string, containingFile: string, co else { let moduleResolution = compilerOptions.moduleResolution; if (moduleResolution === undefined) { - switch (getEmitModuleKind(compilerOptions)) { - case ModuleKind.CommonJS: - moduleResolution = ModuleResolutionKind.Node10; - break; - case ModuleKind.Node16: - moduleResolution = ModuleResolutionKind.Node16; - break; - case ModuleKind.NodeNext: - moduleResolution = ModuleResolutionKind.NodeNext; - break; - default: - moduleResolution = ModuleResolutionKind.Classic; - break; - } + moduleResolution = getEmitModuleResolutionKind(compilerOptions); if (traceEnabled) { trace(host, Diagnostics.Module_resolution_kind_is_not_specified_using_0, ModuleResolutionKind[moduleResolution]); } diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index 2dddc47d30c69..93fac6301a5ac 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -379,7 +379,7 @@ function computeModuleSpecifiers( if (reason.kind !== FileIncludeKind.Import || reason.file !== importingSourceFile.path) return undefined; // If the candidate import mode doesn't match the mode we're generating for, don't consider it // TODO: maybe useful to keep around as an alternative option for certain contexts where the mode is overridable - if (importingSourceFile.impliedNodeFormat && importingSourceFile.impliedNodeFormat !== getModeForResolutionAtIndex(importingSourceFile, reason.index)) return undefined; + if (importingSourceFile.impliedNodeFormat && importingSourceFile.impliedNodeFormat !== getModeForResolutionAtIndex(importingSourceFile, reason.index, compilerOptions)) return undefined; const specifier = getModuleNameStringLiteralAt(importingSourceFile, reason.index).text; // If the preference is for non relative and the module specifier is relative, ignore it return preferences.relativePreference !== RelativePreference.NonRelative || !pathIsRelative(specifier) ? diff --git a/src/compiler/program.ts b/src/compiler/program.ts index cfc2de0a0f4ed..ec29e361e28d8 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -857,14 +857,14 @@ export function getModeForFileReference(ref: FileReference | string, containingF * @param file File to fetch the resolution mode within * @param index Index into the file's complete resolution list to get the resolution of - this is a concatenation of the file's imports and module augmentations */ -export function getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode; +export function getModeForResolutionAtIndex(file: SourceFile, index: number, compilerOptions: CompilerOptions): ResolutionMode; /** @internal */ // eslint-disable-next-line @typescript-eslint/unified-signatures -export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number): ResolutionMode; -export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number): ResolutionMode { +export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number, compilerOptions: CompilerOptions): ResolutionMode; +export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number, compilerOptions: CompilerOptions): ResolutionMode { // we ensure all elements of file.imports and file.moduleAugmentations have the relevant parent pointers set during program setup, // so it's safe to use them even pre-bind - return getModeForUsageLocation(file, getModuleNameStringLiteralAt(file, index)); + return getModeForUsageLocation(file, getModuleNameStringLiteralAt(file, index), compilerOptions); } /** @internal */ @@ -887,7 +887,7 @@ export function isExclusivelyTypeOnlyImportOrExport(decl: ImportDeclaration | Ex * @param usage The module reference string * @returns The final resolution mode of the import */ -export function getModeForUsageLocation(file: { impliedNodeFormat?: ResolutionMode; }, usage: StringLiteralLike) { +export function getModeForUsageLocation(file: { impliedNodeFormat?: ResolutionMode; }, usage: StringLiteralLike, compilerOptions: CompilerOptions) { if ((isImportDeclaration(usage.parent) || isExportDeclaration(usage.parent))) { const isTypeOnly = isExclusivelyTypeOnlyImportOrExport(usage.parent); if (isTypeOnly) { @@ -903,6 +903,9 @@ export function getModeForUsageLocation(file: { impliedNodeFormat?: ResolutionMo return override; } } + if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Bundler) { + return usage.parent.parent && isImportEqualsDeclaration(usage.parent.parent) ? ModuleKind.CommonJS : ModuleKind.ESNext; + } if (file.impliedNodeFormat === undefined) return undefined; if (file.impliedNodeFormat !== ModuleKind.ESNext) { // in cjs files, import call expressions are esm format, otherwise everything is cjs @@ -953,7 +956,7 @@ const emptyResolution: ResolvedModuleWithFailedLookupLocations & ResolvedTypeRef /** @internal */ export interface ResolutionNameAndModeGetter { getName(entry: Entry): string; - getMode(entry: Entry, file: SourceFile): ResolutionMode; + getMode(entry: Entry, file: SourceFile, compilerOptions: CompilerOptions): ResolutionMode; } /** @internal */ @@ -969,7 +972,7 @@ function getModuleResolutionName(literal: StringLiteralLike) { /** @internal */ export const moduleResolutionNameAndModeGetter: ResolutionNameAndModeGetter = { getName: getModuleResolutionName, - getMode: (entry, file) => getModeForUsageLocation(file, entry), + getMode: (entry, file, compilerOptions) => getModeForUsageLocation(file, entry, compilerOptions), }; /** @internal */ @@ -1052,7 +1055,7 @@ export function loadWithModeAwareCache oldProgram!.getResolvedModule(newSourceFile, name, mode), moduleResolutionIsEqualTo, moduleResolutionNameAndModeGetter, + oldProgram.getCompilerOptions(), ); if (resolutionsChanged) structureIsReused = StructureIsReused.SafeModules; const typesReferenceDirectives = newSourceFile.typeReferenceDirectives; @@ -2538,6 +2542,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg (name, mode) => oldProgram?.getResolvedTypeReferenceDirective(newSourceFile, name, mode), typeDirectiveIsEqualTo, typeReferenceResolutionNameAndModeGetter, + oldProgram.getCompilerOptions(), ); if (typeReferenceResolutionsChanged) structureIsReused = StructureIsReused.SafeModules; } @@ -4029,7 +4034,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg for (let index = 0; index < moduleNames.length; index++) { const resolution = resolutions[index].resolvedModule; const moduleName = moduleNames[index].text; - const mode = getModeForUsageLocation(file, moduleNames[index]); + const mode = getModeForUsageLocation(file, moduleNames[index], optionsForFile); resolutionsInFile.set(moduleName, mode, resolutions[index]); addResolutionDiagnosticsFromResolutionOrCache(file, moduleName, resolutions[index], mode); diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts index 9ad219eee2cf6..efa7972d00c18 100644 --- a/src/compiler/resolutionCache.ts +++ b/src/compiler/resolutionCache.ts @@ -822,7 +822,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD const seenNamesInFile = createModeAwareCache(); for (const entry of entries) { const name = loader.nameAndMode.getName(entry); - const mode = loader.nameAndMode.getMode(entry, containingSourceFile); + const mode = loader.nameAndMode.getMode(entry, containingSourceFile, options); let resolution = resolutionsInFile.get(name, mode); // Resolution is valid if it is present and not invalidated if ( @@ -881,7 +881,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD reusedNames?.forEach(entry => seenNamesInFile.set( loader.nameAndMode.getName(entry), - loader.nameAndMode.getMode(entry, containingSourceFile), + loader.nameAndMode.getMode(entry, containingSourceFile, options), true, ) ); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 12a7905047f66..a0283056fe423 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -835,6 +835,7 @@ export function hasChangesInResolutions( getOldResolution: (name: string, mode: ResolutionMode) => V | undefined, comparer: (oldResolution: V, newResolution: V) => boolean, nameAndModeGetter: ResolutionNameAndModeGetter, + compilerOptions: CompilerOptions, ): boolean { Debug.assert(names.length === newResolutions.length); @@ -842,7 +843,7 @@ export function hasChangesInResolutions( const newResolution = newResolutions[i]; const entry = names[i]; const name = nameAndModeGetter.getName(entry); - const mode = nameAndModeGetter.getMode(entry, newSourceFile); + const mode = nameAndModeGetter.getMode(entry, newSourceFile, compilerOptions); const oldResolution = getOldResolution(name, mode); const changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) @@ -9571,7 +9572,8 @@ export function usesExtensionsOnImports({ imports }: SourceFile, hasExtension: ( /** @internal */ export function getModuleSpecifierEndingPreference(preference: UserPreferences["importModuleSpecifierEnding"], resolutionMode: ResolutionMode, compilerOptions: CompilerOptions, sourceFile: SourceFile): ModuleSpecifierEnding { - if (preference === "js" || resolutionMode === ModuleKind.ESNext) { + const moduleResolution = getEmitModuleResolutionKind(compilerOptions); + if (preference === "js" || resolutionMode === ModuleKind.ESNext && ModuleResolutionKind.Node16 <= moduleResolution && moduleResolution <= ModuleResolutionKind.NodeNext) { // Extensions are explicitly requested or required. Now choose between .js and .ts. if (!shouldAllowImportingTsExtension(compilerOptions)) { return ModuleSpecifierEnding.JsExtension; diff --git a/src/services/codefixes/convertToEsModule.ts b/src/services/codefixes/convertToEsModule.ts index 4c7c6ab83048e..88cb6546ac4e2 100644 --- a/src/services/codefixes/convertToEsModule.ts +++ b/src/services/codefixes/convertToEsModule.ts @@ -107,7 +107,7 @@ function fixImportOfModuleExports( quotePreference: QuotePreference, ) { for (const moduleSpecifier of importingFile.imports) { - const imported = program.getResolvedModule(importingFile, moduleSpecifier.text, getModeForUsageLocation(importingFile, moduleSpecifier))?.resolvedModule; + const imported = program.getResolvedModule(importingFile, moduleSpecifier.text, getModeForUsageLocation(importingFile, moduleSpecifier, program.getCompilerOptions()))?.resolvedModule; if (!imported || imported.resolvedFileName !== exportingFile.fileName) { continue; } diff --git a/src/services/codefixes/fixSpelling.ts b/src/services/codefixes/fixSpelling.ts index ede869cfea944..81b90d68e8544 100644 --- a/src/services/codefixes/fixSpelling.ts +++ b/src/services/codefixes/fixSpelling.ts @@ -181,7 +181,7 @@ function convertSemanticMeaningToSymbolFlags(meaning: SemanticMeaning): SymbolFl function getResolvedSourceFileFromImportDeclaration(sourceFile: SourceFile, context: CodeFixContextBase, importDeclaration: ImportDeclaration): SourceFile | undefined { if (!importDeclaration || !isStringLiteralLike(importDeclaration.moduleSpecifier)) return undefined; - const resolvedModule = context.program.getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text, getModeForUsageLocation(sourceFile, importDeclaration.moduleSpecifier))?.resolvedModule; + const resolvedModule = context.program.getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text, getModeForUsageLocation(sourceFile, importDeclaration.moduleSpecifier, context.program.getCompilerOptions()))?.resolvedModule; if (!resolvedModule) return undefined; return context.program.getSourceFile(resolvedModule.resolvedFileName); diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 98b9a46ef2b82..5eeefd02c1c9a 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -1440,7 +1440,7 @@ function promoteFromTypeOnly( // Change .ts extension to .js if necessary if (!compilerOptions.allowImportingTsExtensions) { const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(importClause.parent); - const resolvedModule = moduleSpecifier && program.getResolvedModule(sourceFile, moduleSpecifier.text, getModeForUsageLocation(sourceFile, moduleSpecifier))?.resolvedModule; + const resolvedModule = moduleSpecifier && program.getResolvedModule(sourceFile, moduleSpecifier.text, getModeForUsageLocation(sourceFile, moduleSpecifier, compilerOptions))?.resolvedModule; if (resolvedModule?.resolvedUsingTsExtension) { const changedExtension = changeAnyExtension(moduleSpecifier!.text, getOutputExtension(moduleSpecifier!.text, compilerOptions)); changes.replaceNode(sourceFile, moduleSpecifier!, factory.createStringLiteral(changedExtension)); diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 06aea522ce9be..035b9179bcad2 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -1015,7 +1015,7 @@ export namespace Core { if (!options.implementations && isStringLiteralLike(node)) { if (isModuleSpecifierLike(node)) { const fileIncludeReasons = program.getFileIncludeReasons(); - const referencedFileName = program.getResolvedModule(node.getSourceFile(), node.text, getModeForUsageLocation(node.getSourceFile(), node))?.resolvedModule?.resolvedFileName; + const referencedFileName = program.getResolvedModule(node.getSourceFile(), node.text, getModeForUsageLocation(node.getSourceFile(), node, program.getCompilerOptions()))?.resolvedModule?.resolvedFileName; const referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; if (referencedFile) { return [{ definition: { type: DefinitionKind.String, node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || emptyArray }]; diff --git a/src/services/getEditsForFileRename.ts b/src/services/getEditsForFileRename.ts index d9f386ed7ceed..4bbdf9b95997d 100644 --- a/src/services/getEditsForFileRename.ts +++ b/src/services/getEditsForFileRename.ts @@ -246,7 +246,7 @@ function getSourceFileToImport( return newFileName === undefined ? { newFileName: oldFileName, updated: false } : { newFileName, updated: true }; } else { - const mode = getModeForUsageLocation(importingSourceFile, importLiteral); + const mode = getModeForUsageLocation(importingSourceFile, importLiteral, program.getCompilerOptions()); const resolved = host.resolveModuleNameLiterals || !host.resolveModuleNames ? program.getResolvedModule(importingSourceFile, importLiteral.text, mode) : host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode); diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index c603c6c7bab3d..0ff223f8c5473 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -180,7 +180,7 @@ export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile if (!symbol && isModuleSpecifierLike(fallbackNode)) { // We couldn't resolve the module specifier as an external module, but it could // be that module resolution succeeded but the target was not a module. - const ref = program.getResolvedModule(sourceFile, fallbackNode.text, getModeForUsageLocation(sourceFile, fallbackNode))?.resolvedModule; + const ref = program.getResolvedModule(sourceFile, fallbackNode.text, getModeForUsageLocation(sourceFile, fallbackNode, program.getCompilerOptions()))?.resolvedModule; if (ref) { return [{ name: fallbackNode.text, @@ -336,7 +336,7 @@ export function getReferenceAtPosition(sourceFile: SourceFile, position: number, if (sourceFile.imports.length || sourceFile.moduleAugmentations.length) { const node = getTouchingToken(sourceFile, position); let resolution: ResolvedModuleWithFailedLookupLocations | undefined; - if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && (resolution = program.getResolvedModule(sourceFile, node.text, getModeForUsageLocation(sourceFile, node)))) { + if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && (resolution = program.getResolvedModule(sourceFile, node.text, getModeForUsageLocation(sourceFile, node, program.getCompilerOptions())))) { const verifiedFileName = resolution.resolvedModule?.resolvedFileName; const fileName = verifiedFileName || resolvePath(getDirectoryPath(sourceFile.fileName), node.text); return { diff --git a/src/services/refactors/moveToFile.ts b/src/services/refactors/moveToFile.ts index d3801aabac74a..65cb59a07c778 100644 --- a/src/services/refactors/moveToFile.ts +++ b/src/services/refactors/moveToFile.ts @@ -313,10 +313,11 @@ function getTargetFileImportsAndAddExportInOldFile( forEachImportInStatement(oldStatement, i => { // Recomputing module specifier const moduleSpecifier = moduleSpecifierFromImport(i); - const resolved = program.getResolvedModule(oldFile, moduleSpecifier.text, getModeForUsageLocation(oldFile, moduleSpecifier)); + const compilerOptions = program.getCompilerOptions(); + const resolved = program.getResolvedModule(oldFile, moduleSpecifier.text, getModeForUsageLocation(oldFile, moduleSpecifier, compilerOptions)); const fileName = resolved?.resolvedModule?.resolvedFileName; if (fileName && targetSourceFile) { - const newModuleSpecifier = getModuleSpecifier(program.getCompilerOptions(), targetSourceFile, targetSourceFile.fileName, fileName, createModuleSpecifierResolutionHost(program, host)); + const newModuleSpecifier = getModuleSpecifier(compilerOptions, targetSourceFile, targetSourceFile.fileName, fileName, createModuleSpecifierResolutionHost(program, host)); append(copiedOldImports, filterImport(i, makeStringLiteral(newModuleSpecifier, quotePreference), name => importsToCopy.has(checker.getSymbolAtLocation(name)!))); } else { diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index 474c72be3ddec..c50df9ee96643 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -583,7 +583,7 @@ function getStringLiteralCompletionsFromModuleNames(sourceFile: SourceFile, node function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile: SourceFile, node: LiteralExpression, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker, preferences: UserPreferences): readonly NameAndKind[] { const literalValue = normalizeSlashes(node.text); - const mode = isStringLiteralLike(node) ? getModeForUsageLocation(sourceFile, node) : undefined; + const mode = isStringLiteralLike(node) ? getModeForUsageLocation(sourceFile, node, compilerOptions) : undefined; const scriptPath = sourceFile.path; const scriptDirectory = getDirectoryPath(scriptPath); diff --git a/src/services/suggestionDiagnostics.ts b/src/services/suggestionDiagnostics.ts index 5d89f61c93b5e..6026c126d0cd8 100644 --- a/src/services/suggestionDiagnostics.ts +++ b/src/services/suggestionDiagnostics.ts @@ -88,7 +88,7 @@ export function computeSuggestionDiagnostics(sourceFile: SourceFile, program: Pr const importNode = importFromModuleSpecifier(moduleSpecifier); const name = importNameForConvertToDefaultImport(importNode); if (!name) continue; - const module = program.getResolvedModule(sourceFile, moduleSpecifier.text, getModeForUsageLocation(sourceFile, moduleSpecifier))?.resolvedModule; + const module = program.getResolvedModule(sourceFile, moduleSpecifier.text, getModeForUsageLocation(sourceFile, moduleSpecifier, program.getCompilerOptions()))?.resolvedModule; const resolvedFile = module && program.getSourceFile(module.resolvedFileName); if (resolvedFile && resolvedFile.externalModuleIndicator && resolvedFile.externalModuleIndicator !== true && isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) { diags.push(createDiagnosticForNode(name, Diagnostics.Import_may_be_converted_to_a_default_import)); diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 406966ccec78b..60ee35c08c8a3 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -9897,7 +9897,7 @@ declare namespace ts { * @param file File to fetch the resolution mode within * @param index Index into the file's complete resolution list to get the resolution of - this is a concatenation of the file's imports and module augmentations */ - function getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode; + function getModeForResolutionAtIndex(file: SourceFile, index: number, compilerOptions: CompilerOptions): ResolutionMode; /** * Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if * one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm). @@ -9907,9 +9907,13 @@ declare namespace ts { * @param usage The module reference string * @returns The final resolution mode of the import */ - function getModeForUsageLocation(file: { - impliedNodeFormat?: ResolutionMode; - }, usage: StringLiteralLike): ModuleKind.CommonJS | ModuleKind.ESNext | undefined; + function getModeForUsageLocation( + file: { + impliedNodeFormat?: ResolutionMode; + }, + usage: StringLiteralLike, + compilerOptions: CompilerOptions, + ): ModuleKind.CommonJS | ModuleKind.ESNext | undefined; function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[]; /** * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the diff --git a/tests/baselines/reference/modulePreserve2.symbols b/tests/baselines/reference/modulePreserve2.symbols new file mode 100644 index 0000000000000..20d90a3d2fea4 --- /dev/null +++ b/tests/baselines/reference/modulePreserve2.symbols @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/modulePreserve2.ts] //// + +=== /index.ts === +import { esm } from "dep"; +>esm : Symbol(esm, Decl(index.ts, 0, 8)) + +import cjs = require("dep"); +>cjs : Symbol(cjs, Decl(index.ts, 0, 26)) + +=== /node_modules/dep/import.d.mts === +export const esm: "esm"; +>esm : Symbol(esm, Decl(import.d.mts, 0, 12)) + +=== /node_modules/dep/require.d.ts === +declare const cjs: "cjs"; +>cjs : Symbol(cjs, Decl(require.d.ts, 0, 13)) + +export = cjs; +>cjs : Symbol(cjs, Decl(require.d.ts, 0, 13)) + diff --git a/tests/baselines/reference/modulePreserve2.trace.json b/tests/baselines/reference/modulePreserve2.trace.json new file mode 100644 index 0000000000000..156b93597b9cc --- /dev/null +++ b/tests/baselines/reference/modulePreserve2.trace.json @@ -0,0 +1,866 @@ +[ + "======== Resolving module 'dep' from '/index.ts'. ========", + "Module resolution kind is not specified, using 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "File '/package.json' does not exist.", + "Loading module 'dep' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Found 'package.json' at '/node_modules/dep/package.json'.", + "Entering conditional exports.", + "Matched 'exports' condition 'import'.", + "Using 'exports' subpath '.' with target './import.mjs'.", + "File name '/node_modules/dep/import.mjs' has a '.mjs' extension - stripping it.", + "File '/node_modules/dep/import.mts' does not exist.", + "File '/node_modules/dep/import.d.mts' exists - use it as a name resolution result.", + "Resolved under condition 'import'.", + "Exiting conditional exports.", + "Resolving real path for '/node_modules/dep/import.d.mts', result '/node_modules/dep/import.d.mts'.", + "======== Module name 'dep' was successfully resolved to '/node_modules/dep/import.d.mts'. ========", + "======== Resolving module 'dep' from '/index.ts'. ========", + "Module resolution kind is not specified, using 'Bundler'.", + "Resolving in CJS mode with conditions 'require', 'types'.", + "File '/package.json' does not exist according to earlier cached lookups.", + "Loading module 'dep' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "File '/node_modules/dep/package.json' exists according to earlier cached lookups.", + "Entering conditional exports.", + "Saw non-matching condition 'import'.", + "Matched 'exports' condition 'require'.", + "Using 'exports' subpath '.' with target './require.js'.", + "File name '/node_modules/dep/require.js' has a '.js' extension - stripping it.", + "File '/node_modules/dep/require.ts' does not exist.", + "File '/node_modules/dep/require.tsx' does not exist.", + "File '/node_modules/dep/require.d.ts' exists - use it as a name resolution result.", + "Resolved under condition 'require'.", + "Exiting conditional exports.", + "Resolving real path for '/node_modules/dep/require.d.ts', result '/node_modules/dep/require.d.ts'.", + "======== Module name 'dep' was successfully resolved to '/node_modules/dep/require.d.ts'. ========", + "======== Resolving module '@typescript/lib-esnext' from '/.src/__lib_node_modules_lookup_lib.esnext.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext'", + "Loading module '@typescript/lib-esnext' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2023' from '/.src/__lib_node_modules_lookup_lib.es2023.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2023' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2023'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2023'", + "Loading module '@typescript/lib-es2023' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2023' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2022' from '/.src/__lib_node_modules_lookup_lib.es2022.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2022' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022'", + "Loading module '@typescript/lib-es2022' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2022' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2021' from '/.src/__lib_node_modules_lookup_lib.es2021.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2021' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2021'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2021'", + "Loading module '@typescript/lib-es2021' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2021' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020' from '/.src/__lib_node_modules_lookup_lib.es2020.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020'", + "Loading module '@typescript/lib-es2020' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2019' from '/.src/__lib_node_modules_lookup_lib.es2019.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2019' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019'", + "Loading module '@typescript/lib-es2019' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2019' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2018' from '/.src/__lib_node_modules_lookup_lib.es2018.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2018' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018'", + "Loading module '@typescript/lib-es2018' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2018' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2017' from '/.src/__lib_node_modules_lookup_lib.es2017.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2017' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017'", + "Loading module '@typescript/lib-es2017' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2017' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2016' from '/.src/__lib_node_modules_lookup_lib.es2016.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2016' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2016'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2016'", + "Loading module '@typescript/lib-es2016' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2016' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015' from '/.src/__lib_node_modules_lookup_lib.es2015.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015'", + "Loading module '@typescript/lib-es2015' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015' was not resolved. ========", + "======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es5' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators' from '/.src/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators/legacy' from '/.src/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/core' from '/.src/__lib_node_modules_lookup_lib.es2015.core.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/core' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/core'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/core'", + "Loading module '@typescript/lib-es2015/core' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/core' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/collection' from '/.src/__lib_node_modules_lookup_lib.es2015.collection.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/collection' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/collection'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/collection'", + "Loading module '@typescript/lib-es2015/collection' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/collection' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/iterable' from '/.src/__lib_node_modules_lookup_lib.es2015.iterable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/iterable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/iterable'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/iterable'", + "Loading module '@typescript/lib-es2015/iterable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/iterable' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/symbol' from '/.src/__lib_node_modules_lookup_lib.es2015.symbol.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/symbol' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/symbol'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/symbol'", + "Loading module '@typescript/lib-es2015/symbol' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/symbol' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/generator' from '/.src/__lib_node_modules_lookup_lib.es2015.generator.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/generator' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/generator'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/generator'", + "Loading module '@typescript/lib-es2015/generator' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/generator' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/promise' from '/.src/__lib_node_modules_lookup_lib.es2015.promise.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/promise' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/promise'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/promise'", + "Loading module '@typescript/lib-es2015/promise' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/proxy' from '/.src/__lib_node_modules_lookup_lib.es2015.proxy.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/proxy' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/proxy'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/proxy'", + "Loading module '@typescript/lib-es2015/proxy' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/proxy' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/reflect' from '/.src/__lib_node_modules_lookup_lib.es2015.reflect.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/reflect' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/reflect'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/reflect'", + "Loading module '@typescript/lib-es2015/reflect' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/reflect' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/symbol-wellknown' from '/.src/__lib_node_modules_lookup_lib.es2015.symbol.wellknown.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/symbol-wellknown' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/symbol-wellknown'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/symbol-wellknown'", + "Loading module '@typescript/lib-es2015/symbol-wellknown' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/symbol-wellknown' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2016/array-include' from '/.src/__lib_node_modules_lookup_lib.es2016.array.include.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2016/array-include' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2016/array-include'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2016/array-include'", + "Loading module '@typescript/lib-es2016/array-include' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2016/array-include' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2016/intl' from '/.src/__lib_node_modules_lookup_lib.es2016.intl.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2016/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2016/intl'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2016/intl'", + "Loading module '@typescript/lib-es2016/intl' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2016/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2017/object' from '/.src/__lib_node_modules_lookup_lib.es2017.object.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2017/object' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/object'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/object'", + "Loading module '@typescript/lib-es2017/object' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2017/object' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2017/sharedmemory' from '/.src/__lib_node_modules_lookup_lib.es2017.sharedmemory.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2017/sharedmemory' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/sharedmemory'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/sharedmemory'", + "Loading module '@typescript/lib-es2017/sharedmemory' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2017/sharedmemory' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2017/string' from '/.src/__lib_node_modules_lookup_lib.es2017.string.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2017/string' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/string'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/string'", + "Loading module '@typescript/lib-es2017/string' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2017/string' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2017/intl' from '/.src/__lib_node_modules_lookup_lib.es2017.intl.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2017/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/intl'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/intl'", + "Loading module '@typescript/lib-es2017/intl' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2017/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2017/typedarrays' from '/.src/__lib_node_modules_lookup_lib.es2017.typedarrays.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2017/typedarrays' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/typedarrays'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/typedarrays'", + "Loading module '@typescript/lib-es2017/typedarrays' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2017/typedarrays' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2017/date' from '/.src/__lib_node_modules_lookup_lib.es2017.date.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2017/date' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/date'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/date'", + "Loading module '@typescript/lib-es2017/date' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2017/date' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2018/asynciterable' from '/.src/__lib_node_modules_lookup_lib.es2018.asynciterable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2018/asynciterable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018/asynciterable'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018/asynciterable'", + "Loading module '@typescript/lib-es2018/asynciterable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2018/asynciterable' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2018/asyncgenerator' from '/.src/__lib_node_modules_lookup_lib.es2018.asyncgenerator.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2018/asyncgenerator' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018/asyncgenerator'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018/asyncgenerator'", + "Loading module '@typescript/lib-es2018/asyncgenerator' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2018/asyncgenerator' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2018/promise' from '/.src/__lib_node_modules_lookup_lib.es2018.promise.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2018/promise' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018/promise'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018/promise'", + "Loading module '@typescript/lib-es2018/promise' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2018/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2018/regexp' from '/.src/__lib_node_modules_lookup_lib.es2018.regexp.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2018/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018/regexp'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018/regexp'", + "Loading module '@typescript/lib-es2018/regexp' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2018/regexp' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2018/intl' from '/.src/__lib_node_modules_lookup_lib.es2018.intl.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2018/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018/intl'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018/intl'", + "Loading module '@typescript/lib-es2018/intl' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2018/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2019/array' from '/.src/__lib_node_modules_lookup_lib.es2019.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2019/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019/array'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019/array'", + "Loading module '@typescript/lib-es2019/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2019/array' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2019/object' from '/.src/__lib_node_modules_lookup_lib.es2019.object.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2019/object' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019/object'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019/object'", + "Loading module '@typescript/lib-es2019/object' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2019/object' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2019/string' from '/.src/__lib_node_modules_lookup_lib.es2019.string.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2019/string' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019/string'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019/string'", + "Loading module '@typescript/lib-es2019/string' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2019/string' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2019/symbol' from '/.src/__lib_node_modules_lookup_lib.es2019.symbol.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2019/symbol' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019/symbol'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019/symbol'", + "Loading module '@typescript/lib-es2019/symbol' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2019/symbol' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2019/intl' from '/.src/__lib_node_modules_lookup_lib.es2019.intl.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2019/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019/intl'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019/intl'", + "Loading module '@typescript/lib-es2019/intl' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2019/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020/bigint' from '/.src/__lib_node_modules_lookup_lib.es2020.bigint.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020/bigint' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/bigint'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/bigint'", + "Loading module '@typescript/lib-es2020/bigint' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020/bigint' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020/intl' from '/.src/__lib_node_modules_lookup_lib.es2020.intl.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/intl'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/intl'", + "Loading module '@typescript/lib-es2020/intl' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020/date' from '/.src/__lib_node_modules_lookup_lib.es2020.date.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020/date' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/date'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/date'", + "Loading module '@typescript/lib-es2020/date' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020/date' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020/number' from '/.src/__lib_node_modules_lookup_lib.es2020.number.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020/number' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/number'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/number'", + "Loading module '@typescript/lib-es2020/number' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020/number' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020/promise' from '/.src/__lib_node_modules_lookup_lib.es2020.promise.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020/promise' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/promise'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/promise'", + "Loading module '@typescript/lib-es2020/promise' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020/sharedmemory' from '/.src/__lib_node_modules_lookup_lib.es2020.sharedmemory.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020/sharedmemory' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/sharedmemory'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/sharedmemory'", + "Loading module '@typescript/lib-es2020/sharedmemory' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020/sharedmemory' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020/string' from '/.src/__lib_node_modules_lookup_lib.es2020.string.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020/string' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/string'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/string'", + "Loading module '@typescript/lib-es2020/string' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020/string' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020/symbol-wellknown' from '/.src/__lib_node_modules_lookup_lib.es2020.symbol.wellknown.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020/symbol-wellknown' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/symbol-wellknown'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/symbol-wellknown'", + "Loading module '@typescript/lib-es2020/symbol-wellknown' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020/symbol-wellknown' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2021/promise' from '/.src/__lib_node_modules_lookup_lib.es2021.promise.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2021/promise' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2021/promise'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2021/promise'", + "Loading module '@typescript/lib-es2021/promise' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2021/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2021/string' from '/.src/__lib_node_modules_lookup_lib.es2021.string.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2021/string' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2021/string'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2021/string'", + "Loading module '@typescript/lib-es2021/string' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2021/string' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2021/weakref' from '/.src/__lib_node_modules_lookup_lib.es2021.weakref.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2021/weakref' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2021/weakref'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2021/weakref'", + "Loading module '@typescript/lib-es2021/weakref' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2021/weakref' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2021/intl' from '/.src/__lib_node_modules_lookup_lib.es2021.intl.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2021/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2021/intl'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2021/intl'", + "Loading module '@typescript/lib-es2021/intl' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2021/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2022/array' from '/.src/__lib_node_modules_lookup_lib.es2022.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2022/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/array'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/array'", + "Loading module '@typescript/lib-es2022/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2022/array' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2022/error' from '/.src/__lib_node_modules_lookup_lib.es2022.error.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2022/error' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/error'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/error'", + "Loading module '@typescript/lib-es2022/error' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2022/error' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2022/intl' from '/.src/__lib_node_modules_lookup_lib.es2022.intl.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2022/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/intl'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/intl'", + "Loading module '@typescript/lib-es2022/intl' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2022/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2022/object' from '/.src/__lib_node_modules_lookup_lib.es2022.object.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2022/object' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/object'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/object'", + "Loading module '@typescript/lib-es2022/object' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2022/object' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2022/sharedmemory' from '/.src/__lib_node_modules_lookup_lib.es2022.sharedmemory.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2022/sharedmemory' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/sharedmemory'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/sharedmemory'", + "Loading module '@typescript/lib-es2022/sharedmemory' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2022/sharedmemory' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2022/string' from '/.src/__lib_node_modules_lookup_lib.es2022.string.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2022/string' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/string'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/string'", + "Loading module '@typescript/lib-es2022/string' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2022/string' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2022/regexp' from '/.src/__lib_node_modules_lookup_lib.es2022.regexp.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2022/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/regexp'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/regexp'", + "Loading module '@typescript/lib-es2022/regexp' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2022/regexp' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2023/array' from '/.src/__lib_node_modules_lookup_lib.es2023.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2023/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2023/array'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2023/array'", + "Loading module '@typescript/lib-es2023/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2023/array' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2023/collection' from '/.src/__lib_node_modules_lookup_lib.es2023.collection.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2023/collection' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2023/collection'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2023/collection'", + "Loading module '@typescript/lib-es2023/collection' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2023/collection' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/intl' from '/.src/__lib_node_modules_lookup_lib.esnext.intl.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/intl'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/intl'", + "Loading module '@typescript/lib-esnext/intl' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/decorators' from '/.src/__lib_node_modules_lookup_lib.esnext.decorators.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/decorators'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/decorators'", + "Loading module '@typescript/lib-esnext/decorators' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/decorators' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/disposable' from '/.src/__lib_node_modules_lookup_lib.esnext.disposable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/disposable' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/promise' from '/.src/__lib_node_modules_lookup_lib.esnext.promise.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/promise' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/promise'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/promise'", + "Loading module '@typescript/lib-esnext/promise' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom' was not resolved. ========", + "======== Resolving module '@typescript/lib-webworker/importscripts' from '/.src/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", + "======== Resolving module '@typescript/lib-scripthost' from '/.src/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-scripthost' was not resolved. ========", + "======== Resolving module '@typescript/lib-dom/iterable' from '/.src/__lib_node_modules_lookup_lib.dom.iterable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom/iterable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom/iterable'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom/iterable'", + "Loading module '@typescript/lib-dom/iterable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom/iterable' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/modulePreserve2.types b/tests/baselines/reference/modulePreserve2.types new file mode 100644 index 0000000000000..ec0ba382d72b8 --- /dev/null +++ b/tests/baselines/reference/modulePreserve2.types @@ -0,0 +1,20 @@ +//// [tests/cases/compiler/modulePreserve2.ts] //// + +=== /index.ts === +import { esm } from "dep"; +>esm : "esm" + +import cjs = require("dep"); +>cjs : "cjs" + +=== /node_modules/dep/import.d.mts === +export const esm: "esm"; +>esm : "esm" + +=== /node_modules/dep/require.d.ts === +declare const cjs: "cjs"; +>cjs : "cjs" + +export = cjs; +>cjs : "cjs" + diff --git a/tests/cases/compiler/modulePreserve2.ts b/tests/cases/compiler/modulePreserve2.ts new file mode 100644 index 0000000000000..720457207b48a --- /dev/null +++ b/tests/cases/compiler/modulePreserve2.ts @@ -0,0 +1,25 @@ +// @module: preserve +// @target: esnext +// @strict: true +// @traceResolution: true +// @noEmit: true + +// @Filename: /node_modules/dep/package.json +{ + "name": "dep", + "exports": { + "import": "./import.mjs", + "require": "./require.js" + } +} + +// @Filename: /node_modules/dep/import.d.mts +export const esm: "esm"; + +// @Filename: /node_modules/dep/require.d.ts +declare const cjs: "cjs"; +export = cjs; + +// @Filename: /index.ts +import { esm } from "dep"; +import cjs = require("dep"); \ No newline at end of file From facd177c5f0f7ae739c5fa51392930096c34b618 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 14 Dec 2023 12:28:58 -0800 Subject: [PATCH 06/31] Resolve require in JS --- src/compiler/binder.ts | 2 -- src/compiler/checker.ts | 12 ++++++------ src/compiler/program.ts | 10 +++++----- src/compiler/utilities.ts | 6 ------ tests/baselines/reference/modulePreserve2.symbols | 9 +++++---- tests/baselines/reference/modulePreserve2.trace.json | 4 ++-- tests/baselines/reference/modulePreserve2.types | 7 +++++-- tests/cases/compiler/modulePreserve2.ts | 7 ++++++- 8 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 6ea9b8269548a..7e9f3ced07fec 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -282,7 +282,6 @@ import { setValueDeclaration, ShorthandPropertyAssignment, shouldPreserveConstEnums, - shouldResolveJsRequire, SignatureDeclaration, skipParentheses, sliceAfter, @@ -3559,7 +3558,6 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { const possibleVariableDecl = node.kind === SyntaxKind.VariableDeclaration ? node : node.parent.parent; if ( isInJSFile(node) && - shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & ModifierFlags.Export) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f0f1ea2168f98..9bbd01172bcf8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -958,7 +958,6 @@ import { ShorthandPropertyAssignment, shouldAllowImportingTsExtension, shouldPreserveConstEnums, - shouldResolveJsRequire, Signature, SignatureDeclaration, SignatureFlags, @@ -5000,12 +4999,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const currentSourceFile = getSourceFileOfNode(location); const contextSpecifier = isStringLiteralLike(location) ? location - : findAncestor(location, isImportCall)?.arguments[0] || + : (isModuleDeclaration(location) ? location : location.parent && isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : undefined)?.name || + (isLiteralImportTypeNode(location) ? location : undefined)?.argument.literal || + (isVariableDeclaration(location) && location.initializer && isRequireCall(location.initializer, /*requireStringLiteralLikeArgument*/ true) ? location.initializer.arguments[0] : undefined) || + findAncestor(location, isImportCall)?.arguments[0] || findAncestor(location, isImportDeclaration)?.moduleSpecifier || findAncestor(location, isExternalModuleImportEqualsDeclaration)?.moduleReference.expression || - findAncestor(location, isExportDeclaration)?.moduleSpecifier || - (isModuleDeclaration(location) ? location : location.parent && isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : undefined)?.name || - (isLiteralImportTypeNode(location) ? location : undefined)?.argument.literal; + findAncestor(location, isExportDeclaration)?.moduleSpecifier; const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? getModeForUsageLocation(currentSourceFile, contextSpecifier, compilerOptions) : currentSourceFile.impliedNodeFormat; const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions); const resolvedModule = host.getResolvedModule(currentSourceFile, moduleReference, mode)?.resolvedModule; @@ -35521,7 +35521,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } // In JavaScript files, calls to any identifier 'require' are treated as external module imports - if (isInJSFile(node) && shouldResolveJsRequire(compilerOptions) && isCommonJsRequire(node)) { + if (isInJSFile(node) && isCommonJsRequire(node)) { return resolveExternalModuleTypeByLiteral(node.arguments![0] as StringLiteral); } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index ec29e361e28d8..a44f4d8122aa3 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -286,7 +286,6 @@ import { ScriptTarget, setParent, setParentRecursive, - shouldResolveJsRequire, skipTrivia, skipTypeChecking, some, @@ -904,7 +903,9 @@ export function getModeForUsageLocation(file: { impliedNodeFormat?: ResolutionMo } } if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Bundler) { - return usage.parent.parent && isImportEqualsDeclaration(usage.parent.parent) ? ModuleKind.CommonJS : ModuleKind.ESNext; + return (usage.parent.parent && isImportEqualsDeclaration(usage.parent.parent) || isRequireCall(usage.parent, /*requireStringLiteralLikeArgument*/ false)) + ? ModuleKind.CommonJS + : ModuleKind.ESNext; } if (file.impliedNodeFormat === undefined) return undefined; if (file.impliedNodeFormat !== ModuleKind.ESNext) { @@ -3349,8 +3350,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg collectModuleReferences(node, /*inAmbientModule*/ false); } - const shouldProcessRequires = isJavaScriptFile && shouldResolveJsRequire(options); - if ((file.flags & NodeFlags.PossiblyContainsDynamicImport) || shouldProcessRequires) { + if ((file.flags & NodeFlags.PossiblyContainsDynamicImport) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } @@ -3412,7 +3412,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg const r = /import|require/g; while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null const node = getNodeAtPosition(file, r.lastIndex); - if (shouldProcessRequires && isRequireCall(node, /*requireStringLiteralLikeArgument*/ true)) { + if (isJavaScriptFile && isRequireCall(node, /*requireStringLiteralLikeArgument*/ true)) { setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here imports = append(imports, node.arguments[0]); } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index a0283056fe423..13a2c868cb0a7 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -8890,12 +8890,6 @@ export function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResol || moduleResolution === ModuleResolutionKind.Bundler; } -/** @internal */ -export function shouldResolveJsRequire(compilerOptions: CompilerOptions): boolean { - // `bundler` doesn't support resolving `require`, but needs to in `noDtsResolution` to support Find Source Definition - return !!compilerOptions.noDtsResolution || getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Bundler; -} - /** @internal */ export type StrictOptionName = | "noImplicitAny" diff --git a/tests/baselines/reference/modulePreserve2.symbols b/tests/baselines/reference/modulePreserve2.symbols index 20d90a3d2fea4..682d40164272d 100644 --- a/tests/baselines/reference/modulePreserve2.symbols +++ b/tests/baselines/reference/modulePreserve2.symbols @@ -1,11 +1,12 @@ //// [tests/cases/compiler/modulePreserve2.ts] //// -=== /index.ts === +=== /main.js === import { esm } from "dep"; ->esm : Symbol(esm, Decl(index.ts, 0, 8)) +>esm : Symbol(esm, Decl(main.js, 0, 8)) -import cjs = require("dep"); ->cjs : Symbol(cjs, Decl(index.ts, 0, 26)) +const cjs = require("dep"); +>cjs : Symbol(cjs, Decl(main.js, 1, 5)) +>require : Symbol(require) === /node_modules/dep/import.d.mts === export const esm: "esm"; diff --git a/tests/baselines/reference/modulePreserve2.trace.json b/tests/baselines/reference/modulePreserve2.trace.json index 156b93597b9cc..6f6668093cc41 100644 --- a/tests/baselines/reference/modulePreserve2.trace.json +++ b/tests/baselines/reference/modulePreserve2.trace.json @@ -1,5 +1,5 @@ [ - "======== Resolving module 'dep' from '/index.ts'. ========", + "======== Resolving module 'dep' from '/main.js'. ========", "Module resolution kind is not specified, using 'Bundler'.", "Resolving in CJS mode with conditions 'import', 'types'.", "File '/package.json' does not exist.", @@ -16,7 +16,7 @@ "Exiting conditional exports.", "Resolving real path for '/node_modules/dep/import.d.mts', result '/node_modules/dep/import.d.mts'.", "======== Module name 'dep' was successfully resolved to '/node_modules/dep/import.d.mts'. ========", - "======== Resolving module 'dep' from '/index.ts'. ========", + "======== Resolving module 'dep' from '/main.js'. ========", "Module resolution kind is not specified, using 'Bundler'.", "Resolving in CJS mode with conditions 'require', 'types'.", "File '/package.json' does not exist according to earlier cached lookups.", diff --git a/tests/baselines/reference/modulePreserve2.types b/tests/baselines/reference/modulePreserve2.types index ec0ba382d72b8..50d0cfeb3894c 100644 --- a/tests/baselines/reference/modulePreserve2.types +++ b/tests/baselines/reference/modulePreserve2.types @@ -1,11 +1,14 @@ //// [tests/cases/compiler/modulePreserve2.ts] //// -=== /index.ts === +=== /main.js === import { esm } from "dep"; >esm : "esm" -import cjs = require("dep"); +const cjs = require("dep"); >cjs : "cjs" +>require("dep") : "cjs" +>require : any +>"dep" : "dep" === /node_modules/dep/import.d.mts === export const esm: "esm"; diff --git a/tests/cases/compiler/modulePreserve2.ts b/tests/cases/compiler/modulePreserve2.ts index 720457207b48a..16f72fac886e0 100644 --- a/tests/cases/compiler/modulePreserve2.ts +++ b/tests/cases/compiler/modulePreserve2.ts @@ -1,6 +1,7 @@ // @module: preserve // @target: esnext // @strict: true +// @checkJs: true // @traceResolution: true // @noEmit: true @@ -22,4 +23,8 @@ export = cjs; // @Filename: /index.ts import { esm } from "dep"; -import cjs = require("dep"); \ No newline at end of file +import cjs = require("dep"); + +// @Filename: /main.js +import { esm } from "dep"; +const cjs = require("dep"); From 60f2d96c9fd330df8bbfa6f45091ef383d953767 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 14 Dec 2023 13:25:17 -0800 Subject: [PATCH 07/31] Allow TLA and import attributes --- src/compiler/checker.ts | 9 ++-- src/compiler/diagnosticMessages.json | 6 +-- .../codefixes/fixModuleAndTargetOptions.ts | 2 +- .../awaitInNonAsyncFunction.errors.txt | 4 +- .../bundlerSyntaxRestrictions.symbols | 4 +- .../reference/bundlerSyntaxRestrictions.types | 12 ++--- ...portAssertion1(module=commonjs).errors.txt | 20 ++++---- ...importAssertion1(module=es2015).errors.txt | 20 ++++---- ...portAssertion2(module=commonjs).errors.txt | 24 +++++----- ...importAssertion2(module=es2015).errors.txt | 24 +++++----- ...importAssertion3(module=es2015).errors.txt | 16 +++---- ...ortAttributes1(module=commonjs).errors.txt | 20 ++++---- ...mportAttributes1(module=es2015).errors.txt | 20 ++++---- ...ortAttributes2(module=commonjs).errors.txt | 24 +++++----- ...mportAttributes2(module=es2015).errors.txt | 24 +++++----- ...mportAttributes3(module=es2015).errors.txt | 16 +++---- ...wJsTopLevelAwait(module=node16).errors.txt | 4 +- ...sTopLevelAwait(module=nodenext).errors.txt | 4 +- ...DynamicImportWithPackageExports.errors.txt | 48 +++++++++---------- ...cifierResolution(module=node16).errors.txt | 4 +- ...fierResolution(module=nodenext).errors.txt | 4 +- ...sExportsSourceTs(module=node16).errors.txt | 4 +- ...xportsSourceTs(module=nodenext).errors.txt | 4 +- ...rationConditions(module=node16).errors.txt | 4 +- ...tionConditions(module=nodenext).errors.txt | 4 +- ...erationDirectory(module=node16).errors.txt | 4 +- ...ationDirectory(module=nodenext).errors.txt | 4 +- ...enerationPattern(module=node16).errors.txt | 4 +- ...erationPattern(module=nodenext).errors.txt | 4 +- ...ImportAssertions(module=node16).errors.txt | 8 ++-- ...ImportAttributes(module=node16).errors.txt | 8 ++-- ...DeclarationEmit1(module=node16).errors.txt | 8 ++-- ...DeclarationEmit2(module=node16).errors.txt | 8 ++-- ...rationEmitErrors(module=node16).errors.txt | 12 ++--- ...DeclarationEmit1(module=node16).errors.txt | 8 ++-- ...DeclarationEmit2(module=node16).errors.txt | 8 ++-- ...ationEmitErrors1(module=node16).errors.txt | 12 ++--- ...lesTopLevelAwait(module=node16).errors.txt | 4 +- ...sTopLevelAwait(module=nodenext).errors.txt | 4 +- ....1(module=es2022,target=es2015).errors.txt | 8 ++-- ....1(module=esnext,target=es2015).errors.txt | 8 ++-- ....1(module=system,target=es2015).errors.txt | 8 ++-- 42 files changed, 224 insertions(+), 221 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9bbd01172bcf8..3394138c70c71 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -37455,6 +37455,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // fallthrough case ModuleKind.ES2022: case ModuleKind.ESNext: + case ModuleKind.Preserve: case ModuleKind.System: if (languageVersion >= ScriptTarget.ES2017) { break; @@ -37462,7 +37463,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // fallthrough default: span ??= getSpanOfTokenAtPosition(sourceFile, node.pos); - const message = isAwaitExpression(node) ? Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher : + const message = isAwaitExpression(node) ? Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher : Diagnostics.Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher; diagnostics.add(createFileDiagnostic(sourceFile, span.start, span.length, message)); hasError = true; @@ -45762,14 +45763,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } const mode = (moduleKind === ModuleKind.NodeNext) && declaration.moduleSpecifier && getUsageModeForExpression(declaration.moduleSpecifier); - if (mode !== ModuleKind.ESNext && moduleKind !== ModuleKind.ESNext) { + if (mode !== ModuleKind.ESNext && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.Preserve) { const message = isImportAttributes ? moduleKind === ModuleKind.NodeNext ? Diagnostics.Import_attributes_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls - : Diagnostics.Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext + : Diagnostics.Import_attributes_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve : moduleKind === ModuleKind.NodeNext ? Diagnostics.Import_assertions_are_not_allowed_on_statements_that_compile_to_CommonJS_require_calls - : Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_or_nodenext; + : Diagnostics.Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_nodenext_or_preserve; return grammarErrorOnNode(node, message); } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index e2e45a5911769..920bd12ba38f9 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1220,7 +1220,7 @@ "category": "Message", "code": 1377 }, - "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": { + "Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.": { "category": "Error", "code": 1378 }, @@ -3595,7 +3595,7 @@ "category": "Error", "code": 2820 }, - "Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'.": { + "Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.": { "category": "Error", "code": 2821 }, @@ -3603,7 +3603,7 @@ "category": "Error", "code": 2822 }, - "Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'.": { + "Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'.": { "category": "Error", "code": 2823 }, diff --git a/src/services/codefixes/fixModuleAndTargetOptions.ts b/src/services/codefixes/fixModuleAndTargetOptions.ts index 7446e4babe1d2..1974c7822e3f9 100644 --- a/src/services/codefixes/fixModuleAndTargetOptions.ts +++ b/src/services/codefixes/fixModuleAndTargetOptions.ts @@ -19,7 +19,7 @@ import { registerCodeFix({ errorCodes: [ - Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher.code, Diagnostics.Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, ], diff --git a/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt b/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt index 2af730bfb9e8c..47c0d21bb9f09 100644 --- a/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt +++ b/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt @@ -13,7 +13,7 @@ awaitInNonAsyncFunction.ts(31,5): error TS1308: 'await' expressions are only all awaitInNonAsyncFunction.ts(34,7): error TS1103: 'for await' loops are only allowed within async functions and at the top levels of modules. awaitInNonAsyncFunction.ts(35,5): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. awaitInNonAsyncFunction.ts(39,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ==== awaitInNonAsyncFunction.ts (16 errors) ==== @@ -100,4 +100,4 @@ awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions ar !!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. await null; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. \ No newline at end of file +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. \ No newline at end of file diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions.symbols b/tests/baselines/reference/bundlerSyntaxRestrictions.symbols index 84ff7ff94494e..6eca85325b7a4 100644 --- a/tests/baselines/reference/bundlerSyntaxRestrictions.symbols +++ b/tests/baselines/reference/bundlerSyntaxRestrictions.symbols @@ -33,14 +33,16 @@ declare module "path" { === /mainJs.js === import {} from "./a"; import("./a"); ->"./a" : Symbol("/a", Decl(a.ts, 0, 0)) +>"./a" : Symbol(_, Decl(a.ts, 0, 0)) const _ = require("./a"); // No resolution >_ : Symbol(_, Decl(mainJs.js, 2, 5)) >require : Symbol(require, Decl(index.d.ts, 0, 11)) _.a; // any +>_.a : Symbol(_.a, Decl(a.ts, 0, 12)) >_ : Symbol(_, Decl(mainJs.js, 2, 5)) +>a : Symbol(_.a, Decl(a.ts, 0, 12)) === /main.ts === import {} from "./a"; diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions.types b/tests/baselines/reference/bundlerSyntaxRestrictions.types index 7f0b80dac1ded..52d0390d222e1 100644 --- a/tests/baselines/reference/bundlerSyntaxRestrictions.types +++ b/tests/baselines/reference/bundlerSyntaxRestrictions.types @@ -33,19 +33,19 @@ declare module "path" { === /mainJs.js === import {} from "./a"; import("./a"); ->import("./a") : Promise +>import("./a") : Promise >"./a" : "./a" const _ = require("./a"); // No resolution ->_ : any ->require("./a") : any +>_ : typeof _ +>require("./a") : typeof _ >require : (...args: any[]) => any >"./a" : "./a" _.a; // any ->_.a : any ->_ : any ->a : any +>_.a : "a" +>_ : typeof _ +>a : "a" === /main.ts === import {} from "./a"; diff --git a/tests/baselines/reference/importAssertion1(module=commonjs).errors.txt b/tests/baselines/reference/importAssertion1(module=commonjs).errors.txt index c937b51391439..f82c3d583d8de 100644 --- a/tests/baselines/reference/importAssertion1(module=commonjs).errors.txt +++ b/tests/baselines/reference/importAssertion1(module=commonjs).errors.txt @@ -1,8 +1,8 @@ -1.ts(1,14): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +1.ts(1,14): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. 3.ts(2,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. 3.ts(3,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. 3.ts(4,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. @@ -21,13 +21,13 @@ ==== 1.ts (3 errors) ==== import './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import { a, b } from './0' assert { "type": "json" } ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import * as foo from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. a; b; foo.a; @@ -36,10 +36,10 @@ ==== 2.ts (2 errors) ==== import { a, b } from './0' assert {} ~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import { a as c, b as d } from './0' assert { a: "a", b: "b", c: "c" } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. a; b; c; diff --git a/tests/baselines/reference/importAssertion1(module=es2015).errors.txt b/tests/baselines/reference/importAssertion1(module=es2015).errors.txt index 44aeede5b994c..90dc6fb333c80 100644 --- a/tests/baselines/reference/importAssertion1(module=es2015).errors.txt +++ b/tests/baselines/reference/importAssertion1(module=es2015).errors.txt @@ -1,8 +1,8 @@ -1.ts(1,14): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +1.ts(1,14): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. 3.ts(1,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. 3.ts(2,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. 3.ts(3,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. @@ -21,13 +21,13 @@ ==== 1.ts (3 errors) ==== import './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import { a, b } from './0' assert { "type": "json" } ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import * as foo from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. a; b; foo.a; @@ -36,10 +36,10 @@ ==== 2.ts (2 errors) ==== import { a, b } from './0' assert {} ~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import { a as c, b as d } from './0' assert { a: "a", b: "b", c: "c" } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. a; b; c; diff --git a/tests/baselines/reference/importAssertion2(module=commonjs).errors.txt b/tests/baselines/reference/importAssertion2(module=commonjs).errors.txt index e902dce6562c6..beba23ce610d7 100644 --- a/tests/baselines/reference/importAssertion2(module=commonjs).errors.txt +++ b/tests/baselines/reference/importAssertion2(module=commonjs).errors.txt @@ -1,9 +1,9 @@ -1.ts(1,22): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(3,21): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(4,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +1.ts(1,22): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(3,21): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(4,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== 0.ts (0 errors) ==== @@ -13,22 +13,22 @@ ==== 1.ts (4 errors) ==== export {} from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export { a, b } from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export * from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export * as ns from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== 2.ts (2 errors) ==== export { a, b } from './0' assert {} ~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export { a as c, b as d } from './0' assert { a: "a", b: "b", c: "c" } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. \ No newline at end of file diff --git a/tests/baselines/reference/importAssertion2(module=es2015).errors.txt b/tests/baselines/reference/importAssertion2(module=es2015).errors.txt index e902dce6562c6..beba23ce610d7 100644 --- a/tests/baselines/reference/importAssertion2(module=es2015).errors.txt +++ b/tests/baselines/reference/importAssertion2(module=es2015).errors.txt @@ -1,9 +1,9 @@ -1.ts(1,22): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(3,21): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(4,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +1.ts(1,22): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(2,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(3,21): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(4,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== 0.ts (0 errors) ==== @@ -13,22 +13,22 @@ ==== 1.ts (4 errors) ==== export {} from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export { a, b } from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export * from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export * as ns from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== 2.ts (2 errors) ==== export { a, b } from './0' assert {} ~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export { a as c, b as d } from './0' assert { a: "a", b: "b", c: "c" } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. \ No newline at end of file diff --git a/tests/baselines/reference/importAssertion3(module=es2015).errors.txt b/tests/baselines/reference/importAssertion3(module=es2015).errors.txt index 05054102cd71a..dfd16488102fc 100644 --- a/tests/baselines/reference/importAssertion3(module=es2015).errors.txt +++ b/tests/baselines/reference/importAssertion3(module=es2015).errors.txt @@ -1,7 +1,7 @@ -1.ts(1,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(2,30): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(1,31): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(2,33): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +1.ts(1,27): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(2,30): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(1,31): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(2,33): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== 0.ts (0 errors) ==== @@ -10,17 +10,17 @@ ==== 1.ts (2 errors) ==== export type {} from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export type { I } from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== 2.ts (2 errors) ==== import type { I } from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import type * as foo from './0' assert { type: "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. \ No newline at end of file diff --git a/tests/baselines/reference/importAttributes1(module=commonjs).errors.txt b/tests/baselines/reference/importAttributes1(module=commonjs).errors.txt index 88b174f0b1ae4..41f8ab32df20e 100644 --- a/tests/baselines/reference/importAttributes1(module=commonjs).errors.txt +++ b/tests/baselines/reference/importAttributes1(module=commonjs).errors.txt @@ -1,8 +1,8 @@ -1.ts(1,14): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(2,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(3,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(1,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(2,38): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +1.ts(1,14): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(2,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(3,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(1,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(2,38): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. 3.ts(2,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. 3.ts(3,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. 3.ts(4,25): error TS1324: Dynamic imports only support a second argument when the '--module' option is set to 'esnext', 'node16', or 'nodenext'. @@ -21,13 +21,13 @@ ==== 1.ts (3 errors) ==== import './0' with { type: "json" } ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import { a, b } from './0' with { "type": "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import * as foo from './0' with { type: "json" } ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. a; b; foo.a; @@ -35,10 +35,10 @@ ==== 2.ts (2 errors) ==== import { a, b } from './0' with {} ~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import { a as c, b as d } from './0' with { a: "a", b: "b", c: "c" } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. a; b; c; diff --git a/tests/baselines/reference/importAttributes1(module=es2015).errors.txt b/tests/baselines/reference/importAttributes1(module=es2015).errors.txt index e8259d6d21743..960f52554339b 100644 --- a/tests/baselines/reference/importAttributes1(module=es2015).errors.txt +++ b/tests/baselines/reference/importAttributes1(module=es2015).errors.txt @@ -1,8 +1,8 @@ -1.ts(1,14): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(2,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(3,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(1,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(2,38): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +1.ts(1,14): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(2,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(3,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(1,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(2,38): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. 3.ts(1,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. 3.ts(2,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. 3.ts(3,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'es2022', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node16', or 'nodenext'. @@ -21,13 +21,13 @@ ==== 1.ts (3 errors) ==== import './0' with { type: "json" } ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import { a, b } from './0' with { "type": "json" } ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import * as foo from './0' with { type: "json" } ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. a; b; foo.a; @@ -35,10 +35,10 @@ ==== 2.ts (2 errors) ==== import { a, b } from './0' with {} ~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import { a as c, b as d } from './0' with { a: "a", b: "b", c: "c" } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. a; b; c; diff --git a/tests/baselines/reference/importAttributes2(module=commonjs).errors.txt b/tests/baselines/reference/importAttributes2(module=commonjs).errors.txt index 0d4945bf1e550..144a6f2779301 100644 --- a/tests/baselines/reference/importAttributes2(module=commonjs).errors.txt +++ b/tests/baselines/reference/importAttributes2(module=commonjs).errors.txt @@ -1,9 +1,9 @@ -1.ts(1,22): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(2,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(3,21): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(4,27): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(1,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(2,38): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +1.ts(1,22): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(2,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(3,21): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(4,27): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(1,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(2,38): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== 0.ts (0 errors) ==== @@ -13,22 +13,22 @@ ==== 1.ts (4 errors) ==== export {} from './0' with { type: "json" } ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export { a, b } from './0' with { type: "json" } ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export * from './0' with { type: "json" } ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export * as ns from './0' with { type: "json" } ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== 2.ts (2 errors) ==== export { a, b } from './0' with {} ~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export { a as c, b as d } from './0' with { a: "a", b: "b", c: "c" } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. \ No newline at end of file diff --git a/tests/baselines/reference/importAttributes2(module=es2015).errors.txt b/tests/baselines/reference/importAttributes2(module=es2015).errors.txt index 0d4945bf1e550..144a6f2779301 100644 --- a/tests/baselines/reference/importAttributes2(module=es2015).errors.txt +++ b/tests/baselines/reference/importAttributes2(module=es2015).errors.txt @@ -1,9 +1,9 @@ -1.ts(1,22): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(2,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(3,21): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(4,27): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(1,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(2,38): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +1.ts(1,22): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(2,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(3,21): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(4,27): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(1,28): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(2,38): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== 0.ts (0 errors) ==== @@ -13,22 +13,22 @@ ==== 1.ts (4 errors) ==== export {} from './0' with { type: "json" } ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export { a, b } from './0' with { type: "json" } ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export * from './0' with { type: "json" } ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export * as ns from './0' with { type: "json" } ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== 2.ts (2 errors) ==== export { a, b } from './0' with {} ~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export { a as c, b as d } from './0' with { a: "a", b: "b", c: "c" } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. \ No newline at end of file diff --git a/tests/baselines/reference/importAttributes3(module=es2015).errors.txt b/tests/baselines/reference/importAttributes3(module=es2015).errors.txt index f34fea44998ec..23d166416e0d0 100644 --- a/tests/baselines/reference/importAttributes3(module=es2015).errors.txt +++ b/tests/baselines/reference/importAttributes3(module=es2015).errors.txt @@ -1,7 +1,7 @@ -1.ts(1,27): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -1.ts(2,30): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(1,31): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -2.ts(2,33): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +1.ts(1,27): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +1.ts(2,30): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(1,31): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +2.ts(2,33): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== 0.ts (0 errors) ==== @@ -10,16 +10,16 @@ ==== 1.ts (2 errors) ==== export type {} from './0' with { type: "json" } ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export type { I } from './0' with { type: "json" } ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== 2.ts (2 errors) ==== import type { I } from './0' with { type: "json" } ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import type * as foo from './0' with { type: "json" } ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).errors.txt index 6e03e95a210a6..a16e0fd308aac 100644 --- a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).errors.txt @@ -1,4 +1,4 @@ -index.js(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.js(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.js(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. subfolder/index.js(2,11): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. subfolder/index.js(4,5): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. @@ -17,7 +17,7 @@ subfolder/index.js(4,5): error TS1309: The current file is a CommonJS module and // esm format file const x = await 1; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. export {x}; for await (const y of []) {} ~~~~~ diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt index 6e03e95a210a6..a16e0fd308aac 100644 --- a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt @@ -1,4 +1,4 @@ -index.js(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.js(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.js(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. subfolder/index.js(2,11): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. subfolder/index.js(4,5): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. @@ -17,7 +17,7 @@ subfolder/index.js(4,5): error TS1309: The current file is a CommonJS module and // esm format file const x = await 1; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. export {x}; for await (const y of []) {} ~~~~~ diff --git a/tests/baselines/reference/nodeModulesDeclarationEmitDynamicImportWithPackageExports.errors.txt b/tests/baselines/reference/nodeModulesDeclarationEmitDynamicImportWithPackageExports.errors.txt index 4517eb8290ac4..3302c2b1ff01a 100644 --- a/tests/baselines/reference/nodeModulesDeclarationEmitDynamicImportWithPackageExports.errors.txt +++ b/tests/baselines/reference/nodeModulesDeclarationEmitDynamicImportWithPackageExports.errors.txt @@ -3,31 +3,31 @@ other.cts(2,18): error TS2712: A dynamic import call in ES5/ES3 requires the 'Pr other.cts(3,18): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. other.cts(4,18): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. other.cts(5,18): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -other.mts(2,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +other.mts(2,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. other.mts(2,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -other.mts(3,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +other.mts(3,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. other.mts(3,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -other.mts(4,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +other.mts(4,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. other.mts(4,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -other.mts(5,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +other.mts(5,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. other.mts(5,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -other.ts(2,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +other.ts(2,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. other.ts(2,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -other.ts(3,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +other.ts(3,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. other.ts(3,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -other.ts(4,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +other.ts(4,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. other.ts(4,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -other.ts(5,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +other.ts(5,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. other.ts(5,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. other2.cts(2,18): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. other2.cts(3,18): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -other2.mts(2,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +other2.mts(2,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. other2.mts(2,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -other2.mts(3,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +other2.mts(3,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. other2.mts(3,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -other2.ts(2,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +other2.ts(2,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. other2.ts(2,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -other2.ts(3,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +other2.ts(3,18): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. other2.ts(3,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -45,68 +45,68 @@ other2.ts(3,24): error TS2712: A dynamic import call in ES5/ES3 requires the 'Pr // esm format file export const a = await import("package/cjs"); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. export const b = await import("package/mjs"); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. export const c = await import("package"); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. export const f = await import("inner"); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. ==== other2.ts (4 errors) ==== // esm format file export const d = await import("inner/cjs"); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. export const e = await import("inner/mjs"); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. ==== other.mts (8 errors) ==== // esm format file export const a = await import("package/cjs"); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. export const b = await import("package/mjs"); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. export const c = await import("package"); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. export const f = await import("inner"); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. ==== other2.mts (4 errors) ==== // esm format file export const d = await import("inner/cjs"); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. export const e = await import("inner/mjs"); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. ==== other.cts (4 errors) ==== diff --git a/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt b/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt index 22d37a461c7ff..81aad1fb1c2c0 100644 --- a/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=node16).errors.txt @@ -1,7 +1,7 @@ error TS2468: Cannot find global value 'Promise'. index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. -index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -15,7 +15,7 @@ index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Pro ~ !!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. ==== node_modules/inner/index.d.ts (0 errors) ==== diff --git a/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=nodenext).errors.txt index 22d37a461c7ff..81aad1fb1c2c0 100644 --- a/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesExportsBlocksSpecifierResolution(module=nodenext).errors.txt @@ -1,7 +1,7 @@ error TS2468: Cannot find global value 'Promise'. index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. -index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -15,7 +15,7 @@ index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Pro ~ !!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. ==== node_modules/inner/index.d.ts (0 errors) ==== diff --git a/tests/baselines/reference/nodeModulesExportsSourceTs(module=node16).errors.txt b/tests/baselines/reference/nodeModulesExportsSourceTs(module=node16).errors.txt index ff14c896d8aea..23b9a209a09ab 100644 --- a/tests/baselines/reference/nodeModulesExportsSourceTs(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesExportsSourceTs(module=node16).errors.txt @@ -1,7 +1,7 @@ error TS2468: Cannot find global value 'Promise'. index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. -index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -15,7 +15,7 @@ index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Pro ~ !!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. import {a as a2} from "package"; diff --git a/tests/baselines/reference/nodeModulesExportsSourceTs(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesExportsSourceTs(module=nodenext).errors.txt index ff14c896d8aea..23b9a209a09ab 100644 --- a/tests/baselines/reference/nodeModulesExportsSourceTs(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesExportsSourceTs(module=nodenext).errors.txt @@ -1,7 +1,7 @@ error TS2468: Cannot find global value 'Promise'. index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. index.ts(3,14): error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. -index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -15,7 +15,7 @@ index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Pro ~ !!! error TS2742: The inferred type of 'a' cannot be named without a reference to './node_modules/inner/other.js'. This is likely not portable. A type annotation is necessary. ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. import {a as a2} from "package"; diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=node16).errors.txt b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=node16).errors.txt index 53d93d56c5341..23efc389d88dc 100644 --- a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=node16).errors.txt @@ -1,6 +1,6 @@ error TS2468: Cannot find global value 'Promise'. index.ts(2,23): error TS2307: Cannot find module 'inner/other.js' or its corresponding type declarations. -index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -12,7 +12,7 @@ index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Pro !!! error TS2307: Cannot find module 'inner/other.js' or its corresponding type declarations. export const a = (await import("inner")).x(); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. ==== node_modules/inner/index.d.ts (0 errors) ==== diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=nodenext).errors.txt index 53d93d56c5341..23efc389d88dc 100644 --- a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationConditions(module=nodenext).errors.txt @@ -1,6 +1,6 @@ error TS2468: Cannot find global value 'Promise'. index.ts(2,23): error TS2307: Cannot find module 'inner/other.js' or its corresponding type declarations. -index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -12,7 +12,7 @@ index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Pro !!! error TS2307: Cannot find module 'inner/other.js' or its corresponding type declarations. export const a = (await import("inner")).x(); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. ==== node_modules/inner/index.d.ts (0 errors) ==== diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=node16).errors.txt b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=node16).errors.txt index 255b56044536f..a560e039632e0 100644 --- a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=node16).errors.txt @@ -1,6 +1,6 @@ error TS2468: Cannot find global value 'Promise'. index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. -index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -12,7 +12,7 @@ index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Pro !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. export const a = (await import("inner/index.js")).x(); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. ==== node_modules/inner/index.d.ts (0 errors) ==== diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=nodenext).errors.txt index 255b56044536f..a560e039632e0 100644 --- a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationDirectory(module=nodenext).errors.txt @@ -1,6 +1,6 @@ error TS2468: Cannot find global value 'Promise'. index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. -index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -12,7 +12,7 @@ index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Pro !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. export const a = (await import("inner/index.js")).x(); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. ==== node_modules/inner/index.d.ts (0 errors) ==== diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=node16).errors.txt b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=node16).errors.txt index 0d315192d9817..ee87b40c2d998 100644 --- a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=node16).errors.txt @@ -1,6 +1,6 @@ error TS2468: Cannot find global value 'Promise'. index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. -index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -12,7 +12,7 @@ index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Pro !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. export const a = (await import("inner/index.js")).x(); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. ==== node_modules/inner/index.d.ts (0 errors) ==== diff --git a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=nodenext).errors.txt index 0d315192d9817..ee87b40c2d998 100644 --- a/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesExportsSpecifierGenerationPattern(module=nodenext).errors.txt @@ -1,6 +1,6 @@ error TS2468: Cannot find global value 'Promise'. index.ts(2,23): error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. -index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(3,19): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -12,7 +12,7 @@ index.ts(3,25): error TS2712: A dynamic import call in ES5/ES3 requires the 'Pro !!! error TS2307: Cannot find module 'inner/other' or its corresponding type declarations. export const a = (await import("inner/index.js")).x(); ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. ==== node_modules/inner/index.d.ts (0 errors) ==== diff --git a/tests/baselines/reference/nodeModulesImportAssertions(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportAssertions(module=node16).errors.txt index 9aec13e27c5a5..325782e103506 100644 --- a/tests/baselines/reference/nodeModulesImportAssertions(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesImportAssertions(module=node16).errors.txt @@ -1,6 +1,6 @@ error TS2468: Cannot find global value 'Promise'. -index.ts(1,35): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -otherc.cts(1,35): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +index.ts(1,35): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +otherc.cts(1,35): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. otherc.cts(2,15): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -8,11 +8,11 @@ otherc.cts(2,15): error TS2712: A dynamic import call in ES5/ES3 requires the 'P ==== index.ts (1 errors) ==== import json from "./package.json" assert { type: "json" }; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== otherc.cts (2 errors) ==== import json from "./package.json" assert { type: "json" }; // should error, cjs mode imports don't support assertions ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. const json2 = import("./package.json", { assert: { type: "json" } }); // should be fine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. diff --git a/tests/baselines/reference/nodeModulesImportAttributes(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportAttributes(module=node16).errors.txt index eebc7c09c975c..2aaaf1fd91040 100644 --- a/tests/baselines/reference/nodeModulesImportAttributes(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesImportAttributes(module=node16).errors.txt @@ -1,6 +1,6 @@ error TS2468: Cannot find global value 'Promise'. -index.ts(1,35): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -otherc.cts(1,35): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +index.ts(1,35): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +otherc.cts(1,35): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. otherc.cts(2,15): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. @@ -8,11 +8,11 @@ otherc.cts(2,15): error TS2712: A dynamic import call in ES5/ES3 requires the 'P ==== index.ts (1 errors) ==== import json from "./package.json" with { type: "json" }; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== otherc.cts (2 errors) ==== import json from "./package.json" with { type: "json" }; // should error, cjs mode imports don't support attributes ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. const json2 = import("./package.json", { with: { type: "json" } }); // should be fine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. diff --git a/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmit1(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmit1(module=node16).errors.txt index 55c25456e5507..5986330507739 100644 --- a/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmit1(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmit1(module=node16).errors.txt @@ -1,6 +1,6 @@ -/index.ts(6,50): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +/index.ts(6,50): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. /index.ts(7,14): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. -/index.ts(7,49): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +/index.ts(7,49): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== /index.ts (3 errors) ==== @@ -11,12 +11,12 @@ import {type RequireInterface as Req} from "pkg" with { "resolution-mode": "require" }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import {type ImportInterface as Imp} from "pkg" with { "resolution-mode": "import" }; ~~~~~~~~~~~~~~~ !!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export interface Loc extends Req, Imp {} export type { RequireInterface } from "pkg" with { "resolution-mode": "require" }; diff --git a/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmit2(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmit2(module=node16).errors.txt index 8cb0099fe8ce0..23d74c2152e6c 100644 --- a/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmit2(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmit2(module=node16).errors.txt @@ -1,6 +1,6 @@ /index.ts(6,14): error TS2305: Module '"pkg"' has no exported member 'RequireInterface'. -/index.ts(6,50): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -/index.ts(7,49): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +/index.ts(6,50): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +/index.ts(7,49): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== /index.ts (3 errors) ==== @@ -13,10 +13,10 @@ ~~~~~~~~~~~~~~~~ !!! error TS2305: Module '"pkg"' has no exported member 'RequireInterface'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import {type ImportInterface as Imp} from "pkg" with { "resolution-mode": "import" }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export interface Loc extends Req, Imp {} export type { RequireInterface } from "pkg" with { "resolution-mode": "require" }; diff --git a/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmitErrors(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmitErrors(module=node16).errors.txt index b7e3766635732..f488863314397 100644 --- a/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmitErrors(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesImportAttributesModeDeclarationEmitErrors(module=node16).errors.txt @@ -1,15 +1,15 @@ -/index.ts(2,45): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +/index.ts(2,45): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. /index.ts(2,71): error TS1453: `resolution-mode` should be either `require` or `import`. /index.ts(4,10): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. -/index.ts(4,39): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -/index.ts(6,76): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +/index.ts(4,39): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +/index.ts(6,76): error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== /index.ts (5 errors) ==== // incorrect mode import type { RequireInterface } from "pkg" with { "resolution-mode": "foobar" }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ~~~~~~~~ !!! error TS1453: `resolution-mode` should be either `require` or `import`. // not type-only @@ -17,11 +17,11 @@ ~~~~~~~~~~~~~~~ !!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. // not exclusively type-only import {type RequireInterface as Req, RequireInterface as Req2} from "pkg" with { "resolution-mode": "require" }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2823: Import attributes are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export interface LocalInterface extends RequireInterface, ImportInterface {} diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=node16).errors.txt index a8a76a05152b7..7ab6639b5d644 100644 --- a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit1(module=node16).errors.txt @@ -1,6 +1,6 @@ -/index.ts(6,50): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +/index.ts(6,50): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. /index.ts(7,14): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. -/index.ts(7,49): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +/index.ts(7,49): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== /index.ts (3 errors) ==== @@ -11,12 +11,12 @@ import {type RequireInterface as Req} from "pkg" assert { "resolution-mode": "require" }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import {type ImportInterface as Imp} from "pkg" assert { "resolution-mode": "import" }; ~~~~~~~~~~~~~~~ !!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export interface Loc extends Req, Imp {} export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=node16).errors.txt index 0403a6e026ffe..06d7b09c3ecbf 100644 --- a/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmit2(module=node16).errors.txt @@ -1,6 +1,6 @@ /index.ts(6,14): error TS2305: Module '"pkg"' has no exported member 'RequireInterface'. -/index.ts(6,50): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -/index.ts(7,49): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +/index.ts(6,50): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +/index.ts(7,49): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== /index.ts (3 errors) ==== @@ -13,10 +13,10 @@ ~~~~~~~~~~~~~~~~ !!! error TS2305: Module '"pkg"' has no exported member 'RequireInterface'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. import {type ImportInterface as Imp} from "pkg" assert { "resolution-mode": "import" }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export interface Loc extends Req, Imp {} export type { RequireInterface } from "pkg" assert { "resolution-mode": "require" }; diff --git a/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=node16).errors.txt b/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=node16).errors.txt index bc3eb30565c6f..b84ec4d29a319 100644 --- a/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesImportModeDeclarationEmitErrors1(module=node16).errors.txt @@ -1,15 +1,15 @@ -/index.ts(2,45): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +/index.ts(2,45): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. /index.ts(2,73): error TS1453: `resolution-mode` should be either `require` or `import`. /index.ts(4,10): error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. -/index.ts(4,39): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. -/index.ts(6,76): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +/index.ts(4,39): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. +/index.ts(6,76): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ==== /index.ts (5 errors) ==== // incorrect mode import type { RequireInterface } from "pkg" assert { "resolution-mode": "foobar" }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. ~~~~~~~~ !!! error TS1453: `resolution-mode` should be either `require` or `import`. // not type-only @@ -17,11 +17,11 @@ ~~~~~~~~~~~~~~~ !!! error TS2305: Module '"pkg"' has no exported member 'ImportInterface'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. // not exclusively type-only import {type RequireInterface as Req, RequireInterface as Req2} from "pkg" assert { "resolution-mode": "require" }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext' or 'nodenext'. +!!! error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext', 'nodenext', or 'preserve'. export interface LocalInterface extends RequireInterface, ImportInterface {} diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).errors.txt b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).errors.txt index b905febf46b75..a75cda3bf0997 100644 --- a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).errors.txt @@ -1,4 +1,4 @@ -index.ts(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.ts(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. subfolder/index.ts(2,11): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. subfolder/index.ts(4,5): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. @@ -17,7 +17,7 @@ subfolder/index.ts(4,5): error TS1309: The current file is a CommonJS module and // esm format file const x = await 1; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. export {x}; for await (const y of []) {} ~~~~~ diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt index b905febf46b75..a75cda3bf0997 100644 --- a/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt @@ -1,4 +1,4 @@ -index.ts(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.ts(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. subfolder/index.ts(2,11): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. subfolder/index.ts(4,5): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. @@ -17,7 +17,7 @@ subfolder/index.ts(4,5): error TS1309: The current file is a CommonJS module and // esm format file const x = await 1; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. export {x}; for await (const y of []) {} ~~~~~ diff --git a/tests/baselines/reference/topLevelAwait.1(module=es2022,target=es2015).errors.txt b/tests/baselines/reference/topLevelAwait.1(module=es2022,target=es2015).errors.txt index bf81980d92494..ba4194e299ae2 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=es2022,target=es2015).errors.txt +++ b/tests/baselines/reference/topLevelAwait.1(module=es2022,target=es2015).errors.txt @@ -1,5 +1,5 @@ -index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. @@ -7,7 +7,7 @@ other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when t export const x = 1; await x; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. // reparse element access as await await [x]; @@ -53,7 +53,7 @@ other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when t declare const dec: any; @(await dec) ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. class C { } diff --git a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt index bf81980d92494..ba4194e299ae2 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt +++ b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt @@ -1,5 +1,5 @@ -index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. @@ -7,7 +7,7 @@ other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when t export const x = 1; await x; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. // reparse element access as await await [x]; @@ -53,7 +53,7 @@ other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when t declare const dec: any; @(await dec) ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. class C { } diff --git a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt index bf81980d92494..ba4194e299ae2 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt +++ b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt @@ -1,5 +1,5 @@ -index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. @@ -7,7 +7,7 @@ other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when t export const x = 1; await x; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. // reparse element access as await await [x]; @@ -53,7 +53,7 @@ other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when t declare const dec: any; @(await dec) ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. class C { } From aea6e59d797711096e4f9093d8cb692feb16c5ed Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 14 Dec 2023 13:26:19 -0800 Subject: [PATCH 08/31] Remove outdated test comment --- .../baselines/reference/bundlerSyntaxRestrictions.errors.txt | 2 +- tests/baselines/reference/bundlerSyntaxRestrictions.js | 4 ++-- tests/baselines/reference/bundlerSyntaxRestrictions.symbols | 2 +- tests/baselines/reference/bundlerSyntaxRestrictions.types | 2 +- .../moduleResolution/bundler/bundlerSyntaxRestrictions.ts | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt b/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt index e2f27150dcca9..281834153b864 100644 --- a/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt +++ b/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt @@ -25,7 +25,7 @@ error TS2468: Cannot find global value 'Promise'. import("./a"); ~~~~~~~~~~~~~ !!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. - const _ = require("./a"); // No resolution + const _ = require("./a"); _.a; // any ==== /main.ts (2 errors) ==== diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions.js b/tests/baselines/reference/bundlerSyntaxRestrictions.js index a789516ae9a85..70e9b2b388b35 100644 --- a/tests/baselines/reference/bundlerSyntaxRestrictions.js +++ b/tests/baselines/reference/bundlerSyntaxRestrictions.js @@ -18,7 +18,7 @@ declare module "path" { //// [mainJs.js] import {} from "./a"; import("./a"); -const _ = require("./a"); // No resolution +const _ = require("./a"); _.a; // any //// [main.ts] @@ -35,7 +35,7 @@ export const a = "a"; export var a = "a"; //// [mainJs.js] import("./a"); -var _ = require("./a"); // No resolution +var _ = require("./a"); _.a; // any export {}; //// [main.js] diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions.symbols b/tests/baselines/reference/bundlerSyntaxRestrictions.symbols index 6eca85325b7a4..3de5d0c81acd7 100644 --- a/tests/baselines/reference/bundlerSyntaxRestrictions.symbols +++ b/tests/baselines/reference/bundlerSyntaxRestrictions.symbols @@ -35,7 +35,7 @@ import {} from "./a"; import("./a"); >"./a" : Symbol(_, Decl(a.ts, 0, 0)) -const _ = require("./a"); // No resolution +const _ = require("./a"); >_ : Symbol(_, Decl(mainJs.js, 2, 5)) >require : Symbol(require, Decl(index.d.ts, 0, 11)) diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions.types b/tests/baselines/reference/bundlerSyntaxRestrictions.types index 52d0390d222e1..c2809e3d74576 100644 --- a/tests/baselines/reference/bundlerSyntaxRestrictions.types +++ b/tests/baselines/reference/bundlerSyntaxRestrictions.types @@ -36,7 +36,7 @@ import("./a"); >import("./a") : Promise >"./a" : "./a" -const _ = require("./a"); // No resolution +const _ = require("./a"); >_ : typeof _ >require("./a") : typeof _ >require : (...args: any[]) => any diff --git a/tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts index e71313bca4cf9..1c8f832030284 100644 --- a/tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts @@ -22,7 +22,7 @@ declare module "path" { // @Filename: /mainJs.js import {} from "./a"; import("./a"); -const _ = require("./a"); // No resolution +const _ = require("./a"); _.a; // any // @Filename: /main.ts From 295104dcf0f3d66660f14ea6df2539696318fe11 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 14 Dec 2023 10:12:16 -0800 Subject: [PATCH 09/31] REVERT ME: esnext -> preserve for RWC testing --- src/compiler/commandLineParser.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 359587bdeb669..e4c0f3e30fee5 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -549,11 +549,11 @@ export const moduleOptionDeclaration: CommandLineOptionOfCustomType = { amd: ModuleKind.AMD, system: ModuleKind.System, umd: ModuleKind.UMD, - es6: ModuleKind.ES2015, - es2015: ModuleKind.ES2015, - es2020: ModuleKind.ES2020, - es2022: ModuleKind.ES2022, - esnext: ModuleKind.ESNext, + es6: ModuleKind.Preserve, + es2015: ModuleKind.Preserve, + es2020: ModuleKind.Preserve, + es2022: ModuleKind.Preserve, + esnext: ModuleKind.Preserve, node16: ModuleKind.Node16, nodenext: ModuleKind.NodeNext, preserve: ModuleKind.Preserve, From e7bdce6e360dbb825a9a3429e4a56b8d466fff8f Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 14 Dec 2023 13:40:22 -0800 Subject: [PATCH 10/31] Revert "REVERT ME: esnext -> preserve for RWC testing" This reverts commit 295104dcf0f3d66660f14ea6df2539696318fe11. --- src/compiler/commandLineParser.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index e4c0f3e30fee5..359587bdeb669 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -549,11 +549,11 @@ export const moduleOptionDeclaration: CommandLineOptionOfCustomType = { amd: ModuleKind.AMD, system: ModuleKind.System, umd: ModuleKind.UMD, - es6: ModuleKind.Preserve, - es2015: ModuleKind.Preserve, - es2020: ModuleKind.Preserve, - es2022: ModuleKind.Preserve, - esnext: ModuleKind.Preserve, + es6: ModuleKind.ES2015, + es2015: ModuleKind.ES2015, + es2020: ModuleKind.ES2020, + es2022: ModuleKind.ES2022, + esnext: ModuleKind.ESNext, node16: ModuleKind.Node16, nodenext: ModuleKind.NodeNext, preserve: ModuleKind.Preserve, From db0ca3326cb241d91fd661d0098e6696fd54dc69 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 14 Dec 2023 15:36:34 -0800 Subject: [PATCH 11/31] Fix resolution of JSX synthesized import --- src/compiler/checker.ts | 8 +- .../reference/modulePreserve3.errors.txt | 15 + .../reference/modulePreserve3.trace.json | 798 ++++++++++++++++++ tests/cases/compiler/modulePreserve3.ts | 13 + 4 files changed, 833 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/modulePreserve3.errors.txt create mode 100644 tests/baselines/reference/modulePreserve3.trace.json create mode 100644 tests/cases/compiler/modulePreserve3.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3394138c70c71..61e08ab26726f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -31793,7 +31793,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const errorMessage = isClassic ? Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option : Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations; - const mod = resolveExternalModule(location!, runtimeImportSpecifier, errorMessage, location!); + // Synthesized JSX import is either first or after tslib + const jsxImportIndex = compilerOptions.importHelpers ? 1 : 0; + const specifier = file?.imports[jsxImportIndex]; + if (specifier) { + Debug.assert(nodeIsSynthesized(specifier) && specifier.text === runtimeImportSpecifier, `Expected sourceFile.imports[${jsxImportIndex}] to be the synthesized JSX runtime import`); + } + const mod = resolveExternalModule(specifier || location!, runtimeImportSpecifier, errorMessage, location!); const result = mod && mod !== unknownSymbol ? getMergedSymbol(resolveSymbol(mod)) : undefined; if (links) { links.jsxImplicitImportContainer = result || false; diff --git a/tests/baselines/reference/modulePreserve3.errors.txt b/tests/baselines/reference/modulePreserve3.errors.txt new file mode 100644 index 0000000000000..4a322679eb97c --- /dev/null +++ b/tests/baselines/reference/modulePreserve3.errors.txt @@ -0,0 +1,15 @@ +error TS2688: Cannot find type definition file for 'react'. + The file is in the program because: + Entry point for implicit type library 'react' + + +!!! error TS2688: Cannot find type definition file for 'react'. +!!! error TS2688: The file is in the program because: +!!! error TS2688: Entry point for implicit type library 'react' +==== /node_modules/@types/react/jsx-runtime.d.ts (0 errors) ==== + export namespace JSX {} + +==== /index.tsx (0 errors) ==== + export {}; + (
); + \ No newline at end of file diff --git a/tests/baselines/reference/modulePreserve3.trace.json b/tests/baselines/reference/modulePreserve3.trace.json new file mode 100644 index 0000000000000..bc9728d5e5068 --- /dev/null +++ b/tests/baselines/reference/modulePreserve3.trace.json @@ -0,0 +1,798 @@ +[ + "======== Resolving module 'react/jsx-runtime' from '/index.tsx'. ========", + "Module resolution kind is not specified, using 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "File '/package.json' does not exist.", + "Loading module 'react/jsx-runtime' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "File '/node_modules/@types/react/package.json' does not exist.", + "File '/node_modules/@types/react/jsx-runtime.d.ts' exists - use it as a name resolution result.", + "Resolving real path for '/node_modules/@types/react/jsx-runtime.d.ts', result '/node_modules/@types/react/jsx-runtime.d.ts'.", + "======== Module name 'react/jsx-runtime' was successfully resolved to '/node_modules/@types/react/jsx-runtime.d.ts'. ========", + "======== Resolving type reference directive 'react', containing file '/.src/__inferred type names__.ts', root directory '/.src/node_modules/@types,/node_modules/@types'. ========", + "Resolving with primary search path '/.src/node_modules/@types, /node_modules/@types'.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "File '/node_modules/@types/react/package.json' does not exist according to earlier cached lookups.", + "File '/node_modules/@types/react/index.d.ts' does not exist.", + "Looking up in 'node_modules' folder, initial location '/.src'.", + "Searching all ancestor node_modules directories for preferred extensions: Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "File '/node_modules/react.d.ts' does not exist.", + "File '/node_modules/@types/react/package.json' does not exist according to earlier cached lookups.", + "File '/node_modules/@types/react.d.ts' does not exist.", + "File '/node_modules/@types/react/index.d.ts' does not exist.", + "======== Type reference directive 'react' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext' from '/.src/__lib_node_modules_lookup_lib.esnext.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext'", + "Scoped package detected, looking in 'typescript__lib-esnext'", + "File '/node_modules/@types/typescript__lib-esnext.d.ts' does not exist.", + "Loading module '@typescript/lib-esnext' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2023' from '/.src/__lib_node_modules_lookup_lib.es2023.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2023' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2023'", + "Scoped package detected, looking in 'typescript__lib-es2023'", + "File '/node_modules/@types/typescript__lib-es2023.d.ts' does not exist.", + "Loading module '@typescript/lib-es2023' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2023' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2022' from '/.src/__lib_node_modules_lookup_lib.es2022.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2022' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022'", + "Scoped package detected, looking in 'typescript__lib-es2022'", + "File '/node_modules/@types/typescript__lib-es2022.d.ts' does not exist.", + "Loading module '@typescript/lib-es2022' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2022' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2021' from '/.src/__lib_node_modules_lookup_lib.es2021.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2021' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2021'", + "Scoped package detected, looking in 'typescript__lib-es2021'", + "File '/node_modules/@types/typescript__lib-es2021.d.ts' does not exist.", + "Loading module '@typescript/lib-es2021' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2021' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020' from '/.src/__lib_node_modules_lookup_lib.es2020.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020'", + "Scoped package detected, looking in 'typescript__lib-es2020'", + "File '/node_modules/@types/typescript__lib-es2020.d.ts' does not exist.", + "Loading module '@typescript/lib-es2020' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2019' from '/.src/__lib_node_modules_lookup_lib.es2019.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2019' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019'", + "Scoped package detected, looking in 'typescript__lib-es2019'", + "File '/node_modules/@types/typescript__lib-es2019.d.ts' does not exist.", + "Loading module '@typescript/lib-es2019' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2019' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2018' from '/.src/__lib_node_modules_lookup_lib.es2018.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2018' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018'", + "Scoped package detected, looking in 'typescript__lib-es2018'", + "File '/node_modules/@types/typescript__lib-es2018.d.ts' does not exist.", + "Loading module '@typescript/lib-es2018' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2018' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2017' from '/.src/__lib_node_modules_lookup_lib.es2017.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2017' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017'", + "Scoped package detected, looking in 'typescript__lib-es2017'", + "File '/node_modules/@types/typescript__lib-es2017.d.ts' does not exist.", + "Loading module '@typescript/lib-es2017' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2017' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2016' from '/.src/__lib_node_modules_lookup_lib.es2016.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2016' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2016'", + "Scoped package detected, looking in 'typescript__lib-es2016'", + "File '/node_modules/@types/typescript__lib-es2016.d.ts' does not exist.", + "Loading module '@typescript/lib-es2016' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2016' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015' from '/.src/__lib_node_modules_lookup_lib.es2015.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015'", + "Scoped package detected, looking in 'typescript__lib-es2015'", + "File '/node_modules/@types/typescript__lib-es2015.d.ts' does not exist.", + "Loading module '@typescript/lib-es2015' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015' was not resolved. ========", + "======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Scoped package detected, looking in 'typescript__lib-es5'", + "File '/node_modules/@types/typescript__lib-es5.d.ts' does not exist.", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es5' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators' from '/.src/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "File '/node_modules/@types/typescript__lib-decorators.d.ts' does not exist.", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators/legacy' from '/.src/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/core' from '/.src/__lib_node_modules_lookup_lib.es2015.core.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/core' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/core'", + "Scoped package detected, looking in 'typescript__lib-es2015/core'", + "Loading module '@typescript/lib-es2015/core' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/core' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/collection' from '/.src/__lib_node_modules_lookup_lib.es2015.collection.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/collection' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/collection'", + "Scoped package detected, looking in 'typescript__lib-es2015/collection'", + "Loading module '@typescript/lib-es2015/collection' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/collection' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/iterable' from '/.src/__lib_node_modules_lookup_lib.es2015.iterable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/iterable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/iterable'", + "Scoped package detected, looking in 'typescript__lib-es2015/iterable'", + "Loading module '@typescript/lib-es2015/iterable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/iterable' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/symbol' from '/.src/__lib_node_modules_lookup_lib.es2015.symbol.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/symbol' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/symbol'", + "Scoped package detected, looking in 'typescript__lib-es2015/symbol'", + "Loading module '@typescript/lib-es2015/symbol' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/symbol' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/generator' from '/.src/__lib_node_modules_lookup_lib.es2015.generator.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/generator' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/generator'", + "Scoped package detected, looking in 'typescript__lib-es2015/generator'", + "Loading module '@typescript/lib-es2015/generator' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/generator' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/promise' from '/.src/__lib_node_modules_lookup_lib.es2015.promise.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/promise' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/promise'", + "Scoped package detected, looking in 'typescript__lib-es2015/promise'", + "Loading module '@typescript/lib-es2015/promise' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/proxy' from '/.src/__lib_node_modules_lookup_lib.es2015.proxy.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/proxy' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/proxy'", + "Scoped package detected, looking in 'typescript__lib-es2015/proxy'", + "Loading module '@typescript/lib-es2015/proxy' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/proxy' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/reflect' from '/.src/__lib_node_modules_lookup_lib.es2015.reflect.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/reflect' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/reflect'", + "Scoped package detected, looking in 'typescript__lib-es2015/reflect'", + "Loading module '@typescript/lib-es2015/reflect' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/reflect' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2015/symbol-wellknown' from '/.src/__lib_node_modules_lookup_lib.es2015.symbol.wellknown.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2015/symbol-wellknown' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2015/symbol-wellknown'", + "Scoped package detected, looking in 'typescript__lib-es2015/symbol-wellknown'", + "Loading module '@typescript/lib-es2015/symbol-wellknown' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2015/symbol-wellknown' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2016/array-include' from '/.src/__lib_node_modules_lookup_lib.es2016.array.include.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2016/array-include' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2016/array-include'", + "Scoped package detected, looking in 'typescript__lib-es2016/array-include'", + "Loading module '@typescript/lib-es2016/array-include' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2016/array-include' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2016/intl' from '/.src/__lib_node_modules_lookup_lib.es2016.intl.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2016/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2016/intl'", + "Scoped package detected, looking in 'typescript__lib-es2016/intl'", + "Loading module '@typescript/lib-es2016/intl' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2016/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2017/object' from '/.src/__lib_node_modules_lookup_lib.es2017.object.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2017/object' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/object'", + "Scoped package detected, looking in 'typescript__lib-es2017/object'", + "Loading module '@typescript/lib-es2017/object' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2017/object' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2017/sharedmemory' from '/.src/__lib_node_modules_lookup_lib.es2017.sharedmemory.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2017/sharedmemory' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/sharedmemory'", + "Scoped package detected, looking in 'typescript__lib-es2017/sharedmemory'", + "Loading module '@typescript/lib-es2017/sharedmemory' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2017/sharedmemory' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2017/string' from '/.src/__lib_node_modules_lookup_lib.es2017.string.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2017/string' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/string'", + "Scoped package detected, looking in 'typescript__lib-es2017/string'", + "Loading module '@typescript/lib-es2017/string' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2017/string' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2017/intl' from '/.src/__lib_node_modules_lookup_lib.es2017.intl.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2017/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/intl'", + "Scoped package detected, looking in 'typescript__lib-es2017/intl'", + "Loading module '@typescript/lib-es2017/intl' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2017/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2017/typedarrays' from '/.src/__lib_node_modules_lookup_lib.es2017.typedarrays.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2017/typedarrays' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/typedarrays'", + "Scoped package detected, looking in 'typescript__lib-es2017/typedarrays'", + "Loading module '@typescript/lib-es2017/typedarrays' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2017/typedarrays' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2017/date' from '/.src/__lib_node_modules_lookup_lib.es2017.date.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2017/date' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2017/date'", + "Scoped package detected, looking in 'typescript__lib-es2017/date'", + "Loading module '@typescript/lib-es2017/date' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2017/date' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2018/asynciterable' from '/.src/__lib_node_modules_lookup_lib.es2018.asynciterable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2018/asynciterable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018/asynciterable'", + "Scoped package detected, looking in 'typescript__lib-es2018/asynciterable'", + "Loading module '@typescript/lib-es2018/asynciterable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2018/asynciterable' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2018/asyncgenerator' from '/.src/__lib_node_modules_lookup_lib.es2018.asyncgenerator.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2018/asyncgenerator' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018/asyncgenerator'", + "Scoped package detected, looking in 'typescript__lib-es2018/asyncgenerator'", + "Loading module '@typescript/lib-es2018/asyncgenerator' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2018/asyncgenerator' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2018/promise' from '/.src/__lib_node_modules_lookup_lib.es2018.promise.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2018/promise' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018/promise'", + "Scoped package detected, looking in 'typescript__lib-es2018/promise'", + "Loading module '@typescript/lib-es2018/promise' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2018/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2018/regexp' from '/.src/__lib_node_modules_lookup_lib.es2018.regexp.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2018/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018/regexp'", + "Scoped package detected, looking in 'typescript__lib-es2018/regexp'", + "Loading module '@typescript/lib-es2018/regexp' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2018/regexp' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2018/intl' from '/.src/__lib_node_modules_lookup_lib.es2018.intl.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2018/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2018/intl'", + "Scoped package detected, looking in 'typescript__lib-es2018/intl'", + "Loading module '@typescript/lib-es2018/intl' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2018/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2019/array' from '/.src/__lib_node_modules_lookup_lib.es2019.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2019/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019/array'", + "Scoped package detected, looking in 'typescript__lib-es2019/array'", + "Loading module '@typescript/lib-es2019/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2019/array' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2019/object' from '/.src/__lib_node_modules_lookup_lib.es2019.object.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2019/object' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019/object'", + "Scoped package detected, looking in 'typescript__lib-es2019/object'", + "Loading module '@typescript/lib-es2019/object' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2019/object' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2019/string' from '/.src/__lib_node_modules_lookup_lib.es2019.string.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2019/string' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019/string'", + "Scoped package detected, looking in 'typescript__lib-es2019/string'", + "Loading module '@typescript/lib-es2019/string' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2019/string' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2019/symbol' from '/.src/__lib_node_modules_lookup_lib.es2019.symbol.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2019/symbol' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019/symbol'", + "Scoped package detected, looking in 'typescript__lib-es2019/symbol'", + "Loading module '@typescript/lib-es2019/symbol' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2019/symbol' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2019/intl' from '/.src/__lib_node_modules_lookup_lib.es2019.intl.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2019/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2019/intl'", + "Scoped package detected, looking in 'typescript__lib-es2019/intl'", + "Loading module '@typescript/lib-es2019/intl' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2019/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020/bigint' from '/.src/__lib_node_modules_lookup_lib.es2020.bigint.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020/bigint' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/bigint'", + "Scoped package detected, looking in 'typescript__lib-es2020/bigint'", + "Loading module '@typescript/lib-es2020/bigint' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020/bigint' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020/intl' from '/.src/__lib_node_modules_lookup_lib.es2020.intl.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/intl'", + "Scoped package detected, looking in 'typescript__lib-es2020/intl'", + "Loading module '@typescript/lib-es2020/intl' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020/date' from '/.src/__lib_node_modules_lookup_lib.es2020.date.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020/date' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/date'", + "Scoped package detected, looking in 'typescript__lib-es2020/date'", + "Loading module '@typescript/lib-es2020/date' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020/date' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020/number' from '/.src/__lib_node_modules_lookup_lib.es2020.number.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020/number' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/number'", + "Scoped package detected, looking in 'typescript__lib-es2020/number'", + "Loading module '@typescript/lib-es2020/number' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020/number' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020/promise' from '/.src/__lib_node_modules_lookup_lib.es2020.promise.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020/promise' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/promise'", + "Scoped package detected, looking in 'typescript__lib-es2020/promise'", + "Loading module '@typescript/lib-es2020/promise' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020/sharedmemory' from '/.src/__lib_node_modules_lookup_lib.es2020.sharedmemory.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020/sharedmemory' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/sharedmemory'", + "Scoped package detected, looking in 'typescript__lib-es2020/sharedmemory'", + "Loading module '@typescript/lib-es2020/sharedmemory' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020/sharedmemory' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020/string' from '/.src/__lib_node_modules_lookup_lib.es2020.string.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020/string' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/string'", + "Scoped package detected, looking in 'typescript__lib-es2020/string'", + "Loading module '@typescript/lib-es2020/string' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020/string' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2020/symbol-wellknown' from '/.src/__lib_node_modules_lookup_lib.es2020.symbol.wellknown.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2020/symbol-wellknown' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2020/symbol-wellknown'", + "Scoped package detected, looking in 'typescript__lib-es2020/symbol-wellknown'", + "Loading module '@typescript/lib-es2020/symbol-wellknown' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2020/symbol-wellknown' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2021/promise' from '/.src/__lib_node_modules_lookup_lib.es2021.promise.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2021/promise' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2021/promise'", + "Scoped package detected, looking in 'typescript__lib-es2021/promise'", + "Loading module '@typescript/lib-es2021/promise' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2021/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2021/string' from '/.src/__lib_node_modules_lookup_lib.es2021.string.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2021/string' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2021/string'", + "Scoped package detected, looking in 'typescript__lib-es2021/string'", + "Loading module '@typescript/lib-es2021/string' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2021/string' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2021/weakref' from '/.src/__lib_node_modules_lookup_lib.es2021.weakref.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2021/weakref' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2021/weakref'", + "Scoped package detected, looking in 'typescript__lib-es2021/weakref'", + "Loading module '@typescript/lib-es2021/weakref' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2021/weakref' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2021/intl' from '/.src/__lib_node_modules_lookup_lib.es2021.intl.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2021/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2021/intl'", + "Scoped package detected, looking in 'typescript__lib-es2021/intl'", + "Loading module '@typescript/lib-es2021/intl' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2021/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2022/array' from '/.src/__lib_node_modules_lookup_lib.es2022.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2022/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/array'", + "Scoped package detected, looking in 'typescript__lib-es2022/array'", + "Loading module '@typescript/lib-es2022/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2022/array' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2022/error' from '/.src/__lib_node_modules_lookup_lib.es2022.error.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2022/error' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/error'", + "Scoped package detected, looking in 'typescript__lib-es2022/error'", + "Loading module '@typescript/lib-es2022/error' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2022/error' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2022/intl' from '/.src/__lib_node_modules_lookup_lib.es2022.intl.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2022/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/intl'", + "Scoped package detected, looking in 'typescript__lib-es2022/intl'", + "Loading module '@typescript/lib-es2022/intl' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2022/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2022/object' from '/.src/__lib_node_modules_lookup_lib.es2022.object.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2022/object' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/object'", + "Scoped package detected, looking in 'typescript__lib-es2022/object'", + "Loading module '@typescript/lib-es2022/object' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2022/object' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2022/sharedmemory' from '/.src/__lib_node_modules_lookup_lib.es2022.sharedmemory.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2022/sharedmemory' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/sharedmemory'", + "Scoped package detected, looking in 'typescript__lib-es2022/sharedmemory'", + "Loading module '@typescript/lib-es2022/sharedmemory' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2022/sharedmemory' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2022/string' from '/.src/__lib_node_modules_lookup_lib.es2022.string.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2022/string' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/string'", + "Scoped package detected, looking in 'typescript__lib-es2022/string'", + "Loading module '@typescript/lib-es2022/string' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2022/string' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2022/regexp' from '/.src/__lib_node_modules_lookup_lib.es2022.regexp.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2022/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2022/regexp'", + "Scoped package detected, looking in 'typescript__lib-es2022/regexp'", + "Loading module '@typescript/lib-es2022/regexp' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2022/regexp' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2023/array' from '/.src/__lib_node_modules_lookup_lib.es2023.array.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2023/array' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2023/array'", + "Scoped package detected, looking in 'typescript__lib-es2023/array'", + "Loading module '@typescript/lib-es2023/array' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2023/array' was not resolved. ========", + "======== Resolving module '@typescript/lib-es2023/collection' from '/.src/__lib_node_modules_lookup_lib.es2023.collection.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es2023/collection' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es2023/collection'", + "Scoped package detected, looking in 'typescript__lib-es2023/collection'", + "Loading module '@typescript/lib-es2023/collection' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es2023/collection' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/intl' from '/.src/__lib_node_modules_lookup_lib.esnext.intl.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/intl' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/intl'", + "Scoped package detected, looking in 'typescript__lib-esnext/intl'", + "Loading module '@typescript/lib-esnext/intl' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/decorators' from '/.src/__lib_node_modules_lookup_lib.esnext.decorators.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/decorators'", + "Scoped package detected, looking in 'typescript__lib-esnext/decorators'", + "Loading module '@typescript/lib-esnext/decorators' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/decorators' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/disposable' from '/.src/__lib_node_modules_lookup_lib.esnext.disposable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/disposable' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/promise' from '/.src/__lib_node_modules_lookup_lib.esnext.promise.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/promise' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/promise'", + "Scoped package detected, looking in 'typescript__lib-esnext/promise'", + "Loading module '@typescript/lib-esnext/promise' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Scoped package detected, looking in 'typescript__lib-dom'", + "File '/node_modules/@types/typescript__lib-dom.d.ts' does not exist.", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom' was not resolved. ========", + "======== Resolving module '@typescript/lib-webworker/importscripts' from '/.src/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", + "======== Resolving module '@typescript/lib-scripthost' from '/.src/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "File '/node_modules/@types/typescript__lib-scripthost.d.ts' does not exist.", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-scripthost' was not resolved. ========", + "======== Resolving module '@typescript/lib-dom/iterable' from '/.src/__lib_node_modules_lookup_lib.dom.iterable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom/iterable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom/iterable'", + "Scoped package detected, looking in 'typescript__lib-dom/iterable'", + "Loading module '@typescript/lib-dom/iterable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom/iterable' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/cases/compiler/modulePreserve3.ts b/tests/cases/compiler/modulePreserve3.ts new file mode 100644 index 0000000000000..c15e1b1d4c313 --- /dev/null +++ b/tests/cases/compiler/modulePreserve3.ts @@ -0,0 +1,13 @@ +// @module: preserve +// @target: esnext +// @jsx: react-jsx +// @noEmit: true +// @noTypesAndSymbols: true +// @traceResolution: true + +// @Filename: /node_modules/@types/react/jsx-runtime.d.ts +export namespace JSX {} + +// @Filename: /index.tsx +export {}; +(
); From 186e329a0269f76537ba79b1b76167fd2d3d40f7 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 14 Dec 2023 15:43:40 -0800 Subject: [PATCH 12/31] Fix more TLA stuff --- src/compiler/checker.ts | 6 +- src/compiler/diagnosticMessages.json | 4 +- .../codefixes/fixModuleAndTargetOptions.ts | 4 +- .../awaitInNonAsyncFunction.errors.txt | 4 +- ...ngDeclarations.1(target=es2015).errors.txt | 60 +++++++++---------- ...UsingDeclarations.1(target=es5).errors.txt | 60 +++++++++---------- ...ngDeclarations.2(target=es2015).errors.txt | 4 +- ...UsingDeclarations.2(target=es5).errors.txt | 4 +- ...ngDeclarations.3(target=es2015).errors.txt | 4 +- ...UsingDeclarations.3(target=es5).errors.txt | 4 +- ...wJsTopLevelAwait(module=node16).errors.txt | 4 +- ...sTopLevelAwait(module=nodenext).errors.txt | 4 +- ...lesTopLevelAwait(module=node16).errors.txt | 4 +- ...sTopLevelAwait(module=nodenext).errors.txt | 4 +- .../parser.forAwait.es2018.errors.txt | 8 +-- ....1(module=es2022,target=es2015).errors.txt | 4 +- ....1(module=esnext,target=es2015).errors.txt | 4 +- ....1(module=system,target=es2015).errors.txt | 4 +- 18 files changed, 95 insertions(+), 95 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 61e08ab26726f..457a12e1019c4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -31797,7 +31797,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const jsxImportIndex = compilerOptions.importHelpers ? 1 : 0; const specifier = file?.imports[jsxImportIndex]; if (specifier) { - Debug.assert(nodeIsSynthesized(specifier) && specifier.text === runtimeImportSpecifier, `Expected sourceFile.imports[${jsxImportIndex}] to be the synthesized JSX runtime import`); + Debug.assert(nodeIsSynthesized(specifier) && specifier.text === runtimeImportSpecifier, `Expected sourceFile.imports[${jsxImportIndex}] to be the synthesized JSX runtime import`); } const mod = resolveExternalModule(specifier || location!, runtimeImportSpecifier, errorMessage, location!); const result = mod && mod !== unknownSymbol ? getMergedSymbol(resolveSymbol(mod)) : undefined; @@ -37470,7 +37470,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { default: span ??= getSpanOfTokenAtPosition(sourceFile, node.pos); const message = isAwaitExpression(node) ? Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher : - Diagnostics.Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher; + Diagnostics.Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher; diagnostics.add(createFileDiagnostic(sourceFile, span.start, span.length, message)); hasError = true; break; @@ -49707,7 +49707,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // fallthrough default: diagnostics.add( - createDiagnosticForNode(forInOrOfStatement.awaitModifier, Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher), + createDiagnosticForNode(forInOrOfStatement.awaitModifier, Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher), ); break; } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 920bd12ba38f9..2cb1e66644b98 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1424,7 +1424,7 @@ "category": "Error", "code": 1431 }, - "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": { + "Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.": { "category": "Error", "code": 1432 }, @@ -3683,7 +3683,7 @@ "category": "Error", "code": 2853 }, - "Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": { + "Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher.": { "category": "Error", "code": 2854 }, diff --git a/src/services/codefixes/fixModuleAndTargetOptions.ts b/src/services/codefixes/fixModuleAndTargetOptions.ts index 1974c7822e3f9..5ae7d53a89438 100644 --- a/src/services/codefixes/fixModuleAndTargetOptions.ts +++ b/src/services/codefixes/fixModuleAndTargetOptions.ts @@ -20,8 +20,8 @@ import { registerCodeFix({ errorCodes: [ Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher.code, - Diagnostics.Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, - Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + Diagnostics.Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher.code, + Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_nodenext_or_preserve_and_the_target_option_is_set_to_es2017_or_higher.code, ], getCodeActions: function getCodeActionsToFixModuleAndTarget(context) { const compilerOptions = context.program.getCompilerOptions(); diff --git a/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt b/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt index 47c0d21bb9f09..03d2b46a32010 100644 --- a/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt +++ b/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt @@ -12,7 +12,7 @@ awaitInNonAsyncFunction.ts(30,9): error TS1103: 'for await' loops are only allow awaitInNonAsyncFunction.ts(31,5): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. awaitInNonAsyncFunction.ts(34,7): error TS1103: 'for await' loops are only allowed within async functions and at the top levels of modules. awaitInNonAsyncFunction.ts(35,5): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -awaitInNonAsyncFunction.ts(39,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitInNonAsyncFunction.ts(39,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. @@ -97,7 +97,7 @@ awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions ar for await (const _ of []); ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. await null; ~~~~~ !!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.1(target=es2015).errors.txt b/tests/baselines/reference/awaitUsingDeclarations.1(target=es2015).errors.txt index 52470b2456f61..0ff7a8868b0a8 100644 --- a/tests/baselines/reference/awaitUsingDeclarations.1(target=es2015).errors.txt +++ b/tests/baselines/reference/awaitUsingDeclarations.1(target=es2015).errors.txt @@ -1,24 +1,24 @@ -awaitUsingDeclarations.1.ts(1,1): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(36,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(41,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(45,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(52,13): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(57,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(60,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(63,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(67,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(70,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(74,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(79,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(85,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(90,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(1,1): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(36,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(41,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(45,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(52,13): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(57,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(60,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(63,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(67,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(70,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(74,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(79,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(85,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(90,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ==== awaitUsingDeclarations.1.ts (15 errors) ==== await using d1 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. async function af() { await using d3 = { async [Symbol.asyncDispose]() {} }; @@ -55,20 +55,20 @@ awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' stateme { await using d19 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. } switch (Math.random()) { case 0: await using d20 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. break; case 1: await using d21 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. break; } @@ -77,48 +77,48 @@ awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' stateme case 0: await using d22 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. break; } try { await using d23 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. } catch { await using d24 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. } finally { await using d25 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. } if (true) { await using d26 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. } else { await using d27 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. } while (true) { await using d28 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. break; } do { await using d29 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. break; } while (true); @@ -126,20 +126,20 @@ awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' stateme for (;;) { await using d30 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. break; } for (const x in {}) { await using d31 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. } for (const x of []) { await using d32 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. } export {}; \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.1(target=es5).errors.txt b/tests/baselines/reference/awaitUsingDeclarations.1(target=es5).errors.txt index 52470b2456f61..0ff7a8868b0a8 100644 --- a/tests/baselines/reference/awaitUsingDeclarations.1(target=es5).errors.txt +++ b/tests/baselines/reference/awaitUsingDeclarations.1(target=es5).errors.txt @@ -1,24 +1,24 @@ -awaitUsingDeclarations.1.ts(1,1): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(36,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(41,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(45,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(52,13): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(57,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(60,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(63,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(67,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(70,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(74,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(79,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(85,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(90,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. -awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(1,1): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(36,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(41,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(45,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(52,13): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(57,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(60,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(63,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(67,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(70,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(74,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(79,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(85,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(90,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ==== awaitUsingDeclarations.1.ts (15 errors) ==== await using d1 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. async function af() { await using d3 = { async [Symbol.asyncDispose]() {} }; @@ -55,20 +55,20 @@ awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' stateme { await using d19 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. } switch (Math.random()) { case 0: await using d20 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. break; case 1: await using d21 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. break; } @@ -77,48 +77,48 @@ awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' stateme case 0: await using d22 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. break; } try { await using d23 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. } catch { await using d24 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. } finally { await using d25 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. } if (true) { await using d26 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. } else { await using d27 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. } while (true) { await using d28 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. break; } do { await using d29 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. break; } while (true); @@ -126,20 +126,20 @@ awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' stateme for (;;) { await using d30 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. break; } for (const x in {}) { await using d31 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. } for (const x of []) { await using d32 = { async [Symbol.asyncDispose]() {} }; ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. } export {}; \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.2(target=es2015).errors.txt b/tests/baselines/reference/awaitUsingDeclarations.2(target=es2015).errors.txt index b6d2d529f8b04..b04ba9319bdd8 100644 --- a/tests/baselines/reference/awaitUsingDeclarations.2(target=es2015).errors.txt +++ b/tests/baselines/reference/awaitUsingDeclarations.2(target=es2015).errors.txt @@ -1,11 +1,11 @@ -awaitUsingDeclarations.2.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.2.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ==== awaitUsingDeclarations.2.ts (1 errors) ==== { await using d1 = { async [Symbol.asyncDispose]() {} }, ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. d2 = { async [Symbol.asyncDispose]() {} }; } diff --git a/tests/baselines/reference/awaitUsingDeclarations.2(target=es5).errors.txt b/tests/baselines/reference/awaitUsingDeclarations.2(target=es5).errors.txt index b6d2d529f8b04..b04ba9319bdd8 100644 --- a/tests/baselines/reference/awaitUsingDeclarations.2(target=es5).errors.txt +++ b/tests/baselines/reference/awaitUsingDeclarations.2(target=es5).errors.txt @@ -1,11 +1,11 @@ -awaitUsingDeclarations.2.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.2.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ==== awaitUsingDeclarations.2.ts (1 errors) ==== { await using d1 = { async [Symbol.asyncDispose]() {} }, ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. d2 = { async [Symbol.asyncDispose]() {} }; } diff --git a/tests/baselines/reference/awaitUsingDeclarations.3(target=es2015).errors.txt b/tests/baselines/reference/awaitUsingDeclarations.3(target=es2015).errors.txt index 955e5041b7826..812d27fbe1adb 100644 --- a/tests/baselines/reference/awaitUsingDeclarations.3(target=es2015).errors.txt +++ b/tests/baselines/reference/awaitUsingDeclarations.3(target=es2015).errors.txt @@ -1,11 +1,11 @@ -awaitUsingDeclarations.3.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.3.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ==== awaitUsingDeclarations.3.ts (1 errors) ==== { await using d1 = { async [Symbol.asyncDispose]() {} }, ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. d2 = null, d3 = undefined, d4 = { [Symbol.dispose]() {} }; diff --git a/tests/baselines/reference/awaitUsingDeclarations.3(target=es5).errors.txt b/tests/baselines/reference/awaitUsingDeclarations.3(target=es5).errors.txt index 955e5041b7826..812d27fbe1adb 100644 --- a/tests/baselines/reference/awaitUsingDeclarations.3(target=es5).errors.txt +++ b/tests/baselines/reference/awaitUsingDeclarations.3(target=es5).errors.txt @@ -1,11 +1,11 @@ -awaitUsingDeclarations.3.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.3.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ==== awaitUsingDeclarations.3.ts (1 errors) ==== { await using d1 = { async [Symbol.asyncDispose]() {} }, ~~~~~ -!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. d2 = null, d3 = undefined, d4 = { [Symbol.dispose]() {} }; diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).errors.txt b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).errors.txt index a16e0fd308aac..6d1336b928ed6 100644 --- a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node16).errors.txt @@ -1,5 +1,5 @@ index.js(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. -index.js(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.js(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. subfolder/index.js(2,11): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. subfolder/index.js(4,5): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. @@ -21,7 +21,7 @@ subfolder/index.js(4,5): error TS1309: The current file is a CommonJS module and export {x}; for await (const y of []) {} ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ==== package.json (0 errors) ==== { "name": "package", diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt index a16e0fd308aac..6d1336b928ed6 100644 --- a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt @@ -1,5 +1,5 @@ index.js(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. -index.js(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.js(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. subfolder/index.js(2,11): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. subfolder/index.js(4,5): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. @@ -21,7 +21,7 @@ subfolder/index.js(4,5): error TS1309: The current file is a CommonJS module and export {x}; for await (const y of []) {} ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ==== package.json (0 errors) ==== { "name": "package", diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).errors.txt b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).errors.txt index a75cda3bf0997..3a11425d12393 100644 --- a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).errors.txt +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node16).errors.txt @@ -1,5 +1,5 @@ index.ts(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. -index.ts(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. subfolder/index.ts(2,11): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. subfolder/index.ts(4,5): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. @@ -21,7 +21,7 @@ subfolder/index.ts(4,5): error TS1309: The current file is a CommonJS module and export {x}; for await (const y of []) {} ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ==== package.json (0 errors) ==== { "name": "package", diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt index a75cda3bf0997..3a11425d12393 100644 --- a/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt @@ -1,5 +1,5 @@ index.ts(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. -index.ts(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +index.ts(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. subfolder/index.ts(2,11): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. subfolder/index.ts(4,5): error TS1309: The current file is a CommonJS module and cannot use 'await' at the top level. @@ -21,7 +21,7 @@ subfolder/index.ts(4,5): error TS1309: The current file is a CommonJS module and export {x}; for await (const y of []) {} ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ==== package.json (0 errors) ==== { "name": "package", diff --git a/tests/baselines/reference/parser.forAwait.es2018.errors.txt b/tests/baselines/reference/parser.forAwait.es2018.errors.txt index bc63fd1d1c1d8..93133c27df9ec 100644 --- a/tests/baselines/reference/parser.forAwait.es2018.errors.txt +++ b/tests/baselines/reference/parser.forAwait.es2018.errors.txt @@ -8,10 +8,10 @@ inFunctionDeclWithExprIsError.ts(3,9): error TS1103: 'for await' loops are only inGeneratorWithDeclIsError.ts(3,9): error TS1103: 'for await' loops are only allowed within async functions and at the top levels of modules. inGeneratorWithExprIsError.ts(3,9): error TS1103: 'for await' loops are only allowed within async functions and at the top levels of modules. topLevelWithDeclIsError.ts(1,5): error TS1431: 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. -topLevelWithDeclIsError.ts(1,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +topLevelWithDeclIsError.ts(1,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. topLevelWithDeclIsError.ts(1,23): error TS2304: Cannot find name 'y'. topLevelWithExprIsError.ts(1,5): error TS1431: 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. -topLevelWithExprIsError.ts(1,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +topLevelWithExprIsError.ts(1,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. topLevelWithExprIsError.ts(1,12): error TS2304: Cannot find name 'x'. topLevelWithExprIsError.ts(1,17): error TS2304: Cannot find name 'y'. @@ -21,7 +21,7 @@ topLevelWithExprIsError.ts(1,17): error TS2304: Cannot find name 'y'. ~~~~~ !!! error TS1431: 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~ !!! error TS2304: Cannot find name 'y'. } @@ -30,7 +30,7 @@ topLevelWithExprIsError.ts(1,17): error TS2304: Cannot find name 'y'. ~~~~~ !!! error TS1431: 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ~ !!! error TS2304: Cannot find name 'x'. ~ diff --git a/tests/baselines/reference/topLevelAwait.1(module=es2022,target=es2015).errors.txt b/tests/baselines/reference/topLevelAwait.1(module=es2022,target=es2015).errors.txt index ba4194e299ae2..2c3e91ab9f077 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=es2022,target=es2015).errors.txt +++ b/tests/baselines/reference/topLevelAwait.1(module=es2022,target=es2015).errors.txt @@ -1,6 +1,6 @@ index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. -other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ==== index.ts (2 errors) ==== @@ -84,7 +84,7 @@ other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when t for await (const item of arr) { ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. item; } \ No newline at end of file diff --git a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt index ba4194e299ae2..2c3e91ab9f077 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt +++ b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt @@ -1,6 +1,6 @@ index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. -other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ==== index.ts (2 errors) ==== @@ -84,7 +84,7 @@ other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when t for await (const item of arr) { ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. item; } \ No newline at end of file diff --git a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt index ba4194e299ae2..2c3e91ab9f077 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt +++ b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt @@ -1,6 +1,6 @@ index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. -other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. ==== index.ts (2 errors) ==== @@ -84,7 +84,7 @@ other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when t for await (const item of arr) { ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', 'nodenext', or 'preserve', and the 'target' option is set to 'es2017' or higher. item; } \ No newline at end of file From 4142f99b9515b05dbbbcb805c07c6269b0a70806 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 14 Dec 2023 10:12:16 -0800 Subject: [PATCH 13/31] REVERT ME: esnext -> preserve for RWC testing --- src/compiler/commandLineParser.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 359587bdeb669..e4c0f3e30fee5 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -549,11 +549,11 @@ export const moduleOptionDeclaration: CommandLineOptionOfCustomType = { amd: ModuleKind.AMD, system: ModuleKind.System, umd: ModuleKind.UMD, - es6: ModuleKind.ES2015, - es2015: ModuleKind.ES2015, - es2020: ModuleKind.ES2020, - es2022: ModuleKind.ES2022, - esnext: ModuleKind.ESNext, + es6: ModuleKind.Preserve, + es2015: ModuleKind.Preserve, + es2020: ModuleKind.Preserve, + es2022: ModuleKind.Preserve, + esnext: ModuleKind.Preserve, node16: ModuleKind.Node16, nodenext: ModuleKind.NodeNext, preserve: ModuleKind.Preserve, From 739e153d22d663b06b60f88a142443b1b2900158 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 14 Dec 2023 15:44:39 -0800 Subject: [PATCH 14/31] Revert "REVERT ME: esnext -> preserve for RWC testing" This reverts commit 4142f99b9515b05dbbbcb805c07c6269b0a70806. --- src/compiler/commandLineParser.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index e4c0f3e30fee5..359587bdeb669 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -549,11 +549,11 @@ export const moduleOptionDeclaration: CommandLineOptionOfCustomType = { amd: ModuleKind.AMD, system: ModuleKind.System, umd: ModuleKind.UMD, - es6: ModuleKind.Preserve, - es2015: ModuleKind.Preserve, - es2020: ModuleKind.Preserve, - es2022: ModuleKind.Preserve, - esnext: ModuleKind.Preserve, + es6: ModuleKind.ES2015, + es2015: ModuleKind.ES2015, + es2020: ModuleKind.ES2020, + es2022: ModuleKind.ES2022, + esnext: ModuleKind.ESNext, node16: ModuleKind.Node16, nodenext: ModuleKind.NodeNext, preserve: ModuleKind.Preserve, From 6799c538c3a36d55831f818ba8a408c98519601a Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 14 Dec 2023 16:42:27 -0800 Subject: [PATCH 15/31] Add big test --- .../reference/modulePreserve4.errors.txt | 125 ++++++++ .../reference/modulePreserve4.symbols | 228 +++++++++++++++ .../baselines/reference/modulePreserve4.types | 269 ++++++++++++++++++ .../cases/compiler/ambientRequireFunction.ts | 2 +- tests/cases/compiler/modulePreserve4.ts | 102 +++++++ .../bundler/bundlerConditionsExcludesNode.ts | 2 +- .../bundler/bundlerImportESM.ts | 2 +- .../bundler/bundlerNodeModules1.ts | 2 +- .../bundler/bundlerRelative1.ts | 2 +- .../bundler/bundlerSyntaxRestrictions.ts | 4 +- 10 files changed, 731 insertions(+), 7 deletions(-) create mode 100644 tests/baselines/reference/modulePreserve4.errors.txt create mode 100644 tests/baselines/reference/modulePreserve4.symbols create mode 100644 tests/baselines/reference/modulePreserve4.types create mode 100644 tests/cases/compiler/modulePreserve4.ts diff --git a/tests/baselines/reference/modulePreserve4.errors.txt b/tests/baselines/reference/modulePreserve4.errors.txt new file mode 100644 index 0000000000000..773605f0568c7 --- /dev/null +++ b/tests/baselines/reference/modulePreserve4.errors.txt @@ -0,0 +1,125 @@ +/a.js(2,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +/main1.ts(1,13): error TS2305: Module '"./a"' has no exported member 'y'. +/main1.ts(3,12): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +/main1.ts(15,4): error TS2339: Property 'default' does not exist on type '() => void'. +/main2.mts(1,13): error TS2305: Module '"./a"' has no exported member 'y'. +/main2.mts(4,4): error TS2339: Property 'default' does not exist on type 'typeof import("/a")'. +/main2.mts(5,12): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +/main3.cjs(1,13): error TS2305: Module '"./a"' has no exported member 'y'. +/main3.cjs(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. + + +==== /a.js (1 errors) ==== + export const x = 0; + module.exports.y = 0; // Error + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + +==== /b.ts (0 errors) ==== + export default 0; + +==== /c.ts (0 errors) ==== + export = { + default: function() {} + }; + +==== /d.ts (0 errors) ==== + export = function() {}; + +==== /e.mts (0 errors) ==== + export = 0; + +==== /f.cts (0 errors) ==== + export default 0; + +==== /g.js (0 errors) ==== + exports.default = 0; + +==== /main1.ts (3 errors) ==== + import { x, y } from "./a"; // No y + ~ +!!! error TS2305: Module '"./a"' has no exported member 'y'. + import a1 = require("./a"); // { x: 0 } + const a2 = require("./a"); // Error in TS + ~~~~~~~ +!!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + + import b1 from "./b"; // 0 + import b2 = require("./b"); // { default: 0 } + b2.default; + + import c1 from "./c"; // { default: [Function: default] } + import c2 = require("./c"); // { default: [Function: default] } + c2.default; + import d1 from "./d"; // [Function: default] + import d2 = require("./d"); // [Function: default] + d2(); + d2.default(); // Error + ~~~~~~~ +!!! error TS2339: Property 'default' does not exist on type '() => void'. + import e1 from "./e.mjs"; // 0 + import e2 = require("./e.mjs"); // 0 + import f1 from "./f.cjs"; // 0 + import f2 = require("./f.cjs"); // { default: 0 } + f2.default; + + import g1 from "./g"; // { default: 0 } + g1.default; + import g2 = require("./g"); // { default: 0 } + g2.default; + +==== /main2.mts (3 errors) ==== + import { x, y } from "./a"; // No y + ~ +!!! error TS2305: Module '"./a"' has no exported member 'y'. + import a1 = require("./a"); // { x: 0 } + a1.x; + a1.default.x; // Arguably should exist but doesn't + ~~~~~~~ +!!! error TS2339: Property 'default' does not exist on type 'typeof import("/a")'. + const a2 = require("./a"); // Error in TS + ~~~~~~~ +!!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + + import b1 from "./b"; // 0 + import b2 = require("./b"); // { default: 0 } + + import c1 from "./c"; // { default: [Function: default] } + import c2 = require("./c"); // { default: [Function: default] } + import d1 from "./d"; // [Function: default] + import d2 = require("./d"); // [Function: default] + import e1 from "./e.mjs"; // 0 + import e2 = require("./e.mjs"); // 0 + import f1 from "./f.cjs"; // 0 + import f2 = require("./f.cjs"); // { default: 0 } + + import g1 from "./g"; // { default: 0 } + import g2 = require("./g"); // { default: 0 } + +==== /main3.cjs (2 errors) ==== + import { x, y } from "./a"; // No y + ~ +!!! error TS2305: Module '"./a"' has no exported member 'y'. + import a1 = require("./a"); // Error in JS + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + const a2 = require("./a"); // { x: 0 } + + import b1 from "./b"; // 0 + const b2 = require("./b"); // { default: 0 } + + import c1 from "./c"; // { default: [Function: default] } + const c2 = require("./c"); // { default: [Function: default] } + import d1 from "./d"; // [Function: default] + const d2 = require("./d"); // [Function: default] + import e1 from "./e.mjs"; // 0 + const e2 = require("./e.mjs"); // 0 + import f1 from "./f.cjs"; // 0 + const f2 = require("./f.cjs"); // { default: 0 } + + import g1 from "./g"; // { default: 0 } + const g2 = require("./g"); // { default: 0 } + +==== /dummy.ts (0 errors) ==== + export {}; // Silly test harness + \ No newline at end of file diff --git a/tests/baselines/reference/modulePreserve4.symbols b/tests/baselines/reference/modulePreserve4.symbols new file mode 100644 index 0000000000000..35de69066cf48 --- /dev/null +++ b/tests/baselines/reference/modulePreserve4.symbols @@ -0,0 +1,228 @@ +//// [tests/cases/compiler/modulePreserve4.ts] //// + +=== /a.js === +export const x = 0; +>x : Symbol(x, Decl(a.js, 0, 12)) + +module.exports.y = 0; // Error + +=== /b.ts === + +export default 0; + +=== /c.ts === +export = { + default: function() {} +>default : Symbol(default, Decl(c.ts, 0, 10)) + +}; + +=== /d.ts === + +export = function() {}; + +=== /e.mts === + +export = 0; + +=== /f.cts === + +export default 0; + +=== /g.js === +exports.default = 0; +>exports.default : Symbol(default, Decl(g.js, 0, 0)) +>exports : Symbol(default, Decl(g.js, 0, 0)) +>default : Symbol(default, Decl(g.js, 0, 0)) + +=== /main1.ts === +import { x, y } from "./a"; // No y +>x : Symbol(x, Decl(main1.ts, 0, 8)) +>y : Symbol(y, Decl(main1.ts, 0, 11)) + +import a1 = require("./a"); // { x: 0 } +>a1 : Symbol(a1, Decl(main1.ts, 0, 27)) + +const a2 = require("./a"); // Error in TS +>a2 : Symbol(a2, Decl(main1.ts, 2, 5)) + +import b1 from "./b"; // 0 +>b1 : Symbol(b1, Decl(main1.ts, 4, 6)) + +import b2 = require("./b"); // { default: 0 } +>b2 : Symbol(b2, Decl(main1.ts, 4, 21)) + +b2.default; +>b2.default : Symbol(b1, Decl(b.ts, 0, 0)) +>b2 : Symbol(b2, Decl(main1.ts, 4, 21)) +>default : Symbol(b1, Decl(b.ts, 0, 0)) + +import c1 from "./c"; // { default: [Function: default] } +>c1 : Symbol(c1, Decl(main1.ts, 8, 6)) + +import c2 = require("./c"); // { default: [Function: default] } +>c2 : Symbol(c2, Decl(main1.ts, 8, 21)) + +c2.default; +>c2.default : Symbol(default, Decl(c.ts, 0, 10)) +>c2 : Symbol(c2, Decl(main1.ts, 8, 21)) +>default : Symbol(default, Decl(c.ts, 0, 10)) + +import d1 from "./d"; // [Function: default] +>d1 : Symbol(d1, Decl(main1.ts, 11, 6)) + +import d2 = require("./d"); // [Function: default] +>d2 : Symbol(d2, Decl(main1.ts, 11, 21)) + +d2(); +>d2 : Symbol(d2, Decl(main1.ts, 11, 21)) + +d2.default(); // Error +>d2 : Symbol(d2, Decl(main1.ts, 11, 21)) + +import e1 from "./e.mjs"; // 0 +>e1 : Symbol(e1, Decl(main1.ts, 15, 6)) + +import e2 = require("./e.mjs"); // 0 +>e2 : Symbol(e2, Decl(main1.ts, 15, 25)) + +import f1 from "./f.cjs"; // 0 +>f1 : Symbol(f1, Decl(main1.ts, 17, 6)) + +import f2 = require("./f.cjs"); // { default: 0 } +>f2 : Symbol(f2, Decl(main1.ts, 17, 25)) + +f2.default; +>f2.default : Symbol(f1, Decl(f.cts, 0, 0)) +>f2 : Symbol(f2, Decl(main1.ts, 17, 25)) +>default : Symbol(f1, Decl(f.cts, 0, 0)) + +import g1 from "./g"; // { default: 0 } +>g1 : Symbol(g1, Decl(main1.ts, 21, 6)) + +g1.default; +>g1.default : Symbol(g1.default, Decl(g.js, 0, 0)) +>g1 : Symbol(g1, Decl(main1.ts, 21, 6)) +>default : Symbol(g1.default, Decl(g.js, 0, 0)) + +import g2 = require("./g"); // { default: 0 } +>g2 : Symbol(g2, Decl(main1.ts, 22, 11)) + +g2.default; +>g2.default : Symbol(g1.default, Decl(g.js, 0, 0)) +>g2 : Symbol(g2, Decl(main1.ts, 22, 11)) +>default : Symbol(g1.default, Decl(g.js, 0, 0)) + +=== /main2.mts === +import { x, y } from "./a"; // No y +>x : Symbol(x, Decl(main2.mts, 0, 8)) +>y : Symbol(y, Decl(main2.mts, 0, 11)) + +import a1 = require("./a"); // { x: 0 } +>a1 : Symbol(a1, Decl(main2.mts, 0, 27)) + +a1.x; +>a1.x : Symbol(x, Decl(a.js, 0, 12)) +>a1 : Symbol(a1, Decl(main2.mts, 0, 27)) +>x : Symbol(x, Decl(a.js, 0, 12)) + +a1.default.x; // Arguably should exist but doesn't +>a1 : Symbol(a1, Decl(main2.mts, 0, 27)) + +const a2 = require("./a"); // Error in TS +>a2 : Symbol(a2, Decl(main2.mts, 4, 5)) + +import b1 from "./b"; // 0 +>b1 : Symbol(b1, Decl(main2.mts, 6, 6)) + +import b2 = require("./b"); // { default: 0 } +>b2 : Symbol(b2, Decl(main2.mts, 6, 21)) + +import c1 from "./c"; // { default: [Function: default] } +>c1 : Symbol(c1, Decl(main2.mts, 9, 6)) + +import c2 = require("./c"); // { default: [Function: default] } +>c2 : Symbol(c2, Decl(main2.mts, 9, 21)) + +import d1 from "./d"; // [Function: default] +>d1 : Symbol(d1, Decl(main2.mts, 11, 6)) + +import d2 = require("./d"); // [Function: default] +>d2 : Symbol(d2, Decl(main2.mts, 11, 21)) + +import e1 from "./e.mjs"; // 0 +>e1 : Symbol(e1, Decl(main2.mts, 13, 6)) + +import e2 = require("./e.mjs"); // 0 +>e2 : Symbol(e2, Decl(main2.mts, 13, 25)) + +import f1 from "./f.cjs"; // 0 +>f1 : Symbol(f1, Decl(main2.mts, 15, 6)) + +import f2 = require("./f.cjs"); // { default: 0 } +>f2 : Symbol(f2, Decl(main2.mts, 15, 25)) + +import g1 from "./g"; // { default: 0 } +>g1 : Symbol(g1, Decl(main2.mts, 18, 6)) + +import g2 = require("./g"); // { default: 0 } +>g2 : Symbol(g2, Decl(main2.mts, 18, 21)) + +=== /main3.cjs === +import { x, y } from "./a"; // No y +>x : Symbol(x, Decl(main3.cjs, 0, 8)) +>y : Symbol(y, Decl(main3.cjs, 0, 11)) + +import a1 = require("./a"); // Error in JS +>a1 : Symbol(a1, Decl(main3.cjs, 0, 27)) + +const a2 = require("./a"); // { x: 0 } +>a2 : Symbol(a2, Decl(main3.cjs, 2, 5)) +>require : Symbol(require) + +import b1 from "./b"; // 0 +>b1 : Symbol(b1, Decl(main3.cjs, 4, 6)) + +const b2 = require("./b"); // { default: 0 } +>b2 : Symbol(b2, Decl(main3.cjs, 5, 5)) +>require : Symbol(require) + +import c1 from "./c"; // { default: [Function: default] } +>c1 : Symbol(c1, Decl(main3.cjs, 7, 6)) + +const c2 = require("./c"); // { default: [Function: default] } +>c2 : Symbol(c2, Decl(main3.cjs, 8, 5)) +>require : Symbol(require) + +import d1 from "./d"; // [Function: default] +>d1 : Symbol(d1, Decl(main3.cjs, 9, 6)) + +const d2 = require("./d"); // [Function: default] +>d2 : Symbol(d2, Decl(main3.cjs, 10, 5)) +>require : Symbol(require) + +import e1 from "./e.mjs"; // 0 +>e1 : Symbol(e1, Decl(main3.cjs, 11, 6)) + +const e2 = require("./e.mjs"); // 0 +>e2 : Symbol(e2, Decl(main3.cjs, 12, 5)) +>require : Symbol(require) + +import f1 from "./f.cjs"; // 0 +>f1 : Symbol(f1, Decl(main3.cjs, 13, 6)) + +const f2 = require("./f.cjs"); // { default: 0 } +>f2 : Symbol(f2, Decl(main3.cjs, 14, 5)) +>require : Symbol(require) + +import g1 from "./g"; // { default: 0 } +>g1 : Symbol(g1, Decl(main3.cjs, 16, 6)) + +const g2 = require("./g"); // { default: 0 } +>g2 : Symbol(g2, Decl(main3.cjs, 17, 5)) +>require : Symbol(require) + +=== /dummy.ts === + +export {}; // Silly test harness + diff --git a/tests/baselines/reference/modulePreserve4.types b/tests/baselines/reference/modulePreserve4.types new file mode 100644 index 0000000000000..4a04b9ba621d1 --- /dev/null +++ b/tests/baselines/reference/modulePreserve4.types @@ -0,0 +1,269 @@ +//// [tests/cases/compiler/modulePreserve4.ts] //// + +=== /a.js === +export const x = 0; +>x : 0 +>0 : 0 + +module.exports.y = 0; // Error +>module.exports.y = 0 : 0 +>module.exports.y : any +>module.exports : any +>module : any +>exports : any +>y : any +>0 : 0 + +=== /b.ts === + +export default 0; + +=== /c.ts === +export = { +>{ default: function() {}} : { default: () => void; } + + default: function() {} +>default : () => void +>function() {} : () => void + +}; + +=== /d.ts === +export = function() {}; +>function() {} : () => void + +=== /e.mts === + +export = 0; + +=== /f.cts === + +export default 0; + +=== /g.js === +exports.default = 0; +>exports.default = 0 : 0 +>exports.default : 0 +>exports : typeof import("/g") +>default : 0 +>0 : 0 + +=== /main1.ts === +import { x, y } from "./a"; // No y +>x : 0 +>y : any + +import a1 = require("./a"); // { x: 0 } +>a1 : typeof a1 + +const a2 = require("./a"); // Error in TS +>a2 : any +>require("./a") : any +>require : any +>"./a" : "./a" + +import b1 from "./b"; // 0 +>b1 : 0 + +import b2 = require("./b"); // { default: 0 } +>b2 : typeof b2 + +b2.default; +>b2.default : 0 +>b2 : typeof b2 +>default : 0 + +import c1 from "./c"; // { default: [Function: default] } +>c1 : { default: () => void; } + +import c2 = require("./c"); // { default: [Function: default] } +>c2 : { default: () => void; } + +c2.default; +>c2.default : () => void +>c2 : { default: () => void; } +>default : () => void + +import d1 from "./d"; // [Function: default] +>d1 : () => void + +import d2 = require("./d"); // [Function: default] +>d2 : () => void + +d2(); +>d2() : void +>d2 : () => void + +d2.default(); // Error +>d2.default() : any +>d2.default : any +>d2 : () => void +>default : any + +import e1 from "./e.mjs"; // 0 +>e1 : 0 + +import e2 = require("./e.mjs"); // 0 +>e2 : 0 + +import f1 from "./f.cjs"; // 0 +>f1 : 0 + +import f2 = require("./f.cjs"); // { default: 0 } +>f2 : typeof f2 + +f2.default; +>f2.default : 0 +>f2 : typeof f2 +>default : 0 + +import g1 from "./g"; // { default: 0 } +>g1 : typeof g1 + +g1.default; +>g1.default : 0 +>g1 : typeof g1 +>default : 0 + +import g2 = require("./g"); // { default: 0 } +>g2 : typeof g1 + +g2.default; +>g2.default : 0 +>g2 : typeof g1 +>default : 0 + +=== /main2.mts === +import { x, y } from "./a"; // No y +>x : 0 +>y : any + +import a1 = require("./a"); // { x: 0 } +>a1 : typeof a1 + +a1.x; +>a1.x : 0 +>a1 : typeof a1 +>x : 0 + +a1.default.x; // Arguably should exist but doesn't +>a1.default.x : any +>a1.default : any +>a1 : typeof a1 +>default : any +>x : any + +const a2 = require("./a"); // Error in TS +>a2 : any +>require("./a") : any +>require : any +>"./a" : "./a" + +import b1 from "./b"; // 0 +>b1 : 0 + +import b2 = require("./b"); // { default: 0 } +>b2 : typeof b2 + +import c1 from "./c"; // { default: [Function: default] } +>c1 : { default: () => void; } + +import c2 = require("./c"); // { default: [Function: default] } +>c2 : { default: () => void; } + +import d1 from "./d"; // [Function: default] +>d1 : () => void + +import d2 = require("./d"); // [Function: default] +>d2 : () => void + +import e1 from "./e.mjs"; // 0 +>e1 : 0 + +import e2 = require("./e.mjs"); // 0 +>e2 : 0 + +import f1 from "./f.cjs"; // 0 +>f1 : 0 + +import f2 = require("./f.cjs"); // { default: 0 } +>f2 : typeof f2 + +import g1 from "./g"; // { default: 0 } +>g1 : typeof g1 + +import g2 = require("./g"); // { default: 0 } +>g2 : typeof g1 + +=== /main3.cjs === +import { x, y } from "./a"; // No y +>x : 0 +>y : any + +import a1 = require("./a"); // Error in JS +>a1 : typeof a1 + +const a2 = require("./a"); // { x: 0 } +>a2 : typeof a1 +>require("./a") : typeof a1 +>require : any +>"./a" : "./a" + +import b1 from "./b"; // 0 +>b1 : 0 + +const b2 = require("./b"); // { default: 0 } +>b2 : typeof b2 +>require("./b") : typeof b2 +>require : any +>"./b" : "./b" + +import c1 from "./c"; // { default: [Function: default] } +>c1 : { default: () => void; } + +const c2 = require("./c"); // { default: [Function: default] } +>c2 : { default: () => void; } +>require("./c") : { default: () => void; } +>require : any +>"./c" : "./c" + +import d1 from "./d"; // [Function: default] +>d1 : () => void + +const d2 = require("./d"); // [Function: default] +>d2 : () => void +>require("./d") : () => void +>require : any +>"./d" : "./d" + +import e1 from "./e.mjs"; // 0 +>e1 : 0 + +const e2 = require("./e.mjs"); // 0 +>e2 : 0 +>require("./e.mjs") : 0 +>require : any +>"./e.mjs" : "./e.mjs" + +import f1 from "./f.cjs"; // 0 +>f1 : 0 + +const f2 = require("./f.cjs"); // { default: 0 } +>f2 : typeof f2 +>require("./f.cjs") : typeof f2 +>require : any +>"./f.cjs" : "./f.cjs" + +import g1 from "./g"; // { default: 0 } +>g1 : typeof g1 + +const g2 = require("./g"); // { default: 0 } +>g2 : typeof g1 +>require("./g") : typeof g1 +>require : any +>"./g" : "./g" + +=== /dummy.ts === + +export {}; // Silly test harness + diff --git a/tests/cases/compiler/ambientRequireFunction.ts b/tests/cases/compiler/ambientRequireFunction.ts index ce9019e00bcf7..a5428c2ea9474 100644 --- a/tests/cases/compiler/ambientRequireFunction.ts +++ b/tests/cases/compiler/ambientRequireFunction.ts @@ -1,4 +1,4 @@ -// @module: commonjs +// @module: commonjs, preserve // @allowJs: true // @outDir: ./out/ diff --git a/tests/cases/compiler/modulePreserve4.ts b/tests/cases/compiler/modulePreserve4.ts new file mode 100644 index 0000000000000..6e5c0e6385047 --- /dev/null +++ b/tests/cases/compiler/modulePreserve4.ts @@ -0,0 +1,102 @@ +// @module: preserve +// @target: esnext +// @verbatimModuleSyntax: true +// @checkJs: true +// @noEmit: true +// @strict: true + +// @Filename: /a.js +export const x = 0; +module.exports.y = 0; // Error + +// @Filename: /b.ts +export default 0; + +// @Filename: /c.ts +export = { + default: function() {} +}; + +// @Filename: /d.ts +export = function() {}; + +// @Filename: /e.mts +export = 0; + +// @Filename: /f.cts +export default 0; + +// @Filename: /g.js +exports.default = 0; + +// @Filename: /main1.ts +import { x, y } from "./a"; // No y +import a1 = require("./a"); // { x: 0 } +const a2 = require("./a"); // Error in TS + +import b1 from "./b"; // 0 +import b2 = require("./b"); // { default: 0 } +b2.default; + +import c1 from "./c"; // { default: [Function: default] } +import c2 = require("./c"); // { default: [Function: default] } +c2.default; +import d1 from "./d"; // [Function: default] +import d2 = require("./d"); // [Function: default] +d2(); +d2.default(); // Error +import e1 from "./e.mjs"; // 0 +import e2 = require("./e.mjs"); // 0 +import f1 from "./f.cjs"; // 0 +import f2 = require("./f.cjs"); // { default: 0 } +f2.default; + +import g1 from "./g"; // { default: 0 } +g1.default; +import g2 = require("./g"); // { default: 0 } +g2.default; + +// @Filename: /main2.mts +import { x, y } from "./a"; // No y +import a1 = require("./a"); // { x: 0 } +a1.x; +a1.default.x; // Arguably should exist but doesn't +const a2 = require("./a"); // Error in TS + +import b1 from "./b"; // 0 +import b2 = require("./b"); // { default: 0 } + +import c1 from "./c"; // { default: [Function: default] } +import c2 = require("./c"); // { default: [Function: default] } +import d1 from "./d"; // [Function: default] +import d2 = require("./d"); // [Function: default] +import e1 from "./e.mjs"; // 0 +import e2 = require("./e.mjs"); // 0 +import f1 from "./f.cjs"; // 0 +import f2 = require("./f.cjs"); // { default: 0 } + +import g1 from "./g"; // { default: 0 } +import g2 = require("./g"); // { default: 0 } + +// @Filename: /main3.cjs +import { x, y } from "./a"; // No y +import a1 = require("./a"); // Error in JS +const a2 = require("./a"); // { x: 0 } + +import b1 from "./b"; // 0 +const b2 = require("./b"); // { default: 0 } + +import c1 from "./c"; // { default: [Function: default] } +const c2 = require("./c"); // { default: [Function: default] } +import d1 from "./d"; // [Function: default] +const d2 = require("./d"); // [Function: default] +import e1 from "./e.mjs"; // 0 +const e2 = require("./e.mjs"); // 0 +import f1 from "./f.cjs"; // 0 +const f2 = require("./f.cjs"); // { default: 0 } + +import g1 from "./g"; // { default: 0 } +const g2 = require("./g"); // { default: 0 } + +// @Filename: /dummy.ts +export {}; // Silly test harness diff --git a/tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts index 3ab230e98dd81..ab7a430db0955 100644 --- a/tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts @@ -1,5 +1,5 @@ // @moduleResolution: bundler -// @module: esnext +// @module: esnext, preserve // @traceResolution: true // @Filename: /node_modules/conditions/package.json diff --git a/tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts index 7fbcd0f6f7a85..105f310960d0f 100644 --- a/tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts @@ -1,5 +1,5 @@ // @moduleResolution: bundler -// @module: esnext +// @module: esnext, preserve // @Filename: /esm.mts export const esm = 0; diff --git a/tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts index 2c71e97c08fdc..0e970d1319236 100644 --- a/tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts @@ -1,5 +1,5 @@ // @moduleResolution: bundler -// @module: esnext +// @module: esnext, preserve // @traceResolution: true // @Filename: /node_modules/dual/package.json diff --git a/tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts index 667fe14366d11..9bd6eaa69d138 100644 --- a/tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts @@ -1,5 +1,5 @@ // @moduleResolution: bundler -// @module: esnext +// @module: esnext, preserve // @traceResolution: true // @Filename: /dir/index.ts diff --git a/tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts index 1c8f832030284..c80cf1f676ba0 100644 --- a/tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts @@ -1,5 +1,5 @@ // @moduleResolution: bundler -// @module: esnext +// @module: esnext, preserve // @checkJs: true // @allowJs: true // @outDir: out @@ -27,7 +27,7 @@ _.a; // any // @Filename: /main.ts import {} from "./a"; -import _ = require("./a"); // Error +import _ = require("./a"); // Error in esnext export = {}; // Error export {}; From cf07180e42c3c230f3480a9252891e98c419bb2b Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 14 Dec 2023 17:00:38 -0800 Subject: [PATCH 16/31] Add coverage from existing tests --- diff.bash | 36 ++++ ...ambientRequireFunction(module=commonjs).js | 19 ++ ...ntRequireFunction(module=commonjs).symbols | 29 ++++ ...ientRequireFunction(module=commonjs).types | 32 ++++ ...ambientRequireFunction(module=preserve).js | 19 ++ ...ntRequireFunction(module=preserve).symbols | 28 +++ ...ientRequireFunction(module=preserve).types | 32 ++++ ...ionsExcludesNode(module=esnext).errors.txt | 44 +++++ ...erConditionsExcludesNode(module=esnext).js | 35 ++++ ...ditionsExcludesNode(module=esnext).symbols | 14 ++ ...ionsExcludesNode(module=esnext).trace.json | 93 ++++++++++ ...onditionsExcludesNode(module=esnext).types | 14 ++ ...nsExcludesNode(module=preserve).errors.txt | 44 +++++ ...ConditionsExcludesNode(module=preserve).js | 35 ++++ ...tionsExcludesNode(module=preserve).symbols | 14 ++ ...nsExcludesNode(module=preserve).trace.json | 93 ++++++++++ ...ditionsExcludesNode(module=preserve).types | 14 ++ .../bundlerImportESM(module=esnext).js | 21 +++ .../bundlerImportESM(module=esnext).symbols | 14 ++ .../bundlerImportESM(module=esnext).types | 15 ++ .../bundlerImportESM(module=preserve).js | 21 +++ .../bundlerImportESM(module=preserve).symbols | 14 ++ .../bundlerImportESM(module=preserve).types | 15 ++ ...dlerNodeModules1(module=esnext).errors.txt | 59 +++++++ .../bundlerNodeModules1(module=esnext).js | 45 +++++ ...bundlerNodeModules1(module=esnext).symbols | 25 +++ ...dlerNodeModules1(module=esnext).trace.json | 98 +++++++++++ .../bundlerNodeModules1(module=esnext).types | 25 +++ ...erNodeModules1(module=preserve).errors.txt | 59 +++++++ .../bundlerNodeModules1(module=preserve).js | 45 +++++ ...ndlerNodeModules1(module=preserve).symbols | 25 +++ ...erNodeModules1(module=preserve).trace.json | 98 +++++++++++ ...bundlerNodeModules1(module=preserve).types | 25 +++ ...bundlerRelative1(module=esnext).errors.txt | 39 +++++ .../bundlerRelative1(module=esnext).js | 40 +++++ .../bundlerRelative1(module=esnext).symbols | 49 ++++++ ...bundlerRelative1(module=esnext).trace.json | 162 ++++++++++++++++++ .../bundlerRelative1(module=esnext).types | 51 ++++++ ...ndlerRelative1(module=preserve).errors.txt | 39 +++++ .../bundlerRelative1(module=preserve).js | 40 +++++ .../bundlerRelative1(module=preserve).symbols | 49 ++++++ ...ndlerRelative1(module=preserve).trace.json | 162 ++++++++++++++++++ .../bundlerRelative1(module=preserve).types | 51 ++++++ ...ntaxRestrictions(module=esnext).errors.txt | 43 +++++ ...undlerSyntaxRestrictions(module=esnext).js | 42 +++++ ...rSyntaxRestrictions(module=esnext).symbols | 58 +++++++ ...lerSyntaxRestrictions(module=esnext).types | 64 +++++++ ...axRestrictions(module=preserve).errors.txt | 37 ++++ ...dlerSyntaxRestrictions(module=preserve).js | 43 +++++ ...yntaxRestrictions(module=preserve).symbols | 58 +++++++ ...rSyntaxRestrictions(module=preserve).types | 64 +++++++ 51 files changed, 2290 insertions(+) create mode 100755 diff.bash create mode 100644 tests/baselines/reference/ambientRequireFunction(module=commonjs).js create mode 100644 tests/baselines/reference/ambientRequireFunction(module=commonjs).symbols create mode 100644 tests/baselines/reference/ambientRequireFunction(module=commonjs).types create mode 100644 tests/baselines/reference/ambientRequireFunction(module=preserve).js create mode 100644 tests/baselines/reference/ambientRequireFunction(module=preserve).symbols create mode 100644 tests/baselines/reference/ambientRequireFunction(module=preserve).types create mode 100644 tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).errors.txt create mode 100644 tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).js create mode 100644 tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).symbols create mode 100644 tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).trace.json create mode 100644 tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).types create mode 100644 tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).errors.txt create mode 100644 tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).js create mode 100644 tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).symbols create mode 100644 tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).trace.json create mode 100644 tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).types create mode 100644 tests/baselines/reference/bundlerImportESM(module=esnext).js create mode 100644 tests/baselines/reference/bundlerImportESM(module=esnext).symbols create mode 100644 tests/baselines/reference/bundlerImportESM(module=esnext).types create mode 100644 tests/baselines/reference/bundlerImportESM(module=preserve).js create mode 100644 tests/baselines/reference/bundlerImportESM(module=preserve).symbols create mode 100644 tests/baselines/reference/bundlerImportESM(module=preserve).types create mode 100644 tests/baselines/reference/bundlerNodeModules1(module=esnext).errors.txt create mode 100644 tests/baselines/reference/bundlerNodeModules1(module=esnext).js create mode 100644 tests/baselines/reference/bundlerNodeModules1(module=esnext).symbols create mode 100644 tests/baselines/reference/bundlerNodeModules1(module=esnext).trace.json create mode 100644 tests/baselines/reference/bundlerNodeModules1(module=esnext).types create mode 100644 tests/baselines/reference/bundlerNodeModules1(module=preserve).errors.txt create mode 100644 tests/baselines/reference/bundlerNodeModules1(module=preserve).js create mode 100644 tests/baselines/reference/bundlerNodeModules1(module=preserve).symbols create mode 100644 tests/baselines/reference/bundlerNodeModules1(module=preserve).trace.json create mode 100644 tests/baselines/reference/bundlerNodeModules1(module=preserve).types create mode 100644 tests/baselines/reference/bundlerRelative1(module=esnext).errors.txt create mode 100644 tests/baselines/reference/bundlerRelative1(module=esnext).js create mode 100644 tests/baselines/reference/bundlerRelative1(module=esnext).symbols create mode 100644 tests/baselines/reference/bundlerRelative1(module=esnext).trace.json create mode 100644 tests/baselines/reference/bundlerRelative1(module=esnext).types create mode 100644 tests/baselines/reference/bundlerRelative1(module=preserve).errors.txt create mode 100644 tests/baselines/reference/bundlerRelative1(module=preserve).js create mode 100644 tests/baselines/reference/bundlerRelative1(module=preserve).symbols create mode 100644 tests/baselines/reference/bundlerRelative1(module=preserve).trace.json create mode 100644 tests/baselines/reference/bundlerRelative1(module=preserve).types create mode 100644 tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).errors.txt create mode 100644 tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).js create mode 100644 tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).symbols create mode 100644 tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).types create mode 100644 tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).errors.txt create mode 100644 tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).js create mode 100644 tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).symbols create mode 100644 tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).types diff --git a/diff.bash b/diff.bash new file mode 100755 index 0000000000000..b2bc2ad506659 --- /dev/null +++ b/diff.bash @@ -0,0 +1,36 @@ +#!/bin/zsh + +# Directory containing the test files +directory="./tests/baselines/local" + +# Associative array to hold base names, extensions, and their corresponding files +typeset -A tests + +# Loop over files in the directory with different extensions +for ext in js symbols types errors.txt trace.json; do + for file in "$directory"/*\(module=*\).$ext; do + # Extract the base test name by removing the parameter and extension parts + base_name=${file%%\(module=*} + + # Add the file to the array for this base name and extension + tests[$base_name,$ext]+="$file " + done +done + +# Loop over the test groups +for key in ${(k)tests}; do + # Split the key into base name and extension + base_name=${key%,*} + ext=${key#*,} + + # Get all files for this test and extension + files=(${(s: :)tests[$key]}) + + # Compare each file with each other + for (( i=1; i<=$#files; i++ )); do + for (( j=i+1; j<=$#files; j++ )); do + echo "Diffing $files[i] and $files[j]" + diff "$files[i]" "$files[j]" + done + done +done diff --git a/tests/baselines/reference/ambientRequireFunction(module=commonjs).js b/tests/baselines/reference/ambientRequireFunction(module=commonjs).js new file mode 100644 index 0000000000000..348ee0a144389 --- /dev/null +++ b/tests/baselines/reference/ambientRequireFunction(module=commonjs).js @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/ambientRequireFunction.ts] //// + +//// [node.d.ts] +declare function require(moduleName: string): any; + +declare module "fs" { + export function readFileSync(s: string): string; +} + +//// [app.js] +/// + +const fs = require("fs"); +const text = fs.readFileSync("/a/b/c"); + +//// [app.js] +/// +var fs = require("fs"); +var text = fs.readFileSync("/a/b/c"); diff --git a/tests/baselines/reference/ambientRequireFunction(module=commonjs).symbols b/tests/baselines/reference/ambientRequireFunction(module=commonjs).symbols new file mode 100644 index 0000000000000..c9c5a0cf27954 --- /dev/null +++ b/tests/baselines/reference/ambientRequireFunction(module=commonjs).symbols @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/ambientRequireFunction.ts] //// + +=== app.js === +/// + +const fs = require("fs"); +>fs : Symbol(fs, Decl(app.js, 2, 5)) +>require : Symbol(require, Decl(node.d.ts, 0, 0)) +>"fs" : Symbol(fs, Decl(node.d.ts, 0, 50)) + +const text = fs.readFileSync("/a/b/c"); +>text : Symbol(text, Decl(app.js, 3, 5)) +>fs.readFileSync : Symbol(fs.readFileSync, Decl(node.d.ts, 2, 21)) +>fs : Symbol(fs, Decl(app.js, 2, 5)) +>readFileSync : Symbol(fs.readFileSync, Decl(node.d.ts, 2, 21)) + +=== node.d.ts === +declare function require(moduleName: string): any; +>require : Symbol(require, Decl(node.d.ts, 0, 0)) +>moduleName : Symbol(moduleName, Decl(node.d.ts, 0, 25)) + +declare module "fs" { +>"fs" : Symbol("fs", Decl(node.d.ts, 0, 50)) + + export function readFileSync(s: string): string; +>readFileSync : Symbol(readFileSync, Decl(node.d.ts, 2, 21)) +>s : Symbol(s, Decl(node.d.ts, 3, 33)) +} + diff --git a/tests/baselines/reference/ambientRequireFunction(module=commonjs).types b/tests/baselines/reference/ambientRequireFunction(module=commonjs).types new file mode 100644 index 0000000000000..f395972c32b7a --- /dev/null +++ b/tests/baselines/reference/ambientRequireFunction(module=commonjs).types @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/ambientRequireFunction.ts] //// + +=== app.js === +/// + +const fs = require("fs"); +>fs : typeof fs +>require("fs") : typeof fs +>require : (moduleName: string) => any +>"fs" : "fs" + +const text = fs.readFileSync("/a/b/c"); +>text : string +>fs.readFileSync("/a/b/c") : string +>fs.readFileSync : (s: string) => string +>fs : typeof fs +>readFileSync : (s: string) => string +>"/a/b/c" : "/a/b/c" + +=== node.d.ts === +declare function require(moduleName: string): any; +>require : (moduleName: string) => any +>moduleName : string + +declare module "fs" { +>"fs" : typeof import("fs") + + export function readFileSync(s: string): string; +>readFileSync : (s: string) => string +>s : string +} + diff --git a/tests/baselines/reference/ambientRequireFunction(module=preserve).js b/tests/baselines/reference/ambientRequireFunction(module=preserve).js new file mode 100644 index 0000000000000..348ee0a144389 --- /dev/null +++ b/tests/baselines/reference/ambientRequireFunction(module=preserve).js @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/ambientRequireFunction.ts] //// + +//// [node.d.ts] +declare function require(moduleName: string): any; + +declare module "fs" { + export function readFileSync(s: string): string; +} + +//// [app.js] +/// + +const fs = require("fs"); +const text = fs.readFileSync("/a/b/c"); + +//// [app.js] +/// +var fs = require("fs"); +var text = fs.readFileSync("/a/b/c"); diff --git a/tests/baselines/reference/ambientRequireFunction(module=preserve).symbols b/tests/baselines/reference/ambientRequireFunction(module=preserve).symbols new file mode 100644 index 0000000000000..cd4e7baad49a7 --- /dev/null +++ b/tests/baselines/reference/ambientRequireFunction(module=preserve).symbols @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/ambientRequireFunction.ts] //// + +=== app.js === +/// + +const fs = require("fs"); +>fs : Symbol(fs, Decl(app.js, 2, 5)) +>require : Symbol(require, Decl(node.d.ts, 0, 0)) + +const text = fs.readFileSync("/a/b/c"); +>text : Symbol(text, Decl(app.js, 3, 5)) +>fs.readFileSync : Symbol(fs.readFileSync, Decl(node.d.ts, 2, 21)) +>fs : Symbol(fs, Decl(app.js, 2, 5)) +>readFileSync : Symbol(fs.readFileSync, Decl(node.d.ts, 2, 21)) + +=== node.d.ts === +declare function require(moduleName: string): any; +>require : Symbol(require, Decl(node.d.ts, 0, 0)) +>moduleName : Symbol(moduleName, Decl(node.d.ts, 0, 25)) + +declare module "fs" { +>"fs" : Symbol("fs", Decl(node.d.ts, 0, 50)) + + export function readFileSync(s: string): string; +>readFileSync : Symbol(readFileSync, Decl(node.d.ts, 2, 21)) +>s : Symbol(s, Decl(node.d.ts, 3, 33)) +} + diff --git a/tests/baselines/reference/ambientRequireFunction(module=preserve).types b/tests/baselines/reference/ambientRequireFunction(module=preserve).types new file mode 100644 index 0000000000000..f395972c32b7a --- /dev/null +++ b/tests/baselines/reference/ambientRequireFunction(module=preserve).types @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/ambientRequireFunction.ts] //// + +=== app.js === +/// + +const fs = require("fs"); +>fs : typeof fs +>require("fs") : typeof fs +>require : (moduleName: string) => any +>"fs" : "fs" + +const text = fs.readFileSync("/a/b/c"); +>text : string +>fs.readFileSync("/a/b/c") : string +>fs.readFileSync : (s: string) => string +>fs : typeof fs +>readFileSync : (s: string) => string +>"/a/b/c" : "/a/b/c" + +=== node.d.ts === +declare function require(moduleName: string): any; +>require : (moduleName: string) => any +>moduleName : string + +declare module "fs" { +>"fs" : typeof import("fs") + + export function readFileSync(s: string): string; +>readFileSync : (s: string) => string +>s : string +} + diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).errors.txt b/tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).errors.txt new file mode 100644 index 0000000000000..7a843cb155e70 --- /dev/null +++ b/tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).errors.txt @@ -0,0 +1,44 @@ +error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation + + +!!! error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +!!! error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +==== /node_modules/conditions/package.json (0 errors) ==== + { + "name": "conditions", + "version": "1.0.0", + "type": "module", + "main": "index.cjs", + "types": "index.d.cts", + "exports": { + ".": { + "node": "./index.node.js", + "default": "./index.web.js" + } + } + } + +==== /node_modules/conditions/index.node.js (0 errors) ==== + export const node = 0; + +==== /node_modules/conditions/index.node.d.ts (0 errors) ==== + export const node: number; + +==== /node_modules/conditions/index.web.js (0 errors) ==== + export const web = 0; + +==== /node_modules/conditions/index.web.d.ts (0 errors) ==== + export const web: number; + +==== /main.ts (0 errors) ==== + import { web } from "conditions"; + \ No newline at end of file diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).js b/tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).js new file mode 100644 index 0000000000000..e6eb1fe883a18 --- /dev/null +++ b/tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).js @@ -0,0 +1,35 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts] //// + +//// [package.json] +{ + "name": "conditions", + "version": "1.0.0", + "type": "module", + "main": "index.cjs", + "types": "index.d.cts", + "exports": { + ".": { + "node": "./index.node.js", + "default": "./index.web.js" + } + } + } + +//// [index.node.js] +export const node = 0; + +//// [index.node.d.ts] +export const node: number; + +//// [index.web.js] +export const web = 0; + +//// [index.web.d.ts] +export const web: number; + +//// [main.ts] +import { web } from "conditions"; + + +//// [main.js] +export {}; diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).symbols b/tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).symbols new file mode 100644 index 0000000000000..4d4c9b1d57da4 --- /dev/null +++ b/tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).symbols @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts] //// + +=== /node_modules/conditions/index.node.d.ts === +export const node: number; +>node : Symbol(node, Decl(index.node.d.ts, 0, 12)) + +=== /node_modules/conditions/index.web.d.ts === +export const web: number; +>web : Symbol(web, Decl(index.web.d.ts, 0, 12)) + +=== /main.ts === +import { web } from "conditions"; +>web : Symbol(web, Decl(main.ts, 0, 8)) + diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).trace.json b/tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).trace.json new file mode 100644 index 0000000000000..0e5cd2eb567dc --- /dev/null +++ b/tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).trace.json @@ -0,0 +1,93 @@ +[ + "======== Resolving module 'conditions' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "File '/package.json' does not exist.", + "Loading module 'conditions' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Found 'package.json' at '/node_modules/conditions/package.json'.", + "Entering conditional exports.", + "Saw non-matching condition 'node'.", + "Matched 'exports' condition 'default'.", + "Using 'exports' subpath '.' with target './index.web.js'.", + "File name '/node_modules/conditions/index.web.js' has a '.js' extension - stripping it.", + "File '/node_modules/conditions/index.web.ts' does not exist.", + "File '/node_modules/conditions/index.web.tsx' does not exist.", + "File '/node_modules/conditions/index.web.d.ts' exists - use it as a name resolution result.", + "Resolved under condition 'default'.", + "Exiting conditional exports.", + "Resolving real path for '/node_modules/conditions/index.web.d.ts', result '/node_modules/conditions/index.web.d.ts'.", + "======== Module name 'conditions' was successfully resolved to '/node_modules/conditions/index.web.d.ts' with Package ID 'conditions/index.web.d.ts@1.0.0'. ========", + "======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es5' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators' from '/.src/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators/legacy' from '/.src/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", + "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom' was not resolved. ========", + "======== Resolving module '@typescript/lib-webworker/importscripts' from '/.src/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", + "======== Resolving module '@typescript/lib-scripthost' from '/.src/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-scripthost' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).types b/tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).types new file mode 100644 index 0000000000000..78f74b5c5367e --- /dev/null +++ b/tests/baselines/reference/bundlerConditionsExcludesNode(module=esnext).types @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts] //// + +=== /node_modules/conditions/index.node.d.ts === +export const node: number; +>node : number + +=== /node_modules/conditions/index.web.d.ts === +export const web: number; +>web : number + +=== /main.ts === +import { web } from "conditions"; +>web : number + diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).errors.txt b/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).errors.txt new file mode 100644 index 0000000000000..7a843cb155e70 --- /dev/null +++ b/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).errors.txt @@ -0,0 +1,44 @@ +error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation + + +!!! error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +!!! error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +==== /node_modules/conditions/package.json (0 errors) ==== + { + "name": "conditions", + "version": "1.0.0", + "type": "module", + "main": "index.cjs", + "types": "index.d.cts", + "exports": { + ".": { + "node": "./index.node.js", + "default": "./index.web.js" + } + } + } + +==== /node_modules/conditions/index.node.js (0 errors) ==== + export const node = 0; + +==== /node_modules/conditions/index.node.d.ts (0 errors) ==== + export const node: number; + +==== /node_modules/conditions/index.web.js (0 errors) ==== + export const web = 0; + +==== /node_modules/conditions/index.web.d.ts (0 errors) ==== + export const web: number; + +==== /main.ts (0 errors) ==== + import { web } from "conditions"; + \ No newline at end of file diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).js b/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).js new file mode 100644 index 0000000000000..e6eb1fe883a18 --- /dev/null +++ b/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).js @@ -0,0 +1,35 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts] //// + +//// [package.json] +{ + "name": "conditions", + "version": "1.0.0", + "type": "module", + "main": "index.cjs", + "types": "index.d.cts", + "exports": { + ".": { + "node": "./index.node.js", + "default": "./index.web.js" + } + } + } + +//// [index.node.js] +export const node = 0; + +//// [index.node.d.ts] +export const node: number; + +//// [index.web.js] +export const web = 0; + +//// [index.web.d.ts] +export const web: number; + +//// [main.ts] +import { web } from "conditions"; + + +//// [main.js] +export {}; diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).symbols b/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).symbols new file mode 100644 index 0000000000000..4d4c9b1d57da4 --- /dev/null +++ b/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).symbols @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts] //// + +=== /node_modules/conditions/index.node.d.ts === +export const node: number; +>node : Symbol(node, Decl(index.node.d.ts, 0, 12)) + +=== /node_modules/conditions/index.web.d.ts === +export const web: number; +>web : Symbol(web, Decl(index.web.d.ts, 0, 12)) + +=== /main.ts === +import { web } from "conditions"; +>web : Symbol(web, Decl(main.ts, 0, 8)) + diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).trace.json b/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).trace.json new file mode 100644 index 0000000000000..0e5cd2eb567dc --- /dev/null +++ b/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).trace.json @@ -0,0 +1,93 @@ +[ + "======== Resolving module 'conditions' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "File '/package.json' does not exist.", + "Loading module 'conditions' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Found 'package.json' at '/node_modules/conditions/package.json'.", + "Entering conditional exports.", + "Saw non-matching condition 'node'.", + "Matched 'exports' condition 'default'.", + "Using 'exports' subpath '.' with target './index.web.js'.", + "File name '/node_modules/conditions/index.web.js' has a '.js' extension - stripping it.", + "File '/node_modules/conditions/index.web.ts' does not exist.", + "File '/node_modules/conditions/index.web.tsx' does not exist.", + "File '/node_modules/conditions/index.web.d.ts' exists - use it as a name resolution result.", + "Resolved under condition 'default'.", + "Exiting conditional exports.", + "Resolving real path for '/node_modules/conditions/index.web.d.ts', result '/node_modules/conditions/index.web.d.ts'.", + "======== Module name 'conditions' was successfully resolved to '/node_modules/conditions/index.web.d.ts' with Package ID 'conditions/index.web.d.ts@1.0.0'. ========", + "======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es5' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators' from '/.src/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators/legacy' from '/.src/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", + "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom' was not resolved. ========", + "======== Resolving module '@typescript/lib-webworker/importscripts' from '/.src/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", + "======== Resolving module '@typescript/lib-scripthost' from '/.src/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-scripthost' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).types b/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).types new file mode 100644 index 0000000000000..78f74b5c5367e --- /dev/null +++ b/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).types @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts] //// + +=== /node_modules/conditions/index.node.d.ts === +export const node: number; +>node : number + +=== /node_modules/conditions/index.web.d.ts === +export const web: number; +>web : number + +=== /main.ts === +import { web } from "conditions"; +>web : number + diff --git a/tests/baselines/reference/bundlerImportESM(module=esnext).js b/tests/baselines/reference/bundlerImportESM(module=esnext).js new file mode 100644 index 0000000000000..48e483322c215 --- /dev/null +++ b/tests/baselines/reference/bundlerImportESM(module=esnext).js @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts] //// + +//// [esm.mts] +export const esm = 0; + +//// [not-actually-cjs.cts] +import { esm } from "./esm.mjs"; + +//// [package.json] +{ "type": "commonjs" } + +//// [still-not-cjs.ts] +import { esm } from "./esm.mjs"; + + +//// [esm.mjs] +export var esm = 0; +//// [not-actually-cjs.cjs] +export {}; +//// [still-not-cjs.js] +export {}; diff --git a/tests/baselines/reference/bundlerImportESM(module=esnext).symbols b/tests/baselines/reference/bundlerImportESM(module=esnext).symbols new file mode 100644 index 0000000000000..d143f99424c05 --- /dev/null +++ b/tests/baselines/reference/bundlerImportESM(module=esnext).symbols @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts] //// + +=== /esm.mts === +export const esm = 0; +>esm : Symbol(esm, Decl(esm.mts, 0, 12)) + +=== /not-actually-cjs.cts === +import { esm } from "./esm.mjs"; +>esm : Symbol(esm, Decl(not-actually-cjs.cts, 0, 8)) + +=== /still-not-cjs.ts === +import { esm } from "./esm.mjs"; +>esm : Symbol(esm, Decl(still-not-cjs.ts, 0, 8)) + diff --git a/tests/baselines/reference/bundlerImportESM(module=esnext).types b/tests/baselines/reference/bundlerImportESM(module=esnext).types new file mode 100644 index 0000000000000..5f0da560436b4 --- /dev/null +++ b/tests/baselines/reference/bundlerImportESM(module=esnext).types @@ -0,0 +1,15 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts] //// + +=== /esm.mts === +export const esm = 0; +>esm : 0 +>0 : 0 + +=== /not-actually-cjs.cts === +import { esm } from "./esm.mjs"; +>esm : 0 + +=== /still-not-cjs.ts === +import { esm } from "./esm.mjs"; +>esm : 0 + diff --git a/tests/baselines/reference/bundlerImportESM(module=preserve).js b/tests/baselines/reference/bundlerImportESM(module=preserve).js new file mode 100644 index 0000000000000..48e483322c215 --- /dev/null +++ b/tests/baselines/reference/bundlerImportESM(module=preserve).js @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts] //// + +//// [esm.mts] +export const esm = 0; + +//// [not-actually-cjs.cts] +import { esm } from "./esm.mjs"; + +//// [package.json] +{ "type": "commonjs" } + +//// [still-not-cjs.ts] +import { esm } from "./esm.mjs"; + + +//// [esm.mjs] +export var esm = 0; +//// [not-actually-cjs.cjs] +export {}; +//// [still-not-cjs.js] +export {}; diff --git a/tests/baselines/reference/bundlerImportESM(module=preserve).symbols b/tests/baselines/reference/bundlerImportESM(module=preserve).symbols new file mode 100644 index 0000000000000..d143f99424c05 --- /dev/null +++ b/tests/baselines/reference/bundlerImportESM(module=preserve).symbols @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts] //// + +=== /esm.mts === +export const esm = 0; +>esm : Symbol(esm, Decl(esm.mts, 0, 12)) + +=== /not-actually-cjs.cts === +import { esm } from "./esm.mjs"; +>esm : Symbol(esm, Decl(not-actually-cjs.cts, 0, 8)) + +=== /still-not-cjs.ts === +import { esm } from "./esm.mjs"; +>esm : Symbol(esm, Decl(still-not-cjs.ts, 0, 8)) + diff --git a/tests/baselines/reference/bundlerImportESM(module=preserve).types b/tests/baselines/reference/bundlerImportESM(module=preserve).types new file mode 100644 index 0000000000000..5f0da560436b4 --- /dev/null +++ b/tests/baselines/reference/bundlerImportESM(module=preserve).types @@ -0,0 +1,15 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts] //// + +=== /esm.mts === +export const esm = 0; +>esm : 0 +>0 : 0 + +=== /not-actually-cjs.cts === +import { esm } from "./esm.mjs"; +>esm : 0 + +=== /still-not-cjs.ts === +import { esm } from "./esm.mjs"; +>esm : 0 + diff --git a/tests/baselines/reference/bundlerNodeModules1(module=esnext).errors.txt b/tests/baselines/reference/bundlerNodeModules1(module=esnext).errors.txt new file mode 100644 index 0000000000000..69921a8ce1425 --- /dev/null +++ b/tests/baselines/reference/bundlerNodeModules1(module=esnext).errors.txt @@ -0,0 +1,59 @@ +error TS6504: File '/node_modules/dual/index.cjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +error TS6504: File '/node_modules/dual/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +/main.cts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. +/main.mts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. +/main.ts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. + + +!!! error TS6504: File '/node_modules/dual/index.cjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +!!! error TS6504: File '/node_modules/dual/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +==== /node_modules/dual/package.json (0 errors) ==== + { + "name": "dual", + "version": "1.0.0", + "type": "module", + "main": "index.cjs", + "types": "index.d.cts", + "exports": { + ".": { + "import": "./index.js", + "require": "./index.cjs" + } + } + } + +==== /node_modules/dual/index.js (0 errors) ==== + export const esm = 0; + +==== /node_modules/dual/index.d.ts (0 errors) ==== + export const esm: number; + +==== /node_modules/dual/index.cjs (0 errors) ==== + exports.cjs = 0; + +==== /node_modules/dual/index.d.cts (0 errors) ==== + export const cjs: number; + +==== /main.ts (1 errors) ==== + import { esm, cjs } from "dual"; + ~~~ +!!! error TS2305: Module '"dual"' has no exported member 'cjs'. + +==== /main.mts (1 errors) ==== + import { esm, cjs } from "dual"; + ~~~ +!!! error TS2305: Module '"dual"' has no exported member 'cjs'. + +==== /main.cts (1 errors) ==== + import { esm, cjs } from "dual"; + ~~~ +!!! error TS2305: Module '"dual"' has no exported member 'cjs'. + \ No newline at end of file diff --git a/tests/baselines/reference/bundlerNodeModules1(module=esnext).js b/tests/baselines/reference/bundlerNodeModules1(module=esnext).js new file mode 100644 index 0000000000000..1272b9f38f865 --- /dev/null +++ b/tests/baselines/reference/bundlerNodeModules1(module=esnext).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts] //// + +//// [package.json] +{ + "name": "dual", + "version": "1.0.0", + "type": "module", + "main": "index.cjs", + "types": "index.d.cts", + "exports": { + ".": { + "import": "./index.js", + "require": "./index.cjs" + } + } +} + +//// [index.js] +export const esm = 0; + +//// [index.d.ts] +export const esm: number; + +//// [index.cjs] +exports.cjs = 0; + +//// [index.d.cts] +export const cjs: number; + +//// [main.ts] +import { esm, cjs } from "dual"; + +//// [main.mts] +import { esm, cjs } from "dual"; + +//// [main.cts] +import { esm, cjs } from "dual"; + + +//// [main.js] +export {}; +//// [main.mjs] +export {}; +//// [main.cjs] +export {}; diff --git a/tests/baselines/reference/bundlerNodeModules1(module=esnext).symbols b/tests/baselines/reference/bundlerNodeModules1(module=esnext).symbols new file mode 100644 index 0000000000000..04471bcc93196 --- /dev/null +++ b/tests/baselines/reference/bundlerNodeModules1(module=esnext).symbols @@ -0,0 +1,25 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts] //// + +=== /node_modules/dual/index.d.ts === +export const esm: number; +>esm : Symbol(esm, Decl(index.d.ts, 0, 12)) + +=== /node_modules/dual/index.d.cts === +export const cjs: number; +>cjs : Symbol(cjs, Decl(index.d.cts, 0, 12)) + +=== /main.ts === +import { esm, cjs } from "dual"; +>esm : Symbol(esm, Decl(main.ts, 0, 8)) +>cjs : Symbol(cjs, Decl(main.ts, 0, 13)) + +=== /main.mts === +import { esm, cjs } from "dual"; +>esm : Symbol(esm, Decl(main.mts, 0, 8)) +>cjs : Symbol(cjs, Decl(main.mts, 0, 13)) + +=== /main.cts === +import { esm, cjs } from "dual"; +>esm : Symbol(esm, Decl(main.cts, 0, 8)) +>cjs : Symbol(cjs, Decl(main.cts, 0, 13)) + diff --git a/tests/baselines/reference/bundlerNodeModules1(module=esnext).trace.json b/tests/baselines/reference/bundlerNodeModules1(module=esnext).trace.json new file mode 100644 index 0000000000000..b6d35e104cdf6 --- /dev/null +++ b/tests/baselines/reference/bundlerNodeModules1(module=esnext).trace.json @@ -0,0 +1,98 @@ +[ + "======== Resolving module 'dual' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "File '/package.json' does not exist.", + "Loading module 'dual' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Found 'package.json' at '/node_modules/dual/package.json'.", + "Entering conditional exports.", + "Matched 'exports' condition 'import'.", + "Using 'exports' subpath '.' with target './index.js'.", + "File name '/node_modules/dual/index.js' has a '.js' extension - stripping it.", + "File '/node_modules/dual/index.ts' does not exist.", + "File '/node_modules/dual/index.tsx' does not exist.", + "File '/node_modules/dual/index.d.ts' exists - use it as a name resolution result.", + "Resolved under condition 'import'.", + "Exiting conditional exports.", + "Resolving real path for '/node_modules/dual/index.d.ts', result '/node_modules/dual/index.d.ts'.", + "======== Module name 'dual' was successfully resolved to '/node_modules/dual/index.d.ts' with Package ID 'dual/index.d.ts@1.0.0'. ========", + "======== Resolving module 'dual' from '/main.mts'. ========", + "Resolution for module 'dual' was found in cache from location '/'.", + "======== Module name 'dual' was successfully resolved to '/node_modules/dual/index.d.ts' with Package ID 'dual/index.d.ts@1.0.0'. ========", + "======== Resolving module 'dual' from '/main.cts'. ========", + "Resolution for module 'dual' was found in cache from location '/'.", + "======== Module name 'dual' was successfully resolved to '/node_modules/dual/index.d.ts' with Package ID 'dual/index.d.ts@1.0.0'. ========", + "======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es5' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators' from '/.src/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators/legacy' from '/.src/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", + "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom' was not resolved. ========", + "======== Resolving module '@typescript/lib-webworker/importscripts' from '/.src/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", + "======== Resolving module '@typescript/lib-scripthost' from '/.src/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-scripthost' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/bundlerNodeModules1(module=esnext).types b/tests/baselines/reference/bundlerNodeModules1(module=esnext).types new file mode 100644 index 0000000000000..4fd828baaa40b --- /dev/null +++ b/tests/baselines/reference/bundlerNodeModules1(module=esnext).types @@ -0,0 +1,25 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts] //// + +=== /node_modules/dual/index.d.ts === +export const esm: number; +>esm : number + +=== /node_modules/dual/index.d.cts === +export const cjs: number; +>cjs : number + +=== /main.ts === +import { esm, cjs } from "dual"; +>esm : number +>cjs : any + +=== /main.mts === +import { esm, cjs } from "dual"; +>esm : number +>cjs : any + +=== /main.cts === +import { esm, cjs } from "dual"; +>esm : number +>cjs : any + diff --git a/tests/baselines/reference/bundlerNodeModules1(module=preserve).errors.txt b/tests/baselines/reference/bundlerNodeModules1(module=preserve).errors.txt new file mode 100644 index 0000000000000..69921a8ce1425 --- /dev/null +++ b/tests/baselines/reference/bundlerNodeModules1(module=preserve).errors.txt @@ -0,0 +1,59 @@ +error TS6504: File '/node_modules/dual/index.cjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +error TS6504: File '/node_modules/dual/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? + The file is in the program because: + Root file specified for compilation +/main.cts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. +/main.mts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. +/main.ts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. + + +!!! error TS6504: File '/node_modules/dual/index.cjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +!!! error TS6504: File '/node_modules/dual/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? +!!! error TS6504: The file is in the program because: +!!! error TS6504: Root file specified for compilation +==== /node_modules/dual/package.json (0 errors) ==== + { + "name": "dual", + "version": "1.0.0", + "type": "module", + "main": "index.cjs", + "types": "index.d.cts", + "exports": { + ".": { + "import": "./index.js", + "require": "./index.cjs" + } + } + } + +==== /node_modules/dual/index.js (0 errors) ==== + export const esm = 0; + +==== /node_modules/dual/index.d.ts (0 errors) ==== + export const esm: number; + +==== /node_modules/dual/index.cjs (0 errors) ==== + exports.cjs = 0; + +==== /node_modules/dual/index.d.cts (0 errors) ==== + export const cjs: number; + +==== /main.ts (1 errors) ==== + import { esm, cjs } from "dual"; + ~~~ +!!! error TS2305: Module '"dual"' has no exported member 'cjs'. + +==== /main.mts (1 errors) ==== + import { esm, cjs } from "dual"; + ~~~ +!!! error TS2305: Module '"dual"' has no exported member 'cjs'. + +==== /main.cts (1 errors) ==== + import { esm, cjs } from "dual"; + ~~~ +!!! error TS2305: Module '"dual"' has no exported member 'cjs'. + \ No newline at end of file diff --git a/tests/baselines/reference/bundlerNodeModules1(module=preserve).js b/tests/baselines/reference/bundlerNodeModules1(module=preserve).js new file mode 100644 index 0000000000000..1272b9f38f865 --- /dev/null +++ b/tests/baselines/reference/bundlerNodeModules1(module=preserve).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts] //// + +//// [package.json] +{ + "name": "dual", + "version": "1.0.0", + "type": "module", + "main": "index.cjs", + "types": "index.d.cts", + "exports": { + ".": { + "import": "./index.js", + "require": "./index.cjs" + } + } +} + +//// [index.js] +export const esm = 0; + +//// [index.d.ts] +export const esm: number; + +//// [index.cjs] +exports.cjs = 0; + +//// [index.d.cts] +export const cjs: number; + +//// [main.ts] +import { esm, cjs } from "dual"; + +//// [main.mts] +import { esm, cjs } from "dual"; + +//// [main.cts] +import { esm, cjs } from "dual"; + + +//// [main.js] +export {}; +//// [main.mjs] +export {}; +//// [main.cjs] +export {}; diff --git a/tests/baselines/reference/bundlerNodeModules1(module=preserve).symbols b/tests/baselines/reference/bundlerNodeModules1(module=preserve).symbols new file mode 100644 index 0000000000000..04471bcc93196 --- /dev/null +++ b/tests/baselines/reference/bundlerNodeModules1(module=preserve).symbols @@ -0,0 +1,25 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts] //// + +=== /node_modules/dual/index.d.ts === +export const esm: number; +>esm : Symbol(esm, Decl(index.d.ts, 0, 12)) + +=== /node_modules/dual/index.d.cts === +export const cjs: number; +>cjs : Symbol(cjs, Decl(index.d.cts, 0, 12)) + +=== /main.ts === +import { esm, cjs } from "dual"; +>esm : Symbol(esm, Decl(main.ts, 0, 8)) +>cjs : Symbol(cjs, Decl(main.ts, 0, 13)) + +=== /main.mts === +import { esm, cjs } from "dual"; +>esm : Symbol(esm, Decl(main.mts, 0, 8)) +>cjs : Symbol(cjs, Decl(main.mts, 0, 13)) + +=== /main.cts === +import { esm, cjs } from "dual"; +>esm : Symbol(esm, Decl(main.cts, 0, 8)) +>cjs : Symbol(cjs, Decl(main.cts, 0, 13)) + diff --git a/tests/baselines/reference/bundlerNodeModules1(module=preserve).trace.json b/tests/baselines/reference/bundlerNodeModules1(module=preserve).trace.json new file mode 100644 index 0000000000000..b6d35e104cdf6 --- /dev/null +++ b/tests/baselines/reference/bundlerNodeModules1(module=preserve).trace.json @@ -0,0 +1,98 @@ +[ + "======== Resolving module 'dual' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "File '/package.json' does not exist.", + "Loading module 'dual' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Found 'package.json' at '/node_modules/dual/package.json'.", + "Entering conditional exports.", + "Matched 'exports' condition 'import'.", + "Using 'exports' subpath '.' with target './index.js'.", + "File name '/node_modules/dual/index.js' has a '.js' extension - stripping it.", + "File '/node_modules/dual/index.ts' does not exist.", + "File '/node_modules/dual/index.tsx' does not exist.", + "File '/node_modules/dual/index.d.ts' exists - use it as a name resolution result.", + "Resolved under condition 'import'.", + "Exiting conditional exports.", + "Resolving real path for '/node_modules/dual/index.d.ts', result '/node_modules/dual/index.d.ts'.", + "======== Module name 'dual' was successfully resolved to '/node_modules/dual/index.d.ts' with Package ID 'dual/index.d.ts@1.0.0'. ========", + "======== Resolving module 'dual' from '/main.mts'. ========", + "Resolution for module 'dual' was found in cache from location '/'.", + "======== Module name 'dual' was successfully resolved to '/node_modules/dual/index.d.ts' with Package ID 'dual/index.d.ts@1.0.0'. ========", + "======== Resolving module 'dual' from '/main.cts'. ========", + "Resolution for module 'dual' was found in cache from location '/'.", + "======== Module name 'dual' was successfully resolved to '/node_modules/dual/index.d.ts' with Package ID 'dual/index.d.ts@1.0.0'. ========", + "======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es5' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators' from '/.src/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators/legacy' from '/.src/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", + "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom' was not resolved. ========", + "======== Resolving module '@typescript/lib-webworker/importscripts' from '/.src/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", + "======== Resolving module '@typescript/lib-scripthost' from '/.src/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-scripthost' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/bundlerNodeModules1(module=preserve).types b/tests/baselines/reference/bundlerNodeModules1(module=preserve).types new file mode 100644 index 0000000000000..4fd828baaa40b --- /dev/null +++ b/tests/baselines/reference/bundlerNodeModules1(module=preserve).types @@ -0,0 +1,25 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts] //// + +=== /node_modules/dual/index.d.ts === +export const esm: number; +>esm : number + +=== /node_modules/dual/index.d.cts === +export const cjs: number; +>cjs : number + +=== /main.ts === +import { esm, cjs } from "dual"; +>esm : number +>cjs : any + +=== /main.mts === +import { esm, cjs } from "dual"; +>esm : number +>cjs : any + +=== /main.cts === +import { esm, cjs } from "dual"; +>esm : number +>cjs : any + diff --git a/tests/baselines/reference/bundlerRelative1(module=esnext).errors.txt b/tests/baselines/reference/bundlerRelative1(module=esnext).errors.txt new file mode 100644 index 0000000000000..738eafa19304f --- /dev/null +++ b/tests/baselines/reference/bundlerRelative1(module=esnext).errors.txt @@ -0,0 +1,39 @@ +/main.ts(4,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/main.ts(7,16): error TS2307: Cannot find module './redirect/index' or its corresponding type declarations. + + +==== /dir/index.ts (0 errors) ==== + export const x = 0; + +==== /redirect/package.json (0 errors) ==== + { "main": "../foo" } + +==== /foo/index.ts (0 errors) ==== + export const y = 0; + +==== /types/esm.d.ts (0 errors) ==== + declare const _: string; + export default _; + +==== /types/cjs.d.ts (0 errors) ==== + declare const _: string; + export = _; + +==== /main.ts (2 errors) ==== + import { x } from "./dir"; + import {} from "./dir/index"; + import {} from "./dir/index.js"; + import {} from "./dir/index.ts"; + ~~~~~~~~~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + + import { y } from "./redirect"; + import {} from "./redirect/index"; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module './redirect/index' or its corresponding type declarations. + + import a from "./types/esm"; + import * as esm from "./types/esm"; + import b from "./types/cjs"; + import * as cjs from "./types/cjs"; + \ No newline at end of file diff --git a/tests/baselines/reference/bundlerRelative1(module=esnext).js b/tests/baselines/reference/bundlerRelative1(module=esnext).js new file mode 100644 index 0000000000000..ffc4d34643a30 --- /dev/null +++ b/tests/baselines/reference/bundlerRelative1(module=esnext).js @@ -0,0 +1,40 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts] //// + +//// [index.ts] +export const x = 0; + +//// [package.json] +{ "main": "../foo" } + +//// [index.ts] +export const y = 0; + +//// [esm.d.ts] +declare const _: string; +export default _; + +//// [cjs.d.ts] +declare const _: string; +export = _; + +//// [main.ts] +import { x } from "./dir"; +import {} from "./dir/index"; +import {} from "./dir/index.js"; +import {} from "./dir/index.ts"; + +import { y } from "./redirect"; +import {} from "./redirect/index"; + +import a from "./types/esm"; +import * as esm from "./types/esm"; +import b from "./types/cjs"; +import * as cjs from "./types/cjs"; + + +//// [index.js] +export var x = 0; +//// [index.js] +export var y = 0; +//// [main.js] +export {}; diff --git a/tests/baselines/reference/bundlerRelative1(module=esnext).symbols b/tests/baselines/reference/bundlerRelative1(module=esnext).symbols new file mode 100644 index 0000000000000..41db8dac77e9c --- /dev/null +++ b/tests/baselines/reference/bundlerRelative1(module=esnext).symbols @@ -0,0 +1,49 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts] //// + +=== /dir/index.ts === +export const x = 0; +>x : Symbol(x, Decl(index.ts, 0, 12)) + +=== /foo/index.ts === +export const y = 0; +>y : Symbol(y, Decl(index.ts, 0, 12)) + +=== /types/esm.d.ts === +declare const _: string; +>_ : Symbol(_, Decl(esm.d.ts, 0, 13)) + +export default _; +>_ : Symbol(_, Decl(esm.d.ts, 0, 13)) + +=== /types/cjs.d.ts === +declare const _: string; +>_ : Symbol(_, Decl(cjs.d.ts, 0, 13)) + +export = _; +>_ : Symbol(_, Decl(cjs.d.ts, 0, 13)) + +=== /main.ts === +import { x } from "./dir"; +>x : Symbol(x, Decl(main.ts, 0, 8)) + +import {} from "./dir/index"; +import {} from "./dir/index.js"; +import {} from "./dir/index.ts"; + +import { y } from "./redirect"; +>y : Symbol(y, Decl(main.ts, 5, 8)) + +import {} from "./redirect/index"; + +import a from "./types/esm"; +>a : Symbol(a, Decl(main.ts, 8, 6)) + +import * as esm from "./types/esm"; +>esm : Symbol(esm, Decl(main.ts, 9, 6)) + +import b from "./types/cjs"; +>b : Symbol(b, Decl(main.ts, 10, 6)) + +import * as cjs from "./types/cjs"; +>cjs : Symbol(cjs, Decl(main.ts, 11, 6)) + diff --git a/tests/baselines/reference/bundlerRelative1(module=esnext).trace.json b/tests/baselines/reference/bundlerRelative1(module=esnext).trace.json new file mode 100644 index 0000000000000..c90d2d5fcf7b5 --- /dev/null +++ b/tests/baselines/reference/bundlerRelative1(module=esnext).trace.json @@ -0,0 +1,162 @@ +[ + "======== Resolving module './dir' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/dir', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/dir.ts' does not exist.", + "File '/dir.tsx' does not exist.", + "File '/dir.d.ts' does not exist.", + "File '/dir.js' does not exist.", + "File '/dir.jsx' does not exist.", + "File '/dir/package.json' does not exist.", + "File '/dir/index.ts' exists - use it as a name resolution result.", + "======== Module name './dir' was successfully resolved to '/dir/index.ts'. ========", + "======== Resolving module './dir/index' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/dir/index', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/dir/index.ts' exists - use it as a name resolution result.", + "======== Module name './dir/index' was successfully resolved to '/dir/index.ts'. ========", + "======== Resolving module './dir/index.js' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/dir/index.js', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File name '/dir/index.js' has a '.js' extension - stripping it.", + "File '/dir/index.ts' exists - use it as a name resolution result.", + "======== Module name './dir/index.js' was successfully resolved to '/dir/index.ts'. ========", + "======== Resolving module './dir/index.ts' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/dir/index.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File name '/dir/index.ts' has a '.ts' extension - stripping it.", + "File '/dir/index.ts' exists - use it as a name resolution result.", + "======== Module name './dir/index.ts' was successfully resolved to '/dir/index.ts'. ========", + "======== Resolving module './redirect' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/redirect', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/redirect.ts' does not exist.", + "File '/redirect.tsx' does not exist.", + "File '/redirect.d.ts' does not exist.", + "File '/redirect.js' does not exist.", + "File '/redirect.jsx' does not exist.", + "Found 'package.json' at '/redirect/package.json'.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field '../foo' that references '/foo'.", + "File '/foo' does not exist.", + "Loading module as file / folder, candidate module location '/foo', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/foo.ts' does not exist.", + "File '/foo.tsx' does not exist.", + "File '/foo.d.ts' does not exist.", + "File '/foo.js' does not exist.", + "File '/foo.jsx' does not exist.", + "File '/foo/index.ts' exists - use it as a name resolution result.", + "======== Module name './redirect' was successfully resolved to '/foo/index.ts'. ========", + "======== Resolving module './redirect/index' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/redirect/index', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/redirect/index.ts' does not exist.", + "File '/redirect/index.tsx' does not exist.", + "File '/redirect/index.d.ts' does not exist.", + "File '/redirect/index.js' does not exist.", + "File '/redirect/index.jsx' does not exist.", + "Directory '/redirect/index' does not exist, skipping all lookups in it.", + "======== Module name './redirect/index' was not resolved. ========", + "======== Resolving module './types/esm' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/types/esm', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/types/esm.ts' does not exist.", + "File '/types/esm.tsx' does not exist.", + "File '/types/esm.d.ts' exists - use it as a name resolution result.", + "======== Module name './types/esm' was successfully resolved to '/types/esm.d.ts'. ========", + "======== Resolving module './types/cjs' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/types/cjs', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/types/cjs.ts' does not exist.", + "File '/types/cjs.tsx' does not exist.", + "File '/types/cjs.d.ts' exists - use it as a name resolution result.", + "======== Module name './types/cjs' was successfully resolved to '/types/cjs.d.ts'. ========", + "======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es5' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators' from '/.src/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators/legacy' from '/.src/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", + "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom' was not resolved. ========", + "======== Resolving module '@typescript/lib-webworker/importscripts' from '/.src/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", + "======== Resolving module '@typescript/lib-scripthost' from '/.src/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-scripthost' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/bundlerRelative1(module=esnext).types b/tests/baselines/reference/bundlerRelative1(module=esnext).types new file mode 100644 index 0000000000000..50663cfe46ead --- /dev/null +++ b/tests/baselines/reference/bundlerRelative1(module=esnext).types @@ -0,0 +1,51 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts] //// + +=== /dir/index.ts === +export const x = 0; +>x : 0 +>0 : 0 + +=== /foo/index.ts === +export const y = 0; +>y : 0 +>0 : 0 + +=== /types/esm.d.ts === +declare const _: string; +>_ : string + +export default _; +>_ : string + +=== /types/cjs.d.ts === +declare const _: string; +>_ : string + +export = _; +>_ : string + +=== /main.ts === +import { x } from "./dir"; +>x : 0 + +import {} from "./dir/index"; +import {} from "./dir/index.js"; +import {} from "./dir/index.ts"; + +import { y } from "./redirect"; +>y : 0 + +import {} from "./redirect/index"; + +import a from "./types/esm"; +>a : string + +import * as esm from "./types/esm"; +>esm : typeof esm + +import b from "./types/cjs"; +>b : string + +import * as cjs from "./types/cjs"; +>cjs : string + diff --git a/tests/baselines/reference/bundlerRelative1(module=preserve).errors.txt b/tests/baselines/reference/bundlerRelative1(module=preserve).errors.txt new file mode 100644 index 0000000000000..738eafa19304f --- /dev/null +++ b/tests/baselines/reference/bundlerRelative1(module=preserve).errors.txt @@ -0,0 +1,39 @@ +/main.ts(4,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/main.ts(7,16): error TS2307: Cannot find module './redirect/index' or its corresponding type declarations. + + +==== /dir/index.ts (0 errors) ==== + export const x = 0; + +==== /redirect/package.json (0 errors) ==== + { "main": "../foo" } + +==== /foo/index.ts (0 errors) ==== + export const y = 0; + +==== /types/esm.d.ts (0 errors) ==== + declare const _: string; + export default _; + +==== /types/cjs.d.ts (0 errors) ==== + declare const _: string; + export = _; + +==== /main.ts (2 errors) ==== + import { x } from "./dir"; + import {} from "./dir/index"; + import {} from "./dir/index.js"; + import {} from "./dir/index.ts"; + ~~~~~~~~~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + + import { y } from "./redirect"; + import {} from "./redirect/index"; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module './redirect/index' or its corresponding type declarations. + + import a from "./types/esm"; + import * as esm from "./types/esm"; + import b from "./types/cjs"; + import * as cjs from "./types/cjs"; + \ No newline at end of file diff --git a/tests/baselines/reference/bundlerRelative1(module=preserve).js b/tests/baselines/reference/bundlerRelative1(module=preserve).js new file mode 100644 index 0000000000000..ffc4d34643a30 --- /dev/null +++ b/tests/baselines/reference/bundlerRelative1(module=preserve).js @@ -0,0 +1,40 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts] //// + +//// [index.ts] +export const x = 0; + +//// [package.json] +{ "main": "../foo" } + +//// [index.ts] +export const y = 0; + +//// [esm.d.ts] +declare const _: string; +export default _; + +//// [cjs.d.ts] +declare const _: string; +export = _; + +//// [main.ts] +import { x } from "./dir"; +import {} from "./dir/index"; +import {} from "./dir/index.js"; +import {} from "./dir/index.ts"; + +import { y } from "./redirect"; +import {} from "./redirect/index"; + +import a from "./types/esm"; +import * as esm from "./types/esm"; +import b from "./types/cjs"; +import * as cjs from "./types/cjs"; + + +//// [index.js] +export var x = 0; +//// [index.js] +export var y = 0; +//// [main.js] +export {}; diff --git a/tests/baselines/reference/bundlerRelative1(module=preserve).symbols b/tests/baselines/reference/bundlerRelative1(module=preserve).symbols new file mode 100644 index 0000000000000..41db8dac77e9c --- /dev/null +++ b/tests/baselines/reference/bundlerRelative1(module=preserve).symbols @@ -0,0 +1,49 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts] //// + +=== /dir/index.ts === +export const x = 0; +>x : Symbol(x, Decl(index.ts, 0, 12)) + +=== /foo/index.ts === +export const y = 0; +>y : Symbol(y, Decl(index.ts, 0, 12)) + +=== /types/esm.d.ts === +declare const _: string; +>_ : Symbol(_, Decl(esm.d.ts, 0, 13)) + +export default _; +>_ : Symbol(_, Decl(esm.d.ts, 0, 13)) + +=== /types/cjs.d.ts === +declare const _: string; +>_ : Symbol(_, Decl(cjs.d.ts, 0, 13)) + +export = _; +>_ : Symbol(_, Decl(cjs.d.ts, 0, 13)) + +=== /main.ts === +import { x } from "./dir"; +>x : Symbol(x, Decl(main.ts, 0, 8)) + +import {} from "./dir/index"; +import {} from "./dir/index.js"; +import {} from "./dir/index.ts"; + +import { y } from "./redirect"; +>y : Symbol(y, Decl(main.ts, 5, 8)) + +import {} from "./redirect/index"; + +import a from "./types/esm"; +>a : Symbol(a, Decl(main.ts, 8, 6)) + +import * as esm from "./types/esm"; +>esm : Symbol(esm, Decl(main.ts, 9, 6)) + +import b from "./types/cjs"; +>b : Symbol(b, Decl(main.ts, 10, 6)) + +import * as cjs from "./types/cjs"; +>cjs : Symbol(cjs, Decl(main.ts, 11, 6)) + diff --git a/tests/baselines/reference/bundlerRelative1(module=preserve).trace.json b/tests/baselines/reference/bundlerRelative1(module=preserve).trace.json new file mode 100644 index 0000000000000..c90d2d5fcf7b5 --- /dev/null +++ b/tests/baselines/reference/bundlerRelative1(module=preserve).trace.json @@ -0,0 +1,162 @@ +[ + "======== Resolving module './dir' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/dir', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/dir.ts' does not exist.", + "File '/dir.tsx' does not exist.", + "File '/dir.d.ts' does not exist.", + "File '/dir.js' does not exist.", + "File '/dir.jsx' does not exist.", + "File '/dir/package.json' does not exist.", + "File '/dir/index.ts' exists - use it as a name resolution result.", + "======== Module name './dir' was successfully resolved to '/dir/index.ts'. ========", + "======== Resolving module './dir/index' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/dir/index', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/dir/index.ts' exists - use it as a name resolution result.", + "======== Module name './dir/index' was successfully resolved to '/dir/index.ts'. ========", + "======== Resolving module './dir/index.js' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/dir/index.js', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File name '/dir/index.js' has a '.js' extension - stripping it.", + "File '/dir/index.ts' exists - use it as a name resolution result.", + "======== Module name './dir/index.js' was successfully resolved to '/dir/index.ts'. ========", + "======== Resolving module './dir/index.ts' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/dir/index.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File name '/dir/index.ts' has a '.ts' extension - stripping it.", + "File '/dir/index.ts' exists - use it as a name resolution result.", + "======== Module name './dir/index.ts' was successfully resolved to '/dir/index.ts'. ========", + "======== Resolving module './redirect' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/redirect', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/redirect.ts' does not exist.", + "File '/redirect.tsx' does not exist.", + "File '/redirect.d.ts' does not exist.", + "File '/redirect.js' does not exist.", + "File '/redirect.jsx' does not exist.", + "Found 'package.json' at '/redirect/package.json'.", + "'package.json' does not have a 'typesVersions' field.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field '../foo' that references '/foo'.", + "File '/foo' does not exist.", + "Loading module as file / folder, candidate module location '/foo', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/foo.ts' does not exist.", + "File '/foo.tsx' does not exist.", + "File '/foo.d.ts' does not exist.", + "File '/foo.js' does not exist.", + "File '/foo.jsx' does not exist.", + "File '/foo/index.ts' exists - use it as a name resolution result.", + "======== Module name './redirect' was successfully resolved to '/foo/index.ts'. ========", + "======== Resolving module './redirect/index' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/redirect/index', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/redirect/index.ts' does not exist.", + "File '/redirect/index.tsx' does not exist.", + "File '/redirect/index.d.ts' does not exist.", + "File '/redirect/index.js' does not exist.", + "File '/redirect/index.jsx' does not exist.", + "Directory '/redirect/index' does not exist, skipping all lookups in it.", + "======== Module name './redirect/index' was not resolved. ========", + "======== Resolving module './types/esm' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/types/esm', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/types/esm.ts' does not exist.", + "File '/types/esm.tsx' does not exist.", + "File '/types/esm.d.ts' exists - use it as a name resolution result.", + "======== Module name './types/esm' was successfully resolved to '/types/esm.d.ts'. ========", + "======== Resolving module './types/cjs' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Bundler'.", + "Resolving in CJS mode with conditions 'import', 'types'.", + "Loading module as file / folder, candidate module location '/types/cjs', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/types/cjs.ts' does not exist.", + "File '/types/cjs.tsx' does not exist.", + "File '/types/cjs.d.ts' exists - use it as a name resolution result.", + "======== Module name './types/cjs' was successfully resolved to '/types/cjs.d.ts'. ========", + "======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-es5'", + "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-es5' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators' from '/.src/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators'", + "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators' was not resolved. ========", + "======== Resolving module '@typescript/lib-decorators/legacy' from '/.src/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", + "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", + "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom'", + "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom' was not resolved. ========", + "======== Resolving module '@typescript/lib-webworker/importscripts' from '/.src/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", + "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", + "======== Resolving module '@typescript/lib-scripthost' from '/.src/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-scripthost'", + "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-scripthost' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/bundlerRelative1(module=preserve).types b/tests/baselines/reference/bundlerRelative1(module=preserve).types new file mode 100644 index 0000000000000..50663cfe46ead --- /dev/null +++ b/tests/baselines/reference/bundlerRelative1(module=preserve).types @@ -0,0 +1,51 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts] //// + +=== /dir/index.ts === +export const x = 0; +>x : 0 +>0 : 0 + +=== /foo/index.ts === +export const y = 0; +>y : 0 +>0 : 0 + +=== /types/esm.d.ts === +declare const _: string; +>_ : string + +export default _; +>_ : string + +=== /types/cjs.d.ts === +declare const _: string; +>_ : string + +export = _; +>_ : string + +=== /main.ts === +import { x } from "./dir"; +>x : 0 + +import {} from "./dir/index"; +import {} from "./dir/index.js"; +import {} from "./dir/index.ts"; + +import { y } from "./redirect"; +>y : 0 + +import {} from "./redirect/index"; + +import a from "./types/esm"; +>a : string + +import * as esm from "./types/esm"; +>esm : typeof esm + +import b from "./types/cjs"; +>b : string + +import * as cjs from "./types/cjs"; +>cjs : string + diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).errors.txt b/tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).errors.txt new file mode 100644 index 0000000000000..0883750c3d136 --- /dev/null +++ b/tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).errors.txt @@ -0,0 +1,43 @@ +error TS2468: Cannot find global value 'Promise'. +/main.ts(2,1): error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. +/main.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +/mainJs.js(2,1): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. + + +!!! error TS2468: Cannot find global value 'Promise'. +==== /node_modules/@types/node/index.d.ts (0 errors) ==== + declare var require: (...args: any[]) => any; + +==== /ambient.d.ts (0 errors) ==== + declare module "fs" { + export function readFileSync(path: string, encoding?: string): string; + } + declare module "path" { + import fs = require("fs"); // ok + namespace path { + export const sep: string; + } + export = path; // ok + } + +==== /mainJs.js (1 errors) ==== + import {} from "./a"; + import("./a"); + ~~~~~~~~~~~~~ +!!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. + const _ = require("./a"); + _.a; // any + +==== /main.ts (2 errors) ==== + import {} from "./a"; + import _ = require("./a"); // Error in esnext + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. + export = {}; // Error + ~~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + export {}; + +==== /a.ts (0 errors) ==== + export const a = "a"; + \ No newline at end of file diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).js b/tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).js new file mode 100644 index 0000000000000..ab856841dba85 --- /dev/null +++ b/tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts] //// + +//// [index.d.ts] +declare var require: (...args: any[]) => any; + +//// [ambient.d.ts] +declare module "fs" { + export function readFileSync(path: string, encoding?: string): string; +} +declare module "path" { + import fs = require("fs"); // ok + namespace path { + export const sep: string; + } + export = path; // ok +} + +//// [mainJs.js] +import {} from "./a"; +import("./a"); +const _ = require("./a"); +_.a; // any + +//// [main.ts] +import {} from "./a"; +import _ = require("./a"); // Error in esnext +export = {}; // Error +export {}; + +//// [a.ts] +export const a = "a"; + + +//// [a.js] +export var a = "a"; +//// [mainJs.js] +import("./a"); +var _ = require("./a"); +_.a; // any +export {}; +//// [main.js] +export {}; diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).symbols b/tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).symbols new file mode 100644 index 0000000000000..1a39f0bc05dc4 --- /dev/null +++ b/tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).symbols @@ -0,0 +1,58 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts] //// + +=== /node_modules/@types/node/index.d.ts === +declare var require: (...args: any[]) => any; +>require : Symbol(require, Decl(index.d.ts, 0, 11)) +>args : Symbol(args, Decl(index.d.ts, 0, 22)) + +=== /ambient.d.ts === +declare module "fs" { +>"fs" : Symbol("fs", Decl(ambient.d.ts, 0, 0)) + + export function readFileSync(path: string, encoding?: string): string; +>readFileSync : Symbol(readFileSync, Decl(ambient.d.ts, 0, 21)) +>path : Symbol(path, Decl(ambient.d.ts, 1, 33)) +>encoding : Symbol(encoding, Decl(ambient.d.ts, 1, 46)) +} +declare module "path" { +>"path" : Symbol("path", Decl(ambient.d.ts, 2, 1)) + + import fs = require("fs"); // ok +>fs : Symbol(fs, Decl(ambient.d.ts, 3, 23)) + + namespace path { +>path : Symbol(path, Decl(ambient.d.ts, 4, 30)) + + export const sep: string; +>sep : Symbol(sep, Decl(ambient.d.ts, 6, 20)) + } + export = path; // ok +>path : Symbol(path, Decl(ambient.d.ts, 4, 30)) +} + +=== /mainJs.js === +import {} from "./a"; +import("./a"); +>"./a" : Symbol(_, Decl(a.ts, 0, 0)) + +const _ = require("./a"); +>_ : Symbol(_, Decl(mainJs.js, 2, 5)) +>require : Symbol(require, Decl(index.d.ts, 0, 11)) + +_.a; // any +>_.a : Symbol(_.a, Decl(a.ts, 0, 12)) +>_ : Symbol(_, Decl(mainJs.js, 2, 5)) +>a : Symbol(_.a, Decl(a.ts, 0, 12)) + +=== /main.ts === +import {} from "./a"; +import _ = require("./a"); // Error in esnext +>_ : Symbol(_, Decl(main.ts, 0, 21)) + +export = {}; // Error +export {}; + +=== /a.ts === +export const a = "a"; +>a : Symbol(a, Decl(a.ts, 0, 12)) + diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).types b/tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).types new file mode 100644 index 0000000000000..310b8a83d268e --- /dev/null +++ b/tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).types @@ -0,0 +1,64 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts] //// + +=== /node_modules/@types/node/index.d.ts === +declare var require: (...args: any[]) => any; +>require : (...args: any[]) => any +>args : any[] + +=== /ambient.d.ts === +declare module "fs" { +>"fs" : typeof import("fs") + + export function readFileSync(path: string, encoding?: string): string; +>readFileSync : (path: string, encoding?: string) => string +>path : string +>encoding : string +} +declare module "path" { +>"path" : typeof import("path") + + import fs = require("fs"); // ok +>fs : typeof fs + + namespace path { +>path : typeof path + + export const sep: string; +>sep : string + } + export = path; // ok +>path : typeof path +} + +=== /mainJs.js === +import {} from "./a"; +import("./a"); +>import("./a") : Promise +>"./a" : "./a" + +const _ = require("./a"); +>_ : typeof _ +>require("./a") : typeof _ +>require : (...args: any[]) => any +>"./a" : "./a" + +_.a; // any +>_.a : "a" +>_ : typeof _ +>a : "a" + +=== /main.ts === +import {} from "./a"; +import _ = require("./a"); // Error in esnext +>_ : typeof _ + +export = {}; // Error +>{} : {} + +export {}; + +=== /a.ts === +export const a = "a"; +>a : "a" +>"a" : "a" + diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).errors.txt b/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).errors.txt new file mode 100644 index 0000000000000..7f3ea3715320c --- /dev/null +++ b/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).errors.txt @@ -0,0 +1,37 @@ +error TS2468: Cannot find global value 'Promise'. +/mainJs.js(2,1): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. + + +!!! error TS2468: Cannot find global value 'Promise'. +==== /node_modules/@types/node/index.d.ts (0 errors) ==== + declare var require: (...args: any[]) => any; + +==== /ambient.d.ts (0 errors) ==== + declare module "fs" { + export function readFileSync(path: string, encoding?: string): string; + } + declare module "path" { + import fs = require("fs"); // ok + namespace path { + export const sep: string; + } + export = path; // ok + } + +==== /mainJs.js (1 errors) ==== + import {} from "./a"; + import("./a"); + ~~~~~~~~~~~~~ +!!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. + const _ = require("./a"); + _.a; // any + +==== /main.ts (0 errors) ==== + import {} from "./a"; + import _ = require("./a"); // Error in esnext + export = {}; // Error + export {}; + +==== /a.ts (0 errors) ==== + export const a = "a"; + \ No newline at end of file diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).js b/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).js new file mode 100644 index 0000000000000..c28b7f67b52ba --- /dev/null +++ b/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).js @@ -0,0 +1,43 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts] //// + +//// [index.d.ts] +declare var require: (...args: any[]) => any; + +//// [ambient.d.ts] +declare module "fs" { + export function readFileSync(path: string, encoding?: string): string; +} +declare module "path" { + import fs = require("fs"); // ok + namespace path { + export const sep: string; + } + export = path; // ok +} + +//// [mainJs.js] +import {} from "./a"; +import("./a"); +const _ = require("./a"); +_.a; // any + +//// [main.ts] +import {} from "./a"; +import _ = require("./a"); // Error in esnext +export = {}; // Error +export {}; + +//// [a.ts] +export const a = "a"; + + +//// [a.js] +export var a = "a"; +//// [mainJs.js] +import("./a"); +var _ = require("./a"); +_.a; // any +export {}; +//// [main.js] +module.exports = {}; +export {}; diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).symbols b/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).symbols new file mode 100644 index 0000000000000..1a39f0bc05dc4 --- /dev/null +++ b/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).symbols @@ -0,0 +1,58 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts] //// + +=== /node_modules/@types/node/index.d.ts === +declare var require: (...args: any[]) => any; +>require : Symbol(require, Decl(index.d.ts, 0, 11)) +>args : Symbol(args, Decl(index.d.ts, 0, 22)) + +=== /ambient.d.ts === +declare module "fs" { +>"fs" : Symbol("fs", Decl(ambient.d.ts, 0, 0)) + + export function readFileSync(path: string, encoding?: string): string; +>readFileSync : Symbol(readFileSync, Decl(ambient.d.ts, 0, 21)) +>path : Symbol(path, Decl(ambient.d.ts, 1, 33)) +>encoding : Symbol(encoding, Decl(ambient.d.ts, 1, 46)) +} +declare module "path" { +>"path" : Symbol("path", Decl(ambient.d.ts, 2, 1)) + + import fs = require("fs"); // ok +>fs : Symbol(fs, Decl(ambient.d.ts, 3, 23)) + + namespace path { +>path : Symbol(path, Decl(ambient.d.ts, 4, 30)) + + export const sep: string; +>sep : Symbol(sep, Decl(ambient.d.ts, 6, 20)) + } + export = path; // ok +>path : Symbol(path, Decl(ambient.d.ts, 4, 30)) +} + +=== /mainJs.js === +import {} from "./a"; +import("./a"); +>"./a" : Symbol(_, Decl(a.ts, 0, 0)) + +const _ = require("./a"); +>_ : Symbol(_, Decl(mainJs.js, 2, 5)) +>require : Symbol(require, Decl(index.d.ts, 0, 11)) + +_.a; // any +>_.a : Symbol(_.a, Decl(a.ts, 0, 12)) +>_ : Symbol(_, Decl(mainJs.js, 2, 5)) +>a : Symbol(_.a, Decl(a.ts, 0, 12)) + +=== /main.ts === +import {} from "./a"; +import _ = require("./a"); // Error in esnext +>_ : Symbol(_, Decl(main.ts, 0, 21)) + +export = {}; // Error +export {}; + +=== /a.ts === +export const a = "a"; +>a : Symbol(a, Decl(a.ts, 0, 12)) + diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).types b/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).types new file mode 100644 index 0000000000000..310b8a83d268e --- /dev/null +++ b/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).types @@ -0,0 +1,64 @@ +//// [tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts] //// + +=== /node_modules/@types/node/index.d.ts === +declare var require: (...args: any[]) => any; +>require : (...args: any[]) => any +>args : any[] + +=== /ambient.d.ts === +declare module "fs" { +>"fs" : typeof import("fs") + + export function readFileSync(path: string, encoding?: string): string; +>readFileSync : (path: string, encoding?: string) => string +>path : string +>encoding : string +} +declare module "path" { +>"path" : typeof import("path") + + import fs = require("fs"); // ok +>fs : typeof fs + + namespace path { +>path : typeof path + + export const sep: string; +>sep : string + } + export = path; // ok +>path : typeof path +} + +=== /mainJs.js === +import {} from "./a"; +import("./a"); +>import("./a") : Promise +>"./a" : "./a" + +const _ = require("./a"); +>_ : typeof _ +>require("./a") : typeof _ +>require : (...args: any[]) => any +>"./a" : "./a" + +_.a; // any +>_.a : "a" +>_ : typeof _ +>a : "a" + +=== /main.ts === +import {} from "./a"; +import _ = require("./a"); // Error in esnext +>_ : typeof _ + +export = {}; // Error +>{} : {} + +export {}; + +=== /a.ts === +export const a = "a"; +>a : "a" +>"a" : "a" + From 739e7189476dbe9544f37b4693c9a9257d25d026 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 14 Dec 2023 17:11:22 -0800 Subject: [PATCH 17/31] Remove unused baselines --- diff.bash | 36 ---- .../reference/ambientRequireFunction.js | 19 -- .../reference/ambientRequireFunction.symbols | 29 ---- .../reference/ambientRequireFunction.types | 32 ---- .../bundlerConditionsExcludesNode.errors.txt | 44 ----- .../bundlerConditionsExcludesNode.js | 35 ---- .../bundlerConditionsExcludesNode.symbols | 14 -- .../bundlerConditionsExcludesNode.trace.json | 93 ---------- .../bundlerConditionsExcludesNode.types | 14 -- tests/baselines/reference/bundlerImportESM.js | 21 --- .../reference/bundlerImportESM.symbols | 14 -- .../reference/bundlerImportESM.types | 15 -- .../reference/bundlerNodeModules1.errors.txt | 59 ------- .../reference/bundlerNodeModules1.js | 45 ----- .../reference/bundlerNodeModules1.symbols | 25 --- .../reference/bundlerNodeModules1.trace.json | 98 ----------- .../reference/bundlerNodeModules1.types | 25 --- .../reference/bundlerRelative1.errors.txt | 39 ----- tests/baselines/reference/bundlerRelative1.js | 40 ----- .../reference/bundlerRelative1.symbols | 49 ------ .../reference/bundlerRelative1.trace.json | 162 ------------------ .../reference/bundlerRelative1.types | 51 ------ .../bundlerSyntaxRestrictions.errors.txt | 43 ----- .../reference/bundlerSyntaxRestrictions.js | 42 ----- .../bundlerSyntaxRestrictions.symbols | 58 ------- .../reference/bundlerSyntaxRestrictions.types | 64 ------- 26 files changed, 1166 deletions(-) delete mode 100755 diff.bash delete mode 100644 tests/baselines/reference/ambientRequireFunction.js delete mode 100644 tests/baselines/reference/ambientRequireFunction.symbols delete mode 100644 tests/baselines/reference/ambientRequireFunction.types delete mode 100644 tests/baselines/reference/bundlerConditionsExcludesNode.errors.txt delete mode 100644 tests/baselines/reference/bundlerConditionsExcludesNode.js delete mode 100644 tests/baselines/reference/bundlerConditionsExcludesNode.symbols delete mode 100644 tests/baselines/reference/bundlerConditionsExcludesNode.trace.json delete mode 100644 tests/baselines/reference/bundlerConditionsExcludesNode.types delete mode 100644 tests/baselines/reference/bundlerImportESM.js delete mode 100644 tests/baselines/reference/bundlerImportESM.symbols delete mode 100644 tests/baselines/reference/bundlerImportESM.types delete mode 100644 tests/baselines/reference/bundlerNodeModules1.errors.txt delete mode 100644 tests/baselines/reference/bundlerNodeModules1.js delete mode 100644 tests/baselines/reference/bundlerNodeModules1.symbols delete mode 100644 tests/baselines/reference/bundlerNodeModules1.trace.json delete mode 100644 tests/baselines/reference/bundlerNodeModules1.types delete mode 100644 tests/baselines/reference/bundlerRelative1.errors.txt delete mode 100644 tests/baselines/reference/bundlerRelative1.js delete mode 100644 tests/baselines/reference/bundlerRelative1.symbols delete mode 100644 tests/baselines/reference/bundlerRelative1.trace.json delete mode 100644 tests/baselines/reference/bundlerRelative1.types delete mode 100644 tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt delete mode 100644 tests/baselines/reference/bundlerSyntaxRestrictions.js delete mode 100644 tests/baselines/reference/bundlerSyntaxRestrictions.symbols delete mode 100644 tests/baselines/reference/bundlerSyntaxRestrictions.types diff --git a/diff.bash b/diff.bash deleted file mode 100755 index b2bc2ad506659..0000000000000 --- a/diff.bash +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/zsh - -# Directory containing the test files -directory="./tests/baselines/local" - -# Associative array to hold base names, extensions, and their corresponding files -typeset -A tests - -# Loop over files in the directory with different extensions -for ext in js symbols types errors.txt trace.json; do - for file in "$directory"/*\(module=*\).$ext; do - # Extract the base test name by removing the parameter and extension parts - base_name=${file%%\(module=*} - - # Add the file to the array for this base name and extension - tests[$base_name,$ext]+="$file " - done -done - -# Loop over the test groups -for key in ${(k)tests}; do - # Split the key into base name and extension - base_name=${key%,*} - ext=${key#*,} - - # Get all files for this test and extension - files=(${(s: :)tests[$key]}) - - # Compare each file with each other - for (( i=1; i<=$#files; i++ )); do - for (( j=i+1; j<=$#files; j++ )); do - echo "Diffing $files[i] and $files[j]" - diff "$files[i]" "$files[j]" - done - done -done diff --git a/tests/baselines/reference/ambientRequireFunction.js b/tests/baselines/reference/ambientRequireFunction.js deleted file mode 100644 index 348ee0a144389..0000000000000 --- a/tests/baselines/reference/ambientRequireFunction.js +++ /dev/null @@ -1,19 +0,0 @@ -//// [tests/cases/compiler/ambientRequireFunction.ts] //// - -//// [node.d.ts] -declare function require(moduleName: string): any; - -declare module "fs" { - export function readFileSync(s: string): string; -} - -//// [app.js] -/// - -const fs = require("fs"); -const text = fs.readFileSync("/a/b/c"); - -//// [app.js] -/// -var fs = require("fs"); -var text = fs.readFileSync("/a/b/c"); diff --git a/tests/baselines/reference/ambientRequireFunction.symbols b/tests/baselines/reference/ambientRequireFunction.symbols deleted file mode 100644 index c9c5a0cf27954..0000000000000 --- a/tests/baselines/reference/ambientRequireFunction.symbols +++ /dev/null @@ -1,29 +0,0 @@ -//// [tests/cases/compiler/ambientRequireFunction.ts] //// - -=== app.js === -/// - -const fs = require("fs"); ->fs : Symbol(fs, Decl(app.js, 2, 5)) ->require : Symbol(require, Decl(node.d.ts, 0, 0)) ->"fs" : Symbol(fs, Decl(node.d.ts, 0, 50)) - -const text = fs.readFileSync("/a/b/c"); ->text : Symbol(text, Decl(app.js, 3, 5)) ->fs.readFileSync : Symbol(fs.readFileSync, Decl(node.d.ts, 2, 21)) ->fs : Symbol(fs, Decl(app.js, 2, 5)) ->readFileSync : Symbol(fs.readFileSync, Decl(node.d.ts, 2, 21)) - -=== node.d.ts === -declare function require(moduleName: string): any; ->require : Symbol(require, Decl(node.d.ts, 0, 0)) ->moduleName : Symbol(moduleName, Decl(node.d.ts, 0, 25)) - -declare module "fs" { ->"fs" : Symbol("fs", Decl(node.d.ts, 0, 50)) - - export function readFileSync(s: string): string; ->readFileSync : Symbol(readFileSync, Decl(node.d.ts, 2, 21)) ->s : Symbol(s, Decl(node.d.ts, 3, 33)) -} - diff --git a/tests/baselines/reference/ambientRequireFunction.types b/tests/baselines/reference/ambientRequireFunction.types deleted file mode 100644 index f395972c32b7a..0000000000000 --- a/tests/baselines/reference/ambientRequireFunction.types +++ /dev/null @@ -1,32 +0,0 @@ -//// [tests/cases/compiler/ambientRequireFunction.ts] //// - -=== app.js === -/// - -const fs = require("fs"); ->fs : typeof fs ->require("fs") : typeof fs ->require : (moduleName: string) => any ->"fs" : "fs" - -const text = fs.readFileSync("/a/b/c"); ->text : string ->fs.readFileSync("/a/b/c") : string ->fs.readFileSync : (s: string) => string ->fs : typeof fs ->readFileSync : (s: string) => string ->"/a/b/c" : "/a/b/c" - -=== node.d.ts === -declare function require(moduleName: string): any; ->require : (moduleName: string) => any ->moduleName : string - -declare module "fs" { ->"fs" : typeof import("fs") - - export function readFileSync(s: string): string; ->readFileSync : (s: string) => string ->s : string -} - diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode.errors.txt b/tests/baselines/reference/bundlerConditionsExcludesNode.errors.txt deleted file mode 100644 index 7a843cb155e70..0000000000000 --- a/tests/baselines/reference/bundlerConditionsExcludesNode.errors.txt +++ /dev/null @@ -1,44 +0,0 @@ -error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? - The file is in the program because: - Root file specified for compilation -error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? - The file is in the program because: - Root file specified for compilation - - -!!! error TS6504: File '/node_modules/conditions/index.node.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -!!! error TS6504: The file is in the program because: -!!! error TS6504: Root file specified for compilation -!!! error TS6504: File '/node_modules/conditions/index.web.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -!!! error TS6504: The file is in the program because: -!!! error TS6504: Root file specified for compilation -==== /node_modules/conditions/package.json (0 errors) ==== - { - "name": "conditions", - "version": "1.0.0", - "type": "module", - "main": "index.cjs", - "types": "index.d.cts", - "exports": { - ".": { - "node": "./index.node.js", - "default": "./index.web.js" - } - } - } - -==== /node_modules/conditions/index.node.js (0 errors) ==== - export const node = 0; - -==== /node_modules/conditions/index.node.d.ts (0 errors) ==== - export const node: number; - -==== /node_modules/conditions/index.web.js (0 errors) ==== - export const web = 0; - -==== /node_modules/conditions/index.web.d.ts (0 errors) ==== - export const web: number; - -==== /main.ts (0 errors) ==== - import { web } from "conditions"; - \ No newline at end of file diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode.js b/tests/baselines/reference/bundlerConditionsExcludesNode.js deleted file mode 100644 index e6eb1fe883a18..0000000000000 --- a/tests/baselines/reference/bundlerConditionsExcludesNode.js +++ /dev/null @@ -1,35 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts] //// - -//// [package.json] -{ - "name": "conditions", - "version": "1.0.0", - "type": "module", - "main": "index.cjs", - "types": "index.d.cts", - "exports": { - ".": { - "node": "./index.node.js", - "default": "./index.web.js" - } - } - } - -//// [index.node.js] -export const node = 0; - -//// [index.node.d.ts] -export const node: number; - -//// [index.web.js] -export const web = 0; - -//// [index.web.d.ts] -export const web: number; - -//// [main.ts] -import { web } from "conditions"; - - -//// [main.js] -export {}; diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode.symbols b/tests/baselines/reference/bundlerConditionsExcludesNode.symbols deleted file mode 100644 index 4d4c9b1d57da4..0000000000000 --- a/tests/baselines/reference/bundlerConditionsExcludesNode.symbols +++ /dev/null @@ -1,14 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts] //// - -=== /node_modules/conditions/index.node.d.ts === -export const node: number; ->node : Symbol(node, Decl(index.node.d.ts, 0, 12)) - -=== /node_modules/conditions/index.web.d.ts === -export const web: number; ->web : Symbol(web, Decl(index.web.d.ts, 0, 12)) - -=== /main.ts === -import { web } from "conditions"; ->web : Symbol(web, Decl(main.ts, 0, 8)) - diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode.trace.json b/tests/baselines/reference/bundlerConditionsExcludesNode.trace.json deleted file mode 100644 index 0e5cd2eb567dc..0000000000000 --- a/tests/baselines/reference/bundlerConditionsExcludesNode.trace.json +++ /dev/null @@ -1,93 +0,0 @@ -[ - "======== Resolving module 'conditions' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Bundler'.", - "Resolving in CJS mode with conditions 'import', 'types'.", - "File '/package.json' does not exist.", - "Loading module 'conditions' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Found 'package.json' at '/node_modules/conditions/package.json'.", - "Entering conditional exports.", - "Saw non-matching condition 'node'.", - "Matched 'exports' condition 'default'.", - "Using 'exports' subpath '.' with target './index.web.js'.", - "File name '/node_modules/conditions/index.web.js' has a '.js' extension - stripping it.", - "File '/node_modules/conditions/index.web.ts' does not exist.", - "File '/node_modules/conditions/index.web.tsx' does not exist.", - "File '/node_modules/conditions/index.web.d.ts' exists - use it as a name resolution result.", - "Resolved under condition 'default'.", - "Exiting conditional exports.", - "Resolving real path for '/node_modules/conditions/index.web.d.ts', result '/node_modules/conditions/index.web.d.ts'.", - "======== Module name 'conditions' was successfully resolved to '/node_modules/conditions/index.web.d.ts' with Package ID 'conditions/index.web.d.ts@1.0.0'. ========", - "======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-es5'", - "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-es5'", - "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-es5' was not resolved. ========", - "======== Resolving module '@typescript/lib-decorators' from '/.src/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-decorators'", - "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-decorators'", - "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-decorators' was not resolved. ========", - "======== Resolving module '@typescript/lib-decorators/legacy' from '/.src/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", - "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", - "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", - "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-dom'", - "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-dom'", - "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-dom' was not resolved. ========", - "======== Resolving module '@typescript/lib-webworker/importscripts' from '/.src/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", - "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", - "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", - "======== Resolving module '@typescript/lib-scripthost' from '/.src/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-scripthost'", - "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-scripthost'", - "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-scripthost' was not resolved. ========" -] \ No newline at end of file diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode.types b/tests/baselines/reference/bundlerConditionsExcludesNode.types deleted file mode 100644 index 78f74b5c5367e..0000000000000 --- a/tests/baselines/reference/bundlerConditionsExcludesNode.types +++ /dev/null @@ -1,14 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/bundler/bundlerConditionsExcludesNode.ts] //// - -=== /node_modules/conditions/index.node.d.ts === -export const node: number; ->node : number - -=== /node_modules/conditions/index.web.d.ts === -export const web: number; ->web : number - -=== /main.ts === -import { web } from "conditions"; ->web : number - diff --git a/tests/baselines/reference/bundlerImportESM.js b/tests/baselines/reference/bundlerImportESM.js deleted file mode 100644 index 48e483322c215..0000000000000 --- a/tests/baselines/reference/bundlerImportESM.js +++ /dev/null @@ -1,21 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts] //// - -//// [esm.mts] -export const esm = 0; - -//// [not-actually-cjs.cts] -import { esm } from "./esm.mjs"; - -//// [package.json] -{ "type": "commonjs" } - -//// [still-not-cjs.ts] -import { esm } from "./esm.mjs"; - - -//// [esm.mjs] -export var esm = 0; -//// [not-actually-cjs.cjs] -export {}; -//// [still-not-cjs.js] -export {}; diff --git a/tests/baselines/reference/bundlerImportESM.symbols b/tests/baselines/reference/bundlerImportESM.symbols deleted file mode 100644 index d143f99424c05..0000000000000 --- a/tests/baselines/reference/bundlerImportESM.symbols +++ /dev/null @@ -1,14 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts] //// - -=== /esm.mts === -export const esm = 0; ->esm : Symbol(esm, Decl(esm.mts, 0, 12)) - -=== /not-actually-cjs.cts === -import { esm } from "./esm.mjs"; ->esm : Symbol(esm, Decl(not-actually-cjs.cts, 0, 8)) - -=== /still-not-cjs.ts === -import { esm } from "./esm.mjs"; ->esm : Symbol(esm, Decl(still-not-cjs.ts, 0, 8)) - diff --git a/tests/baselines/reference/bundlerImportESM.types b/tests/baselines/reference/bundlerImportESM.types deleted file mode 100644 index 5f0da560436b4..0000000000000 --- a/tests/baselines/reference/bundlerImportESM.types +++ /dev/null @@ -1,15 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts] //// - -=== /esm.mts === -export const esm = 0; ->esm : 0 ->0 : 0 - -=== /not-actually-cjs.cts === -import { esm } from "./esm.mjs"; ->esm : 0 - -=== /still-not-cjs.ts === -import { esm } from "./esm.mjs"; ->esm : 0 - diff --git a/tests/baselines/reference/bundlerNodeModules1.errors.txt b/tests/baselines/reference/bundlerNodeModules1.errors.txt deleted file mode 100644 index 69921a8ce1425..0000000000000 --- a/tests/baselines/reference/bundlerNodeModules1.errors.txt +++ /dev/null @@ -1,59 +0,0 @@ -error TS6504: File '/node_modules/dual/index.cjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? - The file is in the program because: - Root file specified for compilation -error TS6504: File '/node_modules/dual/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? - The file is in the program because: - Root file specified for compilation -/main.cts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. -/main.mts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. -/main.ts(1,15): error TS2305: Module '"dual"' has no exported member 'cjs'. - - -!!! error TS6504: File '/node_modules/dual/index.cjs' is a JavaScript file. Did you mean to enable the 'allowJs' option? -!!! error TS6504: The file is in the program because: -!!! error TS6504: Root file specified for compilation -!!! error TS6504: File '/node_modules/dual/index.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? -!!! error TS6504: The file is in the program because: -!!! error TS6504: Root file specified for compilation -==== /node_modules/dual/package.json (0 errors) ==== - { - "name": "dual", - "version": "1.0.0", - "type": "module", - "main": "index.cjs", - "types": "index.d.cts", - "exports": { - ".": { - "import": "./index.js", - "require": "./index.cjs" - } - } - } - -==== /node_modules/dual/index.js (0 errors) ==== - export const esm = 0; - -==== /node_modules/dual/index.d.ts (0 errors) ==== - export const esm: number; - -==== /node_modules/dual/index.cjs (0 errors) ==== - exports.cjs = 0; - -==== /node_modules/dual/index.d.cts (0 errors) ==== - export const cjs: number; - -==== /main.ts (1 errors) ==== - import { esm, cjs } from "dual"; - ~~~ -!!! error TS2305: Module '"dual"' has no exported member 'cjs'. - -==== /main.mts (1 errors) ==== - import { esm, cjs } from "dual"; - ~~~ -!!! error TS2305: Module '"dual"' has no exported member 'cjs'. - -==== /main.cts (1 errors) ==== - import { esm, cjs } from "dual"; - ~~~ -!!! error TS2305: Module '"dual"' has no exported member 'cjs'. - \ No newline at end of file diff --git a/tests/baselines/reference/bundlerNodeModules1.js b/tests/baselines/reference/bundlerNodeModules1.js deleted file mode 100644 index 1272b9f38f865..0000000000000 --- a/tests/baselines/reference/bundlerNodeModules1.js +++ /dev/null @@ -1,45 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts] //// - -//// [package.json] -{ - "name": "dual", - "version": "1.0.0", - "type": "module", - "main": "index.cjs", - "types": "index.d.cts", - "exports": { - ".": { - "import": "./index.js", - "require": "./index.cjs" - } - } -} - -//// [index.js] -export const esm = 0; - -//// [index.d.ts] -export const esm: number; - -//// [index.cjs] -exports.cjs = 0; - -//// [index.d.cts] -export const cjs: number; - -//// [main.ts] -import { esm, cjs } from "dual"; - -//// [main.mts] -import { esm, cjs } from "dual"; - -//// [main.cts] -import { esm, cjs } from "dual"; - - -//// [main.js] -export {}; -//// [main.mjs] -export {}; -//// [main.cjs] -export {}; diff --git a/tests/baselines/reference/bundlerNodeModules1.symbols b/tests/baselines/reference/bundlerNodeModules1.symbols deleted file mode 100644 index 04471bcc93196..0000000000000 --- a/tests/baselines/reference/bundlerNodeModules1.symbols +++ /dev/null @@ -1,25 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts] //// - -=== /node_modules/dual/index.d.ts === -export const esm: number; ->esm : Symbol(esm, Decl(index.d.ts, 0, 12)) - -=== /node_modules/dual/index.d.cts === -export const cjs: number; ->cjs : Symbol(cjs, Decl(index.d.cts, 0, 12)) - -=== /main.ts === -import { esm, cjs } from "dual"; ->esm : Symbol(esm, Decl(main.ts, 0, 8)) ->cjs : Symbol(cjs, Decl(main.ts, 0, 13)) - -=== /main.mts === -import { esm, cjs } from "dual"; ->esm : Symbol(esm, Decl(main.mts, 0, 8)) ->cjs : Symbol(cjs, Decl(main.mts, 0, 13)) - -=== /main.cts === -import { esm, cjs } from "dual"; ->esm : Symbol(esm, Decl(main.cts, 0, 8)) ->cjs : Symbol(cjs, Decl(main.cts, 0, 13)) - diff --git a/tests/baselines/reference/bundlerNodeModules1.trace.json b/tests/baselines/reference/bundlerNodeModules1.trace.json deleted file mode 100644 index b6d35e104cdf6..0000000000000 --- a/tests/baselines/reference/bundlerNodeModules1.trace.json +++ /dev/null @@ -1,98 +0,0 @@ -[ - "======== Resolving module 'dual' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Bundler'.", - "Resolving in CJS mode with conditions 'import', 'types'.", - "File '/package.json' does not exist.", - "Loading module 'dual' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Found 'package.json' at '/node_modules/dual/package.json'.", - "Entering conditional exports.", - "Matched 'exports' condition 'import'.", - "Using 'exports' subpath '.' with target './index.js'.", - "File name '/node_modules/dual/index.js' has a '.js' extension - stripping it.", - "File '/node_modules/dual/index.ts' does not exist.", - "File '/node_modules/dual/index.tsx' does not exist.", - "File '/node_modules/dual/index.d.ts' exists - use it as a name resolution result.", - "Resolved under condition 'import'.", - "Exiting conditional exports.", - "Resolving real path for '/node_modules/dual/index.d.ts', result '/node_modules/dual/index.d.ts'.", - "======== Module name 'dual' was successfully resolved to '/node_modules/dual/index.d.ts' with Package ID 'dual/index.d.ts@1.0.0'. ========", - "======== Resolving module 'dual' from '/main.mts'. ========", - "Resolution for module 'dual' was found in cache from location '/'.", - "======== Module name 'dual' was successfully resolved to '/node_modules/dual/index.d.ts' with Package ID 'dual/index.d.ts@1.0.0'. ========", - "======== Resolving module 'dual' from '/main.cts'. ========", - "Resolution for module 'dual' was found in cache from location '/'.", - "======== Module name 'dual' was successfully resolved to '/node_modules/dual/index.d.ts' with Package ID 'dual/index.d.ts@1.0.0'. ========", - "======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-es5'", - "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-es5'", - "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-es5' was not resolved. ========", - "======== Resolving module '@typescript/lib-decorators' from '/.src/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-decorators'", - "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-decorators'", - "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-decorators' was not resolved. ========", - "======== Resolving module '@typescript/lib-decorators/legacy' from '/.src/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", - "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", - "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", - "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-dom'", - "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-dom'", - "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-dom' was not resolved. ========", - "======== Resolving module '@typescript/lib-webworker/importscripts' from '/.src/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", - "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", - "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", - "======== Resolving module '@typescript/lib-scripthost' from '/.src/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-scripthost'", - "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-scripthost'", - "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-scripthost' was not resolved. ========" -] \ No newline at end of file diff --git a/tests/baselines/reference/bundlerNodeModules1.types b/tests/baselines/reference/bundlerNodeModules1.types deleted file mode 100644 index 4fd828baaa40b..0000000000000 --- a/tests/baselines/reference/bundlerNodeModules1.types +++ /dev/null @@ -1,25 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts] //// - -=== /node_modules/dual/index.d.ts === -export const esm: number; ->esm : number - -=== /node_modules/dual/index.d.cts === -export const cjs: number; ->cjs : number - -=== /main.ts === -import { esm, cjs } from "dual"; ->esm : number ->cjs : any - -=== /main.mts === -import { esm, cjs } from "dual"; ->esm : number ->cjs : any - -=== /main.cts === -import { esm, cjs } from "dual"; ->esm : number ->cjs : any - diff --git a/tests/baselines/reference/bundlerRelative1.errors.txt b/tests/baselines/reference/bundlerRelative1.errors.txt deleted file mode 100644 index 738eafa19304f..0000000000000 --- a/tests/baselines/reference/bundlerRelative1.errors.txt +++ /dev/null @@ -1,39 +0,0 @@ -/main.ts(4,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. -/main.ts(7,16): error TS2307: Cannot find module './redirect/index' or its corresponding type declarations. - - -==== /dir/index.ts (0 errors) ==== - export const x = 0; - -==== /redirect/package.json (0 errors) ==== - { "main": "../foo" } - -==== /foo/index.ts (0 errors) ==== - export const y = 0; - -==== /types/esm.d.ts (0 errors) ==== - declare const _: string; - export default _; - -==== /types/cjs.d.ts (0 errors) ==== - declare const _: string; - export = _; - -==== /main.ts (2 errors) ==== - import { x } from "./dir"; - import {} from "./dir/index"; - import {} from "./dir/index.js"; - import {} from "./dir/index.ts"; - ~~~~~~~~~~~~~~~~ -!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. - - import { y } from "./redirect"; - import {} from "./redirect/index"; - ~~~~~~~~~~~~~~~~~~ -!!! error TS2307: Cannot find module './redirect/index' or its corresponding type declarations. - - import a from "./types/esm"; - import * as esm from "./types/esm"; - import b from "./types/cjs"; - import * as cjs from "./types/cjs"; - \ No newline at end of file diff --git a/tests/baselines/reference/bundlerRelative1.js b/tests/baselines/reference/bundlerRelative1.js deleted file mode 100644 index ffc4d34643a30..0000000000000 --- a/tests/baselines/reference/bundlerRelative1.js +++ /dev/null @@ -1,40 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts] //// - -//// [index.ts] -export const x = 0; - -//// [package.json] -{ "main": "../foo" } - -//// [index.ts] -export const y = 0; - -//// [esm.d.ts] -declare const _: string; -export default _; - -//// [cjs.d.ts] -declare const _: string; -export = _; - -//// [main.ts] -import { x } from "./dir"; -import {} from "./dir/index"; -import {} from "./dir/index.js"; -import {} from "./dir/index.ts"; - -import { y } from "./redirect"; -import {} from "./redirect/index"; - -import a from "./types/esm"; -import * as esm from "./types/esm"; -import b from "./types/cjs"; -import * as cjs from "./types/cjs"; - - -//// [index.js] -export var x = 0; -//// [index.js] -export var y = 0; -//// [main.js] -export {}; diff --git a/tests/baselines/reference/bundlerRelative1.symbols b/tests/baselines/reference/bundlerRelative1.symbols deleted file mode 100644 index 41db8dac77e9c..0000000000000 --- a/tests/baselines/reference/bundlerRelative1.symbols +++ /dev/null @@ -1,49 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts] //// - -=== /dir/index.ts === -export const x = 0; ->x : Symbol(x, Decl(index.ts, 0, 12)) - -=== /foo/index.ts === -export const y = 0; ->y : Symbol(y, Decl(index.ts, 0, 12)) - -=== /types/esm.d.ts === -declare const _: string; ->_ : Symbol(_, Decl(esm.d.ts, 0, 13)) - -export default _; ->_ : Symbol(_, Decl(esm.d.ts, 0, 13)) - -=== /types/cjs.d.ts === -declare const _: string; ->_ : Symbol(_, Decl(cjs.d.ts, 0, 13)) - -export = _; ->_ : Symbol(_, Decl(cjs.d.ts, 0, 13)) - -=== /main.ts === -import { x } from "./dir"; ->x : Symbol(x, Decl(main.ts, 0, 8)) - -import {} from "./dir/index"; -import {} from "./dir/index.js"; -import {} from "./dir/index.ts"; - -import { y } from "./redirect"; ->y : Symbol(y, Decl(main.ts, 5, 8)) - -import {} from "./redirect/index"; - -import a from "./types/esm"; ->a : Symbol(a, Decl(main.ts, 8, 6)) - -import * as esm from "./types/esm"; ->esm : Symbol(esm, Decl(main.ts, 9, 6)) - -import b from "./types/cjs"; ->b : Symbol(b, Decl(main.ts, 10, 6)) - -import * as cjs from "./types/cjs"; ->cjs : Symbol(cjs, Decl(main.ts, 11, 6)) - diff --git a/tests/baselines/reference/bundlerRelative1.trace.json b/tests/baselines/reference/bundlerRelative1.trace.json deleted file mode 100644 index c90d2d5fcf7b5..0000000000000 --- a/tests/baselines/reference/bundlerRelative1.trace.json +++ /dev/null @@ -1,162 +0,0 @@ -[ - "======== Resolving module './dir' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Bundler'.", - "Resolving in CJS mode with conditions 'import', 'types'.", - "Loading module as file / folder, candidate module location '/dir', target file types: TypeScript, JavaScript, Declaration, JSON.", - "File '/dir.ts' does not exist.", - "File '/dir.tsx' does not exist.", - "File '/dir.d.ts' does not exist.", - "File '/dir.js' does not exist.", - "File '/dir.jsx' does not exist.", - "File '/dir/package.json' does not exist.", - "File '/dir/index.ts' exists - use it as a name resolution result.", - "======== Module name './dir' was successfully resolved to '/dir/index.ts'. ========", - "======== Resolving module './dir/index' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Bundler'.", - "Resolving in CJS mode with conditions 'import', 'types'.", - "Loading module as file / folder, candidate module location '/dir/index', target file types: TypeScript, JavaScript, Declaration, JSON.", - "File '/dir/index.ts' exists - use it as a name resolution result.", - "======== Module name './dir/index' was successfully resolved to '/dir/index.ts'. ========", - "======== Resolving module './dir/index.js' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Bundler'.", - "Resolving in CJS mode with conditions 'import', 'types'.", - "Loading module as file / folder, candidate module location '/dir/index.js', target file types: TypeScript, JavaScript, Declaration, JSON.", - "File name '/dir/index.js' has a '.js' extension - stripping it.", - "File '/dir/index.ts' exists - use it as a name resolution result.", - "======== Module name './dir/index.js' was successfully resolved to '/dir/index.ts'. ========", - "======== Resolving module './dir/index.ts' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Bundler'.", - "Resolving in CJS mode with conditions 'import', 'types'.", - "Loading module as file / folder, candidate module location '/dir/index.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", - "File name '/dir/index.ts' has a '.ts' extension - stripping it.", - "File '/dir/index.ts' exists - use it as a name resolution result.", - "======== Module name './dir/index.ts' was successfully resolved to '/dir/index.ts'. ========", - "======== Resolving module './redirect' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Bundler'.", - "Resolving in CJS mode with conditions 'import', 'types'.", - "Loading module as file / folder, candidate module location '/redirect', target file types: TypeScript, JavaScript, Declaration, JSON.", - "File '/redirect.ts' does not exist.", - "File '/redirect.tsx' does not exist.", - "File '/redirect.d.ts' does not exist.", - "File '/redirect.js' does not exist.", - "File '/redirect.jsx' does not exist.", - "Found 'package.json' at '/redirect/package.json'.", - "'package.json' does not have a 'typesVersions' field.", - "'package.json' does not have a 'typings' field.", - "'package.json' does not have a 'types' field.", - "'package.json' has 'main' field '../foo' that references '/foo'.", - "File '/foo' does not exist.", - "Loading module as file / folder, candidate module location '/foo', target file types: TypeScript, JavaScript, Declaration, JSON.", - "File '/foo.ts' does not exist.", - "File '/foo.tsx' does not exist.", - "File '/foo.d.ts' does not exist.", - "File '/foo.js' does not exist.", - "File '/foo.jsx' does not exist.", - "File '/foo/index.ts' exists - use it as a name resolution result.", - "======== Module name './redirect' was successfully resolved to '/foo/index.ts'. ========", - "======== Resolving module './redirect/index' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Bundler'.", - "Resolving in CJS mode with conditions 'import', 'types'.", - "Loading module as file / folder, candidate module location '/redirect/index', target file types: TypeScript, JavaScript, Declaration, JSON.", - "File '/redirect/index.ts' does not exist.", - "File '/redirect/index.tsx' does not exist.", - "File '/redirect/index.d.ts' does not exist.", - "File '/redirect/index.js' does not exist.", - "File '/redirect/index.jsx' does not exist.", - "Directory '/redirect/index' does not exist, skipping all lookups in it.", - "======== Module name './redirect/index' was not resolved. ========", - "======== Resolving module './types/esm' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Bundler'.", - "Resolving in CJS mode with conditions 'import', 'types'.", - "Loading module as file / folder, candidate module location '/types/esm', target file types: TypeScript, JavaScript, Declaration, JSON.", - "File '/types/esm.ts' does not exist.", - "File '/types/esm.tsx' does not exist.", - "File '/types/esm.d.ts' exists - use it as a name resolution result.", - "======== Module name './types/esm' was successfully resolved to '/types/esm.d.ts'. ========", - "======== Resolving module './types/cjs' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Bundler'.", - "Resolving in CJS mode with conditions 'import', 'types'.", - "Loading module as file / folder, candidate module location '/types/cjs', target file types: TypeScript, JavaScript, Declaration, JSON.", - "File '/types/cjs.ts' does not exist.", - "File '/types/cjs.tsx' does not exist.", - "File '/types/cjs.d.ts' exists - use it as a name resolution result.", - "======== Module name './types/cjs' was successfully resolved to '/types/cjs.d.ts'. ========", - "======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-es5'", - "Directory '/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-es5'", - "Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Directory '/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-es5' was not resolved. ========", - "======== Resolving module '@typescript/lib-decorators' from '/.src/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-decorators'", - "Directory '/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-decorators'", - "Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Directory '/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-decorators' was not resolved. ========", - "======== Resolving module '@typescript/lib-decorators/legacy' from '/.src/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", - "Directory '/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-decorators/legacy'", - "Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Directory '/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", - "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-dom'", - "Directory '/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-dom'", - "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Directory '/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-dom' was not resolved. ========", - "======== Resolving module '@typescript/lib-webworker/importscripts' from '/.src/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", - "Directory '/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-webworker/importscripts'", - "Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Directory '/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", - "======== Resolving module '@typescript/lib-scripthost' from '/.src/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", - "Explicitly specified module resolution kind: 'Node10'.", - "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", - "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-scripthost'", - "Directory '/node_modules' does not exist, skipping all lookups in it.", - "Scoped package detected, looking in 'typescript__lib-scripthost'", - "Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", - "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", - "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "Directory '/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-scripthost' was not resolved. ========" -] \ No newline at end of file diff --git a/tests/baselines/reference/bundlerRelative1.types b/tests/baselines/reference/bundlerRelative1.types deleted file mode 100644 index 50663cfe46ead..0000000000000 --- a/tests/baselines/reference/bundlerRelative1.types +++ /dev/null @@ -1,51 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts] //// - -=== /dir/index.ts === -export const x = 0; ->x : 0 ->0 : 0 - -=== /foo/index.ts === -export const y = 0; ->y : 0 ->0 : 0 - -=== /types/esm.d.ts === -declare const _: string; ->_ : string - -export default _; ->_ : string - -=== /types/cjs.d.ts === -declare const _: string; ->_ : string - -export = _; ->_ : string - -=== /main.ts === -import { x } from "./dir"; ->x : 0 - -import {} from "./dir/index"; -import {} from "./dir/index.js"; -import {} from "./dir/index.ts"; - -import { y } from "./redirect"; ->y : 0 - -import {} from "./redirect/index"; - -import a from "./types/esm"; ->a : string - -import * as esm from "./types/esm"; ->esm : typeof esm - -import b from "./types/cjs"; ->b : string - -import * as cjs from "./types/cjs"; ->cjs : string - diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt b/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt deleted file mode 100644 index 281834153b864..0000000000000 --- a/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt +++ /dev/null @@ -1,43 +0,0 @@ -error TS2468: Cannot find global value 'Promise'. -/main.ts(2,1): error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. -/main.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. -/mainJs.js(2,1): error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. - - -!!! error TS2468: Cannot find global value 'Promise'. -==== /node_modules/@types/node/index.d.ts (0 errors) ==== - declare var require: (...args: any[]) => any; - -==== /ambient.d.ts (0 errors) ==== - declare module "fs" { - export function readFileSync(path: string, encoding?: string): string; - } - declare module "path" { - import fs = require("fs"); // ok - namespace path { - export const sep: string; - } - export = path; // ok - } - -==== /mainJs.js (1 errors) ==== - import {} from "./a"; - import("./a"); - ~~~~~~~~~~~~~ -!!! error TS2712: A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. - const _ = require("./a"); - _.a; // any - -==== /main.ts (2 errors) ==== - import {} from "./a"; - import _ = require("./a"); // Error - ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. - export = {}; // Error - ~~~~~~~~~~~~ -!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. - export {}; - -==== /a.ts (0 errors) ==== - export const a = "a"; - \ No newline at end of file diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions.js b/tests/baselines/reference/bundlerSyntaxRestrictions.js deleted file mode 100644 index 70e9b2b388b35..0000000000000 --- a/tests/baselines/reference/bundlerSyntaxRestrictions.js +++ /dev/null @@ -1,42 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts] //// - -//// [index.d.ts] -declare var require: (...args: any[]) => any; - -//// [ambient.d.ts] -declare module "fs" { - export function readFileSync(path: string, encoding?: string): string; -} -declare module "path" { - import fs = require("fs"); // ok - namespace path { - export const sep: string; - } - export = path; // ok -} - -//// [mainJs.js] -import {} from "./a"; -import("./a"); -const _ = require("./a"); -_.a; // any - -//// [main.ts] -import {} from "./a"; -import _ = require("./a"); // Error -export = {}; // Error -export {}; - -//// [a.ts] -export const a = "a"; - - -//// [a.js] -export var a = "a"; -//// [mainJs.js] -import("./a"); -var _ = require("./a"); -_.a; // any -export {}; -//// [main.js] -export {}; diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions.symbols b/tests/baselines/reference/bundlerSyntaxRestrictions.symbols deleted file mode 100644 index 3de5d0c81acd7..0000000000000 --- a/tests/baselines/reference/bundlerSyntaxRestrictions.symbols +++ /dev/null @@ -1,58 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts] //// - -=== /node_modules/@types/node/index.d.ts === -declare var require: (...args: any[]) => any; ->require : Symbol(require, Decl(index.d.ts, 0, 11)) ->args : Symbol(args, Decl(index.d.ts, 0, 22)) - -=== /ambient.d.ts === -declare module "fs" { ->"fs" : Symbol("fs", Decl(ambient.d.ts, 0, 0)) - - export function readFileSync(path: string, encoding?: string): string; ->readFileSync : Symbol(readFileSync, Decl(ambient.d.ts, 0, 21)) ->path : Symbol(path, Decl(ambient.d.ts, 1, 33)) ->encoding : Symbol(encoding, Decl(ambient.d.ts, 1, 46)) -} -declare module "path" { ->"path" : Symbol("path", Decl(ambient.d.ts, 2, 1)) - - import fs = require("fs"); // ok ->fs : Symbol(fs, Decl(ambient.d.ts, 3, 23)) - - namespace path { ->path : Symbol(path, Decl(ambient.d.ts, 4, 30)) - - export const sep: string; ->sep : Symbol(sep, Decl(ambient.d.ts, 6, 20)) - } - export = path; // ok ->path : Symbol(path, Decl(ambient.d.ts, 4, 30)) -} - -=== /mainJs.js === -import {} from "./a"; -import("./a"); ->"./a" : Symbol(_, Decl(a.ts, 0, 0)) - -const _ = require("./a"); ->_ : Symbol(_, Decl(mainJs.js, 2, 5)) ->require : Symbol(require, Decl(index.d.ts, 0, 11)) - -_.a; // any ->_.a : Symbol(_.a, Decl(a.ts, 0, 12)) ->_ : Symbol(_, Decl(mainJs.js, 2, 5)) ->a : Symbol(_.a, Decl(a.ts, 0, 12)) - -=== /main.ts === -import {} from "./a"; -import _ = require("./a"); // Error ->_ : Symbol(_, Decl(main.ts, 0, 21)) - -export = {}; // Error -export {}; - -=== /a.ts === -export const a = "a"; ->a : Symbol(a, Decl(a.ts, 0, 12)) - diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions.types b/tests/baselines/reference/bundlerSyntaxRestrictions.types deleted file mode 100644 index c2809e3d74576..0000000000000 --- a/tests/baselines/reference/bundlerSyntaxRestrictions.types +++ /dev/null @@ -1,64 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts] //// - -=== /node_modules/@types/node/index.d.ts === -declare var require: (...args: any[]) => any; ->require : (...args: any[]) => any ->args : any[] - -=== /ambient.d.ts === -declare module "fs" { ->"fs" : typeof import("fs") - - export function readFileSync(path: string, encoding?: string): string; ->readFileSync : (path: string, encoding?: string) => string ->path : string ->encoding : string -} -declare module "path" { ->"path" : typeof import("path") - - import fs = require("fs"); // ok ->fs : typeof fs - - namespace path { ->path : typeof path - - export const sep: string; ->sep : string - } - export = path; // ok ->path : typeof path -} - -=== /mainJs.js === -import {} from "./a"; -import("./a"); ->import("./a") : Promise ->"./a" : "./a" - -const _ = require("./a"); ->_ : typeof _ ->require("./a") : typeof _ ->require : (...args: any[]) => any ->"./a" : "./a" - -_.a; // any ->_.a : "a" ->_ : typeof _ ->a : "a" - -=== /main.ts === -import {} from "./a"; -import _ = require("./a"); // Error ->_ : typeof _ - -export = {}; // Error ->{} : {} - -export {}; - -=== /a.ts === -export const a = "a"; ->a : "a" ->"a" : "a" - From c25e1cc6232877d05fc5f24300ebea06ef2cde4e Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 15 Dec 2023 10:21:28 -0800 Subject: [PATCH 18/31] Fix getSymbolAtLocation for bundler --- src/compiler/checker.ts | 2 +- .../ambientRequireFunction(module=preserve).symbols | 1 + .../bundlerSyntaxRestrictions(module=esnext).symbols | 1 + .../bundlerSyntaxRestrictions(module=preserve).symbols | 1 + tests/baselines/reference/modulePreserve2.symbols | 1 + tests/baselines/reference/modulePreserve4.symbols | 7 +++++++ 6 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 457a12e1019c4..aab127c1d5816 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -47315,7 +47315,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if ( (isExternalModuleImportEqualsDeclaration(node.parent.parent) && getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || ((node.parent.kind === SyntaxKind.ImportDeclaration || node.parent.kind === SyntaxKind.ExportDeclaration) && (node.parent as ImportDeclaration).moduleSpecifier === node) || - ((isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Bundler && isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ false)) || isImportCall(node.parent)) || + ((isInJSFile(node) && isRequireCall(node.parent, /*requireStringLiteralLikeArgument*/ false)) || isImportCall(node.parent)) || (isLiteralTypeNode(node.parent) && isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent) ) { return resolveExternalModuleName(node, node as LiteralExpression, ignoreErrors); diff --git a/tests/baselines/reference/ambientRequireFunction(module=preserve).symbols b/tests/baselines/reference/ambientRequireFunction(module=preserve).symbols index cd4e7baad49a7..c9c5a0cf27954 100644 --- a/tests/baselines/reference/ambientRequireFunction(module=preserve).symbols +++ b/tests/baselines/reference/ambientRequireFunction(module=preserve).symbols @@ -6,6 +6,7 @@ const fs = require("fs"); >fs : Symbol(fs, Decl(app.js, 2, 5)) >require : Symbol(require, Decl(node.d.ts, 0, 0)) +>"fs" : Symbol(fs, Decl(node.d.ts, 0, 50)) const text = fs.readFileSync("/a/b/c"); >text : Symbol(text, Decl(app.js, 3, 5)) diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).symbols b/tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).symbols index 1a39f0bc05dc4..9f5246891c63c 100644 --- a/tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).symbols +++ b/tests/baselines/reference/bundlerSyntaxRestrictions(module=esnext).symbols @@ -38,6 +38,7 @@ import("./a"); const _ = require("./a"); >_ : Symbol(_, Decl(mainJs.js, 2, 5)) >require : Symbol(require, Decl(index.d.ts, 0, 11)) +>"./a" : Symbol(_, Decl(a.ts, 0, 0)) _.a; // any >_.a : Symbol(_.a, Decl(a.ts, 0, 12)) diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).symbols b/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).symbols index 1a39f0bc05dc4..9f5246891c63c 100644 --- a/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).symbols +++ b/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).symbols @@ -38,6 +38,7 @@ import("./a"); const _ = require("./a"); >_ : Symbol(_, Decl(mainJs.js, 2, 5)) >require : Symbol(require, Decl(index.d.ts, 0, 11)) +>"./a" : Symbol(_, Decl(a.ts, 0, 0)) _.a; // any >_.a : Symbol(_.a, Decl(a.ts, 0, 12)) diff --git a/tests/baselines/reference/modulePreserve2.symbols b/tests/baselines/reference/modulePreserve2.symbols index 682d40164272d..57e9232fef152 100644 --- a/tests/baselines/reference/modulePreserve2.symbols +++ b/tests/baselines/reference/modulePreserve2.symbols @@ -7,6 +7,7 @@ import { esm } from "dep"; const cjs = require("dep"); >cjs : Symbol(cjs, Decl(main.js, 1, 5)) >require : Symbol(require) +>"dep" : Symbol("/node_modules/dep/require", Decl(require.d.ts, 0, 0)) === /node_modules/dep/import.d.mts === export const esm: "esm"; diff --git a/tests/baselines/reference/modulePreserve4.symbols b/tests/baselines/reference/modulePreserve4.symbols index 35de69066cf48..fec5b053ac454 100644 --- a/tests/baselines/reference/modulePreserve4.symbols +++ b/tests/baselines/reference/modulePreserve4.symbols @@ -179,6 +179,7 @@ import a1 = require("./a"); // Error in JS const a2 = require("./a"); // { x: 0 } >a2 : Symbol(a2, Decl(main3.cjs, 2, 5)) >require : Symbol(require) +>"./a" : Symbol(a1, Decl(a.js, 0, 0)) import b1 from "./b"; // 0 >b1 : Symbol(b1, Decl(main3.cjs, 4, 6)) @@ -186,6 +187,7 @@ import b1 from "./b"; // 0 const b2 = require("./b"); // { default: 0 } >b2 : Symbol(b2, Decl(main3.cjs, 5, 5)) >require : Symbol(require) +>"./b" : Symbol(b2, Decl(b.ts, 0, 0)) import c1 from "./c"; // { default: [Function: default] } >c1 : Symbol(c1, Decl(main3.cjs, 7, 6)) @@ -193,6 +195,7 @@ import c1 from "./c"; // { default: [Function: default] } const c2 = require("./c"); // { default: [Function: default] } >c2 : Symbol(c2, Decl(main3.cjs, 8, 5)) >require : Symbol(require) +>"./c" : Symbol("/c", Decl(c.ts, 0, 0)) import d1 from "./d"; // [Function: default] >d1 : Symbol(d1, Decl(main3.cjs, 9, 6)) @@ -200,6 +203,7 @@ import d1 from "./d"; // [Function: default] const d2 = require("./d"); // [Function: default] >d2 : Symbol(d2, Decl(main3.cjs, 10, 5)) >require : Symbol(require) +>"./d" : Symbol("/d", Decl(d.ts, 0, 0)) import e1 from "./e.mjs"; // 0 >e1 : Symbol(e1, Decl(main3.cjs, 11, 6)) @@ -207,6 +211,7 @@ import e1 from "./e.mjs"; // 0 const e2 = require("./e.mjs"); // 0 >e2 : Symbol(e2, Decl(main3.cjs, 12, 5)) >require : Symbol(require) +>"./e.mjs" : Symbol("/e", Decl(e.mts, 0, 0)) import f1 from "./f.cjs"; // 0 >f1 : Symbol(f1, Decl(main3.cjs, 13, 6)) @@ -214,6 +219,7 @@ import f1 from "./f.cjs"; // 0 const f2 = require("./f.cjs"); // { default: 0 } >f2 : Symbol(f2, Decl(main3.cjs, 14, 5)) >require : Symbol(require) +>"./f.cjs" : Symbol(f2, Decl(f.cts, 0, 0)) import g1 from "./g"; // { default: 0 } >g1 : Symbol(g1, Decl(main3.cjs, 16, 6)) @@ -221,6 +227,7 @@ import g1 from "./g"; // { default: 0 } const g2 = require("./g"); // { default: 0 } >g2 : Symbol(g2, Decl(main3.cjs, 17, 5)) >require : Symbol(require) +>"./g" : Symbol(g1, Decl(g.js, 0, 0)) === /dummy.ts === From 7f7038572275ce08152e75514de07e70b740cc80 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 15 Dec 2023 10:44:29 -0800 Subject: [PATCH 19/31] Remove extraneous `export {}` emit from --module preserve --- .../transformers/module/esnextAnd2015.ts | 2 +- ...ConditionsExcludesNode(module=preserve).js | 1 - .../bundlerImportESM(module=preserve).js | 2 - .../bundlerNodeModules1(module=preserve).js | 3 - .../bundlerRelative1(module=preserve).js | 1 - ...dlerSyntaxRestrictions(module=preserve).js | 2 - tests/baselines/reference/modulePreserve1.js | 1 - tests/baselines/reference/modulePreserve4.js | 208 ++++++++++++++++++ tests/cases/compiler/modulePreserve4.ts | 3 +- 9 files changed, 211 insertions(+), 12 deletions(-) create mode 100644 tests/baselines/reference/modulePreserve4.js diff --git a/src/compiler/transformers/module/esnextAnd2015.ts b/src/compiler/transformers/module/esnextAnd2015.ts index 59192fd1f3def..12c8fd87136ed 100644 --- a/src/compiler/transformers/module/esnextAnd2015.ts +++ b/src/compiler/transformers/module/esnextAnd2015.ts @@ -89,7 +89,7 @@ export function transformECMAScriptModule(context: TransformationContext): (x: S setTextRange(factory.createNodeArray(insertStatementsAfterCustomPrologue(result.statements.slice(), importRequireStatements)), result.statements), ); } - if (!isExternalModule(node) || some(result.statements, isExternalModuleIndicator)) { + if (!isExternalModule(node) || getEmitModuleKind(compilerOptions) === ModuleKind.Preserve || some(result.statements, isExternalModuleIndicator)) { return result; } return factory.updateSourceFile( diff --git a/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).js b/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).js index e6eb1fe883a18..6ec6fb5080f01 100644 --- a/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).js +++ b/tests/baselines/reference/bundlerConditionsExcludesNode(module=preserve).js @@ -32,4 +32,3 @@ import { web } from "conditions"; //// [main.js] -export {}; diff --git a/tests/baselines/reference/bundlerImportESM(module=preserve).js b/tests/baselines/reference/bundlerImportESM(module=preserve).js index 48e483322c215..ed877b14da7f0 100644 --- a/tests/baselines/reference/bundlerImportESM(module=preserve).js +++ b/tests/baselines/reference/bundlerImportESM(module=preserve).js @@ -16,6 +16,4 @@ import { esm } from "./esm.mjs"; //// [esm.mjs] export var esm = 0; //// [not-actually-cjs.cjs] -export {}; //// [still-not-cjs.js] -export {}; diff --git a/tests/baselines/reference/bundlerNodeModules1(module=preserve).js b/tests/baselines/reference/bundlerNodeModules1(module=preserve).js index 1272b9f38f865..6ba7482a64733 100644 --- a/tests/baselines/reference/bundlerNodeModules1(module=preserve).js +++ b/tests/baselines/reference/bundlerNodeModules1(module=preserve).js @@ -38,8 +38,5 @@ import { esm, cjs } from "dual"; //// [main.js] -export {}; //// [main.mjs] -export {}; //// [main.cjs] -export {}; diff --git a/tests/baselines/reference/bundlerRelative1(module=preserve).js b/tests/baselines/reference/bundlerRelative1(module=preserve).js index ffc4d34643a30..28c5ac26a7df3 100644 --- a/tests/baselines/reference/bundlerRelative1(module=preserve).js +++ b/tests/baselines/reference/bundlerRelative1(module=preserve).js @@ -37,4 +37,3 @@ export var x = 0; //// [index.js] export var y = 0; //// [main.js] -export {}; diff --git a/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).js b/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).js index c28b7f67b52ba..9a8cd79f58eec 100644 --- a/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).js +++ b/tests/baselines/reference/bundlerSyntaxRestrictions(module=preserve).js @@ -37,7 +37,5 @@ export var a = "a"; import("./a"); var _ = require("./a"); _.a; // any -export {}; //// [main.js] module.exports = {}; -export {}; diff --git a/tests/baselines/reference/modulePreserve1.js b/tests/baselines/reference/modulePreserve1.js index 8cb4e5237baaf..f545b031d7d75 100644 --- a/tests/baselines/reference/modulePreserve1.js +++ b/tests/baselines/reference/modulePreserve1.js @@ -18,7 +18,6 @@ export class A { //// [b.js] module.exports = class B { }; -export {}; //// [main.js] import { A } from "./a"; const B = require("./b"); diff --git a/tests/baselines/reference/modulePreserve4.js b/tests/baselines/reference/modulePreserve4.js new file mode 100644 index 0000000000000..db61038d0e3d6 --- /dev/null +++ b/tests/baselines/reference/modulePreserve4.js @@ -0,0 +1,208 @@ +//// [tests/cases/compiler/modulePreserve4.ts] //// + +//// [a.js] +export const x = 0; +module.exports.y = 0; // Error + +//// [b.ts] +export default 0; + +//// [c.ts] +export = { + default: function() {} +}; + +//// [d.ts] +export = function() {}; + +//// [e.mts] +export = 0; + +//// [f.cts] +export default 0; + +//// [g.js] +exports.default = 0; + +//// [main1.ts] +import { x, y } from "./a"; // No y +import a1 = require("./a"); // { x: 0 } +const a2 = require("./a"); // Error in TS + +import b1 from "./b"; // 0 +import b2 = require("./b"); // { default: 0 } +b2.default; + +import c1 from "./c"; // { default: [Function: default] } +import c2 = require("./c"); // { default: [Function: default] } +c2.default; +import d1 from "./d"; // [Function: default] +import d2 = require("./d"); // [Function: default] +d2(); +d2.default(); // Error +import e1 from "./e.mjs"; // 0 +import e2 = require("./e.mjs"); // 0 +import f1 from "./f.cjs"; // 0 +import f2 = require("./f.cjs"); // { default: 0 } +f2.default; + +import g1 from "./g"; // { default: 0 } +g1.default; +import g2 = require("./g"); // { default: 0 } +g2.default; + +//// [main2.mts] +import { x, y } from "./a"; // No y +import a1 = require("./a"); // { x: 0 } +a1.x; +a1.default.x; // Arguably should exist but doesn't +const a2 = require("./a"); // Error in TS + +import b1 from "./b"; // 0 +import b2 = require("./b"); // { default: 0 } + +import c1 from "./c"; // { default: [Function: default] } +import c2 = require("./c"); // { default: [Function: default] } +import d1 from "./d"; // [Function: default] +import d2 = require("./d"); // [Function: default] +import e1 from "./e.mjs"; // 0 +import e2 = require("./e.mjs"); // 0 +import f1 from "./f.cjs"; // 0 +import f2 = require("./f.cjs"); // { default: 0 } + +import g1 from "./g"; // { default: 0 } +import g2 = require("./g"); // { default: 0 } + +//// [main3.cjs] +import { x, y } from "./a"; // No y +import a1 = require("./a"); // Error in JS +const a2 = require("./a"); // { x: 0 } + +import b1 from "./b"; // 0 +const b2 = require("./b"); // { default: 0 } + +import c1 from "./c"; // { default: [Function: default] } +const c2 = require("./c"); // { default: [Function: default] } +import d1 from "./d"; // [Function: default] +const d2 = require("./d"); // [Function: default] +import e1 from "./e.mjs"; // 0 +const e2 = require("./e.mjs"); // 0 +import f1 from "./f.cjs"; // 0 +const f2 = require("./f.cjs"); // { default: 0 } + +import g1 from "./g"; // { default: 0 } +const g2 = require("./g"); // { default: 0 } + +//// [dummy.ts] +export {}; // Silly test harness + + +//// [a.js] +export const x = 0; +module.exports.y = 0; // Error +//// [b.js] +export default 0; +//// [c.js] +module.exports = { + default: function () { } +}; +//// [d.js] +module.exports = function () { }; +//// [e.mjs] +module.exports = 0; +//// [f.cjs] +export default 0; +//// [g.js] +"use strict"; +exports.default = 0; +//// [main1.js] +import { x, y } from "./a"; // No y +const a1 = require("./a"); // { x: 0 } +const a2 = require("./a"); // Error in TS +import b1 from "./b"; // 0 +const b2 = require("./b"); // { default: 0 } +b2.default; +import c1 from "./c"; // { default: [Function: default] } +const c2 = require("./c"); // { default: [Function: default] } +c2.default; +import d1 from "./d"; // [Function: default] +const d2 = require("./d"); // [Function: default] +d2(); +d2.default(); // Error +import e1 from "./e.mjs"; // 0 +const e2 = require("./e.mjs"); // 0 +import f1 from "./f.cjs"; // 0 +const f2 = require("./f.cjs"); // { default: 0 } +f2.default; +import g1 from "./g"; // { default: 0 } +g1.default; +const g2 = require("./g"); // { default: 0 } +g2.default; +//// [main2.mjs] +import { x, y } from "./a"; // No y +const a1 = require("./a"); // { x: 0 } +a1.x; +a1.default.x; // Arguably should exist but doesn't +const a2 = require("./a"); // Error in TS +import b1 from "./b"; // 0 +const b2 = require("./b"); // { default: 0 } +import c1 from "./c"; // { default: [Function: default] } +const c2 = require("./c"); // { default: [Function: default] } +import d1 from "./d"; // [Function: default] +const d2 = require("./d"); // [Function: default] +import e1 from "./e.mjs"; // 0 +const e2 = require("./e.mjs"); // 0 +import f1 from "./f.cjs"; // 0 +const f2 = require("./f.cjs"); // { default: 0 } +import g1 from "./g"; // { default: 0 } +const g2 = require("./g"); // { default: 0 } +//// [main3.cjs] +import { x, y } from "./a"; // No y +const a1 = require("./a"); // Error in JS +const a2 = require("./a"); // { x: 0 } +import b1 from "./b"; // 0 +const b2 = require("./b"); // { default: 0 } +import c1 from "./c"; // { default: [Function: default] } +const c2 = require("./c"); // { default: [Function: default] } +import d1 from "./d"; // [Function: default] +const d2 = require("./d"); // [Function: default] +import e1 from "./e.mjs"; // 0 +const e2 = require("./e.mjs"); // 0 +import f1 from "./f.cjs"; // 0 +const f2 = require("./f.cjs"); // { default: 0 } +import g1 from "./g"; // { default: 0 } +const g2 = require("./g"); // { default: 0 } +//// [dummy.js] +export {}; // Silly test harness + + +//// [a.d.ts] +export const x: 0; +//// [b.d.ts] +declare const _default: 0; +export default _default; +//// [c.d.ts] +declare const _default: { + default: () => void; +}; +export = _default; +//// [d.d.ts] +declare const _default: () => void; +export = _default; +//// [e.d.mts] +declare const _default: 0; +export = _default; +//// [f.d.cts] +declare const _default: 0; +export default _default; +//// [g.d.ts] +declare const _default: 0; +export default _default; +//// [main1.d.ts] +export {}; +//// [main2.d.mts] +export {}; +//// [main3.d.cts] +export {}; +//// [dummy.d.ts] +export {}; diff --git a/tests/cases/compiler/modulePreserve4.ts b/tests/cases/compiler/modulePreserve4.ts index 6e5c0e6385047..5bc59e2d1b495 100644 --- a/tests/cases/compiler/modulePreserve4.ts +++ b/tests/cases/compiler/modulePreserve4.ts @@ -2,7 +2,8 @@ // @target: esnext // @verbatimModuleSyntax: true // @checkJs: true -// @noEmit: true +// @outDir: dist +// @declaration: true // @strict: true // @Filename: /a.js From 94bd2eee4a9a4dd6f3ab04c746a8b72e8bcd294f Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 15 Dec 2023 14:49:52 -0800 Subject: [PATCH 20/31] Add dynamic import to tests --- .../reference/modulePreserve4.errors.txt | 9 ++- tests/baselines/reference/modulePreserve4.js | 13 ++++ .../reference/modulePreserve4.symbols | 65 +++++++++++++------ .../baselines/reference/modulePreserve4.types | 34 ++++++++++ tests/cases/compiler/modulePreserve4.ts | 7 ++ 5 files changed, 108 insertions(+), 20 deletions(-) diff --git a/tests/baselines/reference/modulePreserve4.errors.txt b/tests/baselines/reference/modulePreserve4.errors.txt index 773605f0568c7..fa8baeb0c390d 100644 --- a/tests/baselines/reference/modulePreserve4.errors.txt +++ b/tests/baselines/reference/modulePreserve4.errors.txt @@ -1,7 +1,7 @@ /a.js(2,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. /main1.ts(1,13): error TS2305: Module '"./a"' has no exported member 'y'. /main1.ts(3,12): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. -/main1.ts(15,4): error TS2339: Property 'default' does not exist on type '() => void'. +/main1.ts(19,4): error TS2339: Property 'default' does not exist on type '() => void'. /main2.mts(1,13): error TS2305: Module '"./a"' has no exported member 'y'. /main2.mts(4,4): error TS2339: Property 'default' does not exist on type 'typeof import("/a")'. /main2.mts(5,12): error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. @@ -43,10 +43,14 @@ const a2 = require("./a"); // Error in TS ~~~~~~~ !!! error TS2580: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. + const a3 = await import("./a"); // { x: 0 } + a3.x; import b1 from "./b"; // 0 import b2 = require("./b"); // { default: 0 } b2.default; + const b3 = await import("./b"); // { default: 0 } + b3.default; import c1 from "./c"; // { default: [Function: default] } import c2 = require("./c"); // { default: [Function: default] } @@ -57,6 +61,9 @@ d2.default(); // Error ~~~~~~~ !!! error TS2339: Property 'default' does not exist on type '() => void'. + const d3 = await import("./d"); // { default: [Function: default] } + d3.default(); + import e1 from "./e.mjs"; // 0 import e2 = require("./e.mjs"); // 0 import f1 from "./f.cjs"; // 0 diff --git a/tests/baselines/reference/modulePreserve4.js b/tests/baselines/reference/modulePreserve4.js index db61038d0e3d6..e5e009d628b0c 100644 --- a/tests/baselines/reference/modulePreserve4.js +++ b/tests/baselines/reference/modulePreserve4.js @@ -28,10 +28,14 @@ exports.default = 0; import { x, y } from "./a"; // No y import a1 = require("./a"); // { x: 0 } const a2 = require("./a"); // Error in TS +const a3 = await import("./a"); // { x: 0 } +a3.x; import b1 from "./b"; // 0 import b2 = require("./b"); // { default: 0 } b2.default; +const b3 = await import("./b"); // { default: 0 } +b3.default; import c1 from "./c"; // { default: [Function: default] } import c2 = require("./c"); // { default: [Function: default] } @@ -40,6 +44,9 @@ import d1 from "./d"; // [Function: default] import d2 = require("./d"); // [Function: default] d2(); d2.default(); // Error +const d3 = await import("./d"); // { default: [Function: default] } +d3.default(); + import e1 from "./e.mjs"; // 0 import e2 = require("./e.mjs"); // 0 import f1 from "./f.cjs"; // 0 @@ -119,9 +126,13 @@ exports.default = 0; import { x, y } from "./a"; // No y const a1 = require("./a"); // { x: 0 } const a2 = require("./a"); // Error in TS +const a3 = await import("./a"); // { x: 0 } +a3.x; import b1 from "./b"; // 0 const b2 = require("./b"); // { default: 0 } b2.default; +const b3 = await import("./b"); // { default: 0 } +b3.default; import c1 from "./c"; // { default: [Function: default] } const c2 = require("./c"); // { default: [Function: default] } c2.default; @@ -129,6 +140,8 @@ import d1 from "./d"; // [Function: default] const d2 = require("./d"); // [Function: default] d2(); d2.default(); // Error +const d3 = await import("./d"); // { default: [Function: default] } +d3.default(); import e1 from "./e.mjs"; // 0 const e2 = require("./e.mjs"); // 0 import f1 from "./f.cjs"; // 0 diff --git a/tests/baselines/reference/modulePreserve4.symbols b/tests/baselines/reference/modulePreserve4.symbols index fec5b053ac454..05a7671af0235 100644 --- a/tests/baselines/reference/modulePreserve4.symbols +++ b/tests/baselines/reference/modulePreserve4.symbols @@ -46,71 +46,98 @@ import a1 = require("./a"); // { x: 0 } const a2 = require("./a"); // Error in TS >a2 : Symbol(a2, Decl(main1.ts, 2, 5)) +const a3 = await import("./a"); // { x: 0 } +>a3 : Symbol(a3, Decl(main1.ts, 3, 5)) +>"./a" : Symbol(a1, Decl(a.js, 0, 0)) + +a3.x; +>a3.x : Symbol(x, Decl(a.js, 0, 12)) +>a3 : Symbol(a3, Decl(main1.ts, 3, 5)) +>x : Symbol(x, Decl(a.js, 0, 12)) + import b1 from "./b"; // 0 ->b1 : Symbol(b1, Decl(main1.ts, 4, 6)) +>b1 : Symbol(b1, Decl(main1.ts, 6, 6)) import b2 = require("./b"); // { default: 0 } ->b2 : Symbol(b2, Decl(main1.ts, 4, 21)) +>b2 : Symbol(b2, Decl(main1.ts, 6, 21)) b2.default; >b2.default : Symbol(b1, Decl(b.ts, 0, 0)) ->b2 : Symbol(b2, Decl(main1.ts, 4, 21)) +>b2 : Symbol(b2, Decl(main1.ts, 6, 21)) +>default : Symbol(b1, Decl(b.ts, 0, 0)) + +const b3 = await import("./b"); // { default: 0 } +>b3 : Symbol(b3, Decl(main1.ts, 9, 5)) +>"./b" : Symbol(b2, Decl(b.ts, 0, 0)) + +b3.default; +>b3.default : Symbol(b1, Decl(b.ts, 0, 0)) +>b3 : Symbol(b3, Decl(main1.ts, 9, 5)) >default : Symbol(b1, Decl(b.ts, 0, 0)) import c1 from "./c"; // { default: [Function: default] } ->c1 : Symbol(c1, Decl(main1.ts, 8, 6)) +>c1 : Symbol(c1, Decl(main1.ts, 12, 6)) import c2 = require("./c"); // { default: [Function: default] } ->c2 : Symbol(c2, Decl(main1.ts, 8, 21)) +>c2 : Symbol(c2, Decl(main1.ts, 12, 21)) c2.default; >c2.default : Symbol(default, Decl(c.ts, 0, 10)) ->c2 : Symbol(c2, Decl(main1.ts, 8, 21)) +>c2 : Symbol(c2, Decl(main1.ts, 12, 21)) >default : Symbol(default, Decl(c.ts, 0, 10)) import d1 from "./d"; // [Function: default] ->d1 : Symbol(d1, Decl(main1.ts, 11, 6)) +>d1 : Symbol(d1, Decl(main1.ts, 15, 6)) import d2 = require("./d"); // [Function: default] ->d2 : Symbol(d2, Decl(main1.ts, 11, 21)) +>d2 : Symbol(d2, Decl(main1.ts, 15, 21)) d2(); ->d2 : Symbol(d2, Decl(main1.ts, 11, 21)) +>d2 : Symbol(d2, Decl(main1.ts, 15, 21)) d2.default(); // Error ->d2 : Symbol(d2, Decl(main1.ts, 11, 21)) +>d2 : Symbol(d2, Decl(main1.ts, 15, 21)) + +const d3 = await import("./d"); // { default: [Function: default] } +>d3 : Symbol(d3, Decl(main1.ts, 19, 5)) +>"./d" : Symbol("/d", Decl(d.ts, 0, 0)) + +d3.default(); +>d3.default : Symbol(default) +>d3 : Symbol(d3, Decl(main1.ts, 19, 5)) +>default : Symbol(default) import e1 from "./e.mjs"; // 0 ->e1 : Symbol(e1, Decl(main1.ts, 15, 6)) +>e1 : Symbol(e1, Decl(main1.ts, 22, 6)) import e2 = require("./e.mjs"); // 0 ->e2 : Symbol(e2, Decl(main1.ts, 15, 25)) +>e2 : Symbol(e2, Decl(main1.ts, 22, 25)) import f1 from "./f.cjs"; // 0 ->f1 : Symbol(f1, Decl(main1.ts, 17, 6)) +>f1 : Symbol(f1, Decl(main1.ts, 24, 6)) import f2 = require("./f.cjs"); // { default: 0 } ->f2 : Symbol(f2, Decl(main1.ts, 17, 25)) +>f2 : Symbol(f2, Decl(main1.ts, 24, 25)) f2.default; >f2.default : Symbol(f1, Decl(f.cts, 0, 0)) ->f2 : Symbol(f2, Decl(main1.ts, 17, 25)) +>f2 : Symbol(f2, Decl(main1.ts, 24, 25)) >default : Symbol(f1, Decl(f.cts, 0, 0)) import g1 from "./g"; // { default: 0 } ->g1 : Symbol(g1, Decl(main1.ts, 21, 6)) +>g1 : Symbol(g1, Decl(main1.ts, 28, 6)) g1.default; >g1.default : Symbol(g1.default, Decl(g.js, 0, 0)) ->g1 : Symbol(g1, Decl(main1.ts, 21, 6)) +>g1 : Symbol(g1, Decl(main1.ts, 28, 6)) >default : Symbol(g1.default, Decl(g.js, 0, 0)) import g2 = require("./g"); // { default: 0 } ->g2 : Symbol(g2, Decl(main1.ts, 22, 11)) +>g2 : Symbol(g2, Decl(main1.ts, 29, 11)) g2.default; >g2.default : Symbol(g1.default, Decl(g.js, 0, 0)) ->g2 : Symbol(g2, Decl(main1.ts, 22, 11)) +>g2 : Symbol(g2, Decl(main1.ts, 29, 11)) >default : Symbol(g1.default, Decl(g.js, 0, 0)) === /main2.mts === diff --git a/tests/baselines/reference/modulePreserve4.types b/tests/baselines/reference/modulePreserve4.types index 4a04b9ba621d1..04872a9dde255 100644 --- a/tests/baselines/reference/modulePreserve4.types +++ b/tests/baselines/reference/modulePreserve4.types @@ -62,6 +62,17 @@ const a2 = require("./a"); // Error in TS >require : any >"./a" : "./a" +const a3 = await import("./a"); // { x: 0 } +>a3 : typeof a1 +>await import("./a") : typeof a1 +>import("./a") : Promise +>"./a" : "./a" + +a3.x; +>a3.x : 0 +>a3 : typeof a1 +>x : 0 + import b1 from "./b"; // 0 >b1 : 0 @@ -73,6 +84,17 @@ b2.default; >b2 : typeof b2 >default : 0 +const b3 = await import("./b"); // { default: 0 } +>b3 : typeof b2 +>await import("./b") : typeof b2 +>import("./b") : Promise +>"./b" : "./b" + +b3.default; +>b3.default : 0 +>b3 : typeof b2 +>default : 0 + import c1 from "./c"; // { default: [Function: default] } >c1 : { default: () => void; } @@ -100,6 +122,18 @@ d2.default(); // Error >d2 : () => void >default : any +const d3 = await import("./d"); // { default: [Function: default] } +>d3 : { default: () => void; } +>await import("./d") : { default: () => void; } +>import("./d") : Promise<{ default: () => void; }> +>"./d" : "./d" + +d3.default(); +>d3.default() : void +>d3.default : () => void +>d3 : { default: () => void; } +>default : () => void + import e1 from "./e.mjs"; // 0 >e1 : 0 diff --git a/tests/cases/compiler/modulePreserve4.ts b/tests/cases/compiler/modulePreserve4.ts index 5bc59e2d1b495..9eabe664bb88c 100644 --- a/tests/cases/compiler/modulePreserve4.ts +++ b/tests/cases/compiler/modulePreserve4.ts @@ -34,10 +34,14 @@ exports.default = 0; import { x, y } from "./a"; // No y import a1 = require("./a"); // { x: 0 } const a2 = require("./a"); // Error in TS +const a3 = await import("./a"); // { x: 0 } +a3.x; import b1 from "./b"; // 0 import b2 = require("./b"); // { default: 0 } b2.default; +const b3 = await import("./b"); // { default: 0 } +b3.default; import c1 from "./c"; // { default: [Function: default] } import c2 = require("./c"); // { default: [Function: default] } @@ -46,6 +50,9 @@ import d1 from "./d"; // [Function: default] import d2 = require("./d"); // [Function: default] d2(); d2.default(); // Error +const d3 = await import("./d"); // { default: [Function: default] } +d3.default(); + import e1 from "./e.mjs"; // 0 import e2 = require("./e.mjs"); // 0 import f1 from "./f.cjs"; // 0 From 3c2ebd72af6f1a163b387c1380faa12d39b3e89e Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 11 Jan 2024 09:01:24 -0800 Subject: [PATCH 21/31] Use referenced project options to determine import mode --- src/compiler/program.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index a44f4d8122aa3..505d2e8784ebe 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1056,7 +1056,7 @@ export function loadWithModeAwareCache Date: Tue, 16 Jan 2024 10:30:43 -0800 Subject: [PATCH 22/31] Update baselines from main merge --- .../reference/modulePreserve2.trace.json | 38 ++++++++++++++++++- .../reference/modulePreserve3.trace.json | 35 ++++++++++++++++- 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/tests/baselines/reference/modulePreserve2.trace.json b/tests/baselines/reference/modulePreserve2.trace.json index 6f6668093cc41..e8f128fcc1462 100644 --- a/tests/baselines/reference/modulePreserve2.trace.json +++ b/tests/baselines/reference/modulePreserve2.trace.json @@ -815,6 +815,30 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/object' from '/.src/__lib_node_modules_lookup_lib.esnext.object.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/object' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/collection' from '/.src/__lib_node_modules_lookup_lib.esnext.collection.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", @@ -862,5 +886,17 @@ "Loading module '@typescript/lib-dom/iterable' from 'node_modules' folder, target file types: JavaScript.", "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-dom/iterable' was not resolved. ========" + "======== Module name '@typescript/lib-dom/iterable' was not resolved. ========", + "======== Resolving module '@typescript/lib-dom/asynciterable' from '/.src/__lib_node_modules_lookup_lib.dom.asynciterable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom/asynciterable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom/asynciterable'", + "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom/asynciterable'", + "Loading module '@typescript/lib-dom/asynciterable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom/asynciterable' was not resolved. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/modulePreserve3.trace.json b/tests/baselines/reference/modulePreserve3.trace.json index bc9728d5e5068..35f43171f4a04 100644 --- a/tests/baselines/reference/modulePreserve3.trace.json +++ b/tests/baselines/reference/modulePreserve3.trace.json @@ -749,6 +749,28 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/promise' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/object' from '/.src/__lib_node_modules_lookup_lib.esnext.object.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Scoped package detected, looking in 'typescript__lib-esnext/object'", + "Loading module '@typescript/lib-esnext/object' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/object' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/collection' from '/.src/__lib_node_modules_lookup_lib.esnext.collection.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Scoped package detected, looking in 'typescript__lib-esnext/collection'", + "Loading module '@typescript/lib-esnext/collection' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/collection' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", @@ -794,5 +816,16 @@ "Loading module '@typescript/lib-dom/iterable' from 'node_modules' folder, target file types: JavaScript.", "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", - "======== Module name '@typescript/lib-dom/iterable' was not resolved. ========" + "======== Module name '@typescript/lib-dom/iterable' was not resolved. ========", + "======== Resolving module '@typescript/lib-dom/asynciterable' from '/.src/__lib_node_modules_lookup_lib.dom.asynciterable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-dom/asynciterable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-dom/asynciterable'", + "Scoped package detected, looking in 'typescript__lib-dom/asynciterable'", + "Loading module '@typescript/lib-dom/asynciterable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-dom/asynciterable' was not resolved. ========" ] \ No newline at end of file From ff7d405ca83898b79a914903d5a1b1cc6cd76a5e Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Tue, 16 Jan 2024 14:51:10 -0800 Subject: [PATCH 23/31] Create and use program.getModeForUsageLocation --- src/compiler/checker.ts | 5 +-- src/compiler/program.ts | 41 ++++++++++++++----- src/compiler/types.ts | 11 +++++ src/services/codefixes/convertToEsModule.ts | 3 +- .../codefixes/fixImportNonExportedMember.ts | 6 +-- src/services/codefixes/fixSpelling.ts | 7 ++-- src/services/codefixes/importFixes.ts | 3 +- src/services/completions.ts | 2 +- src/services/findAllReferences.ts | 3 +- src/services/getEditsForFileRename.ts | 5 +-- src/services/goToDefinition.ts | 5 +-- src/services/refactors/moveToFile.ts | 3 +- src/services/stringCompletions.ts | 26 ++++++------ src/services/suggestionDiagnostics.ts | 3 +- tests/baselines/reference/api/typescript.d.ts | 11 +++-- 15 files changed, 81 insertions(+), 53 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5762167d2a318..f8ff819a46fd5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -322,7 +322,6 @@ import { getLineAndCharacterOfPosition, getLocalSymbolForExportDefault, getMembersOfDeclaration, - getModeForUsageLocation, getModifiers, getModuleInstanceState, getNameFromImportAttribute, @@ -4059,7 +4058,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function getUsageModeForExpression(usage: Expression) { - return isStringLiteralLike(usage) ? getModeForUsageLocation(getSourceFileOfNode(usage), usage, compilerOptions) : undefined; + return isStringLiteralLike(usage) ? host.getModeForUsageLocation(getSourceFileOfNode(usage), usage) : undefined; } function isESMFormatImportImportingCommonjsFormatFile(usageMode: ResolutionMode, targetMode: ResolutionMode) { @@ -5012,7 +5011,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { findAncestor(location, isImportDeclaration)?.moduleSpecifier || findAncestor(location, isExternalModuleImportEqualsDeclaration)?.moduleReference.expression || findAncestor(location, isExportDeclaration)?.moduleSpecifier; - const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? getModeForUsageLocation(currentSourceFile, contextSpecifier, compilerOptions) : currentSourceFile.impliedNodeFormat; + const mode = contextSpecifier && isStringLiteralLike(contextSpecifier) ? host.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat; const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions); const resolvedModule = host.getResolvedModule(currentSourceFile, moduleReference, mode)?.resolvedModule; const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule, currentSourceFile); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 9df58cb853d71..f631acd902294 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -140,6 +140,7 @@ import { getResolveJsonModule, getRootLength, getSetExternalModuleIndicator, + getSourceFileOfNode, getSpellingSuggestion, getStrictOptionValue, getSupportedExtensions, @@ -864,7 +865,7 @@ export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number, compilerOptions: CompilerOptions): ResolutionMode { // we ensure all elements of file.imports and file.moduleAugmentations have the relevant parent pointers set during program setup, // so it's safe to use them even pre-bind - return getModeForUsageLocation(file, getModuleNameStringLiteralAt(file, index), compilerOptions); + return getModeForUsageLocationWorker(file, getModuleNameStringLiteralAt(file, index), compilerOptions); } /** @internal */ @@ -879,15 +880,23 @@ export function isExclusivelyTypeOnlyImportOrExport(decl: ImportDeclaration | Ex } /** - * Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if - * one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm). - * Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when - * `moduleResolution` is `node16`+. + * Use `program.getModeForUsageLocation`, which retrieves the correct `compilerOptions`, instead of this function whenever possible. + * Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import + * attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may + * depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other + * `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no + * impact on module resolution, emit, or type checking. * @param file The file the import or import-like reference is contained within * @param usage The module reference string + * @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options + * should be the options of the referenced project, not the referencing project. * @returns The final resolution mode of the import */ export function getModeForUsageLocation(file: { impliedNodeFormat?: ResolutionMode; }, usage: StringLiteralLike, compilerOptions: CompilerOptions) { + return getModeForUsageLocationWorker(file, usage, compilerOptions); +} + +function getModeForUsageLocationWorker(file: { impliedNodeFormat?: ResolutionMode; }, usage: StringLiteralLike, compilerOptions: CompilerOptions) { if ((isImportDeclaration(usage.parent) || isExportDeclaration(usage.parent))) { const isTypeOnly = isExclusivelyTypeOnlyImportOrExport(usage.parent); if (isTypeOnly) { @@ -903,7 +912,7 @@ export function getModeForUsageLocation(file: { impliedNodeFormat?: ResolutionMo return override; } } - if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Bundler) { + if (getEmitModuleKind(compilerOptions) === ModuleKind.Preserve) { return (usage.parent.parent && isImportEqualsDeclaration(usage.parent.parent) || isRequireCall(usage.parent, /*requireStringLiteralLikeArgument*/ false)) ? ModuleKind.CommonJS : ModuleKind.ESNext; @@ -1889,6 +1898,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg getAutomaticTypeDirectiveResolutions: () => automaticTypeDirectiveResolutions, isSourceFileFromExternalLibrary, isSourceFileDefaultLibrary, + getModeForUsageLocation, getSourceFileFromReference, getLibFileFromReference, sourceFileToPackageName, @@ -1898,6 +1908,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg resolvedTypeReferenceDirectiveNames, resolvedLibReferences, getResolvedModule, + getResolvedModuleFromModuleSpecifier, getResolvedTypeReferenceDirective, forEachResolvedModule, forEachResolvedTypeReferenceDirective, @@ -1954,6 +1965,12 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg return resolvedModules?.get(file.path)?.get(moduleName, mode); } + function getResolvedModuleFromModuleSpecifier(moduleSpecifier: StringLiteralLike): ResolvedModuleWithFailedLookupLocations | undefined { + const sourceFile = getSourceFileOfNode(moduleSpecifier); + Debug.assertIsDefined(sourceFile, "`moduleSpecifier` must have a `SourceFile` ancestor. Use `program.getResolvedModule` instead to provide the containing file and resolution mode."); + return getResolvedModule(sourceFile, moduleSpecifier.text, getModeForUsageLocation(sourceFile, moduleSpecifier)); + } + function getResolvedTypeReferenceDirective(file: SourceFile, typeDirectiveName: string, mode: ResolutionMode) { return resolvedTypeReferenceDirectiveNames?.get(file.path)?.get(typeDirectiveName, mode); } @@ -2162,8 +2179,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg const moduleName = moduleNames[i]; // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions if (file === oldSourceFile && !hasInvalidatedResolutions(file.path)) { - const mode = getModeForUsageLocation(file, moduleName, options); - const oldResolution = oldProgram?.getResolvedModule(file, moduleName.text, mode); + const oldResolution = oldProgram?.getResolvedModule(file, moduleName.text, oldProgram.getModeForUsageLocation(file, moduleName)); if (oldResolution?.resolvedModule) { if (isTraceEnabled(options, host)) { trace( @@ -2231,7 +2247,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg // If we change our policy of rechecking failed lookups on each program create, // we should adjust the value returned here. function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName: StringLiteralLike): boolean { - const resolutionToFile = oldProgram?.getResolvedModule(file, moduleName.text, getModeForUsageLocation(file, moduleName, oldProgram.getCompilerOptions()))?.resolvedModule; + const resolutionToFile = oldProgram?.getResolvedModule(file, moduleName.text, oldProgram.getModeForUsageLocation(file, moduleName))?.resolvedModule; const resolvedFile = resolutionToFile && oldProgram!.getSourceFile(resolutionToFile.resolvedFileName); if (resolutionToFile && resolvedFile) { // In the old program, we resolved to an ambient module that was in the same @@ -4035,7 +4051,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg for (let index = 0; index < moduleNames.length; index++) { const resolution = resolutions[index].resolvedModule; const moduleName = moduleNames[index].text; - const mode = getModeForUsageLocation(file, moduleNames[index], optionsForFile); + const mode = getModeForUsageLocationWorker(file, moduleNames[index], optionsForFile); resolutionsInFile.set(moduleName, mode, resolutions[index]); addResolutionDiagnosticsFromResolutionOrCache(file, moduleName, resolutions[index], mode); @@ -4985,6 +5001,11 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg } return symlinks; } + + function getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode { + const optionsForFile = getRedirectReferenceForResolution(file)?.commandLine.options || options; + return getModeForUsageLocationWorker(file, usage, optionsForFile); + } } interface HostForUseSourceOfProjectReferenceRedirect { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 47bd0a52ae6e6..f1da7fed9bc4d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4698,6 +4698,8 @@ export interface Program extends ScriptReferenceHost { /** @internal */ getResolvedModule(f: SourceFile, moduleName: string, mode: ResolutionMode): ResolvedModuleWithFailedLookupLocations | undefined; /** @internal */ + getResolvedModuleFromModuleSpecifier(moduleSpecifier: StringLiteralLike): ResolvedModuleWithFailedLookupLocations | undefined; + /** @internal */ getResolvedTypeReferenceDirective(f: SourceFile, typeDirectiveName: string, mode: ResolutionMode): ResolvedTypeReferenceDirectiveWithFailedLookupLocations | undefined; /** @internal */ forEachResolvedModule( @@ -4760,6 +4762,14 @@ export interface Program extends ScriptReferenceHost { /** @internal */ getAutomaticTypeDirectiveResolutions(): ModeAwareCache; isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; + /** + * Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import + * attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may + * depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other + * `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no + * impact on module resolution, emit, or type checking. + */ + getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode; // For testing purposes only. // This is set on created program to let us know how the program was created using old program @@ -4925,6 +4935,7 @@ export interface TypeCheckerHost extends ModuleSpecifierResolutionHost { getResolvedTypeReferenceDirectives(): ModeAwareCache; getProjectReferenceRedirect(fileName: string): string | undefined; isSourceOfProjectReferenceRedirect(fileName: string): boolean; + getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode; getResolvedModule(f: SourceFile, moduleName: string, mode: ResolutionMode): ResolvedModuleWithFailedLookupLocations | undefined; diff --git a/src/services/codefixes/convertToEsModule.ts b/src/services/codefixes/convertToEsModule.ts index 88cb6546ac4e2..b78669dc244a0 100644 --- a/src/services/codefixes/convertToEsModule.ts +++ b/src/services/codefixes/convertToEsModule.ts @@ -26,7 +26,6 @@ import { FunctionDeclaration, FunctionExpression, getEmitScriptTarget, - getModeForUsageLocation, getQuotePreference, getSynthesizedDeepClone, getSynthesizedDeepClones, @@ -107,7 +106,7 @@ function fixImportOfModuleExports( quotePreference: QuotePreference, ) { for (const moduleSpecifier of importingFile.imports) { - const imported = program.getResolvedModule(importingFile, moduleSpecifier.text, getModeForUsageLocation(importingFile, moduleSpecifier, program.getCompilerOptions()))?.resolvedModule; + const imported = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)?.resolvedModule; if (!imported || imported.resolvedFileName !== exportingFile.fileName) { continue; } diff --git a/src/services/codefixes/fixImportNonExportedMember.ts b/src/services/codefixes/fixImportNonExportedMember.ts index 376a74663e114..56208667bdb5e 100644 --- a/src/services/codefixes/fixImportNonExportedMember.ts +++ b/src/services/codefixes/fixImportNonExportedMember.ts @@ -116,10 +116,10 @@ function getInfo(sourceFile: SourceFile, pos: number, program: Program): Info | const importDeclaration = findAncestor(token, isImportDeclaration); if (importDeclaration === undefined) return undefined; - const moduleSpecifier = isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier.text : undefined; + const moduleSpecifier = isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier : undefined; if (moduleSpecifier === undefined) return undefined; - const resolvedModule = program.getResolvedModule(sourceFile, moduleSpecifier, /*mode*/ undefined)?.resolvedModule; + const resolvedModule = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)?.resolvedModule; if (resolvedModule === undefined) return undefined; const moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName); @@ -136,7 +136,7 @@ function getInfo(sourceFile: SourceFile, pos: number, program: Program): Info | if (node === undefined) return undefined; const exportName = { node: token, isTypeOnly: isTypeDeclaration(node) }; - return { exportName, node, moduleSourceFile, moduleSpecifier }; + return { exportName, node, moduleSourceFile, moduleSpecifier: moduleSpecifier.text }; } return undefined; } diff --git a/src/services/codefixes/fixSpelling.ts b/src/services/codefixes/fixSpelling.ts index 81b90d68e8544..8c2130ab57c91 100644 --- a/src/services/codefixes/fixSpelling.ts +++ b/src/services/codefixes/fixSpelling.ts @@ -7,7 +7,6 @@ import { getEffectiveBaseTypeNode, getEmitScriptTarget, getMeaningFromLocation, - getModeForUsageLocation, getTextOfNode, getTokenAtPosition, hasOverrideModifier, @@ -119,7 +118,7 @@ function getInfo(sourceFile: SourceFile, pos: number, context: CodeFixContextBas else if (isImportSpecifier(parent) && parent.name === node) { Debug.assertNode(node, isIdentifier, "Expected an identifier for spelling (import)"); const importDeclaration = findAncestor(node, isImportDeclaration)!; - const resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); + const resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { suggestedSymbol = checker.getSuggestedSymbolForNonexistentModule(node, resolvedSourceFile.symbol); } @@ -178,10 +177,10 @@ function convertSemanticMeaningToSymbolFlags(meaning: SemanticMeaning): SymbolFl return flags; } -function getResolvedSourceFileFromImportDeclaration(sourceFile: SourceFile, context: CodeFixContextBase, importDeclaration: ImportDeclaration): SourceFile | undefined { +function getResolvedSourceFileFromImportDeclaration(context: CodeFixContextBase, importDeclaration: ImportDeclaration): SourceFile | undefined { if (!importDeclaration || !isStringLiteralLike(importDeclaration.moduleSpecifier)) return undefined; - const resolvedModule = context.program.getResolvedModule(sourceFile, importDeclaration.moduleSpecifier.text, getModeForUsageLocation(sourceFile, importDeclaration.moduleSpecifier, context.program.getCompilerOptions()))?.resolvedModule; + const resolvedModule = context.program.getResolvedModuleFromModuleSpecifier(importDeclaration.moduleSpecifier)?.resolvedModule; if (!resolvedModule) return undefined; return context.program.getSourceFile(resolvedModule.resolvedFileName); diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 600e796320057..a634ac334a02f 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -44,7 +44,6 @@ import { getExportInfoMap, getMeaningFromDeclaration, getMeaningFromLocation, - getModeForUsageLocation, getNameForExportedSymbol, getNodeId, getOutputExtension, @@ -1441,7 +1440,7 @@ function promoteFromTypeOnly( // Change .ts extension to .js if necessary if (!compilerOptions.allowImportingTsExtensions) { const moduleSpecifier = tryGetModuleSpecifierFromDeclaration(importClause.parent); - const resolvedModule = moduleSpecifier && program.getResolvedModule(sourceFile, moduleSpecifier.text, getModeForUsageLocation(sourceFile, moduleSpecifier, compilerOptions))?.resolvedModule; + const resolvedModule = moduleSpecifier && program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)?.resolvedModule; if (resolvedModule?.resolvedUsingTsExtension) { const changedExtension = changeAnyExtension(moduleSpecifier!.text, getOutputExtension(moduleSpecifier!.text, compilerOptions)); changes.replaceNode(sourceFile, moduleSpecifier!, factory.createStringLiteral(changedExtension)); diff --git a/src/services/completions.ts b/src/services/completions.ts index 234a4072c76a5..25ecd5e8b624f 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -2807,7 +2807,7 @@ export function getCompletionEntryDetails( const { previousToken, contextToken } = getRelevantTokens(position, sourceFile); if (isInString(sourceFile, position, previousToken)) { - return StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, previousToken, typeChecker, compilerOptions, host, cancellationToken, preferences); + return StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, previousToken, program, host, cancellationToken, preferences); } // Compute all the completion symbols again. diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 43190717550b8..fdf81a7edf925 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -65,7 +65,6 @@ import { getLocalSymbolForExportDefault, getMeaningFromDeclaration, getMeaningFromLocation, - getModeForUsageLocation, getNameOfDeclaration, getNameTable, getNextJSDocCommentLocation, @@ -1023,7 +1022,7 @@ export namespace Core { if (!options.implementations && isStringLiteralLike(node)) { if (isModuleSpecifierLike(node)) { const fileIncludeReasons = program.getFileIncludeReasons(); - const referencedFileName = program.getResolvedModule(node.getSourceFile(), node.text, getModeForUsageLocation(node.getSourceFile(), node, program.getCompilerOptions()))?.resolvedModule?.resolvedFileName; + const referencedFileName = program.getResolvedModuleFromModuleSpecifier(node)?.resolvedModule?.resolvedFileName; const referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; if (referencedFile) { return [{ definition: { type: DefinitionKind.String, node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || emptyArray }]; diff --git a/src/services/getEditsForFileRename.ts b/src/services/getEditsForFileRename.ts index 4bbdf9b95997d..860202a0bb285 100644 --- a/src/services/getEditsForFileRename.ts +++ b/src/services/getEditsForFileRename.ts @@ -16,7 +16,6 @@ import { GetCanonicalFileName, getDirectoryPath, getFileMatcherPatterns, - getModeForUsageLocation, getOptionFromName, getRegexFromPattern, getRelativePathFromDirectory, @@ -246,9 +245,9 @@ function getSourceFileToImport( return newFileName === undefined ? { newFileName: oldFileName, updated: false } : { newFileName, updated: true }; } else { - const mode = getModeForUsageLocation(importingSourceFile, importLiteral, program.getCompilerOptions()); + const mode = program.getModeForUsageLocation(importingSourceFile, importLiteral); const resolved = host.resolveModuleNameLiterals || !host.resolveModuleNames ? - program.getResolvedModule(importingSourceFile, importLiteral.text, mode) : + program.getResolvedModuleFromModuleSpecifier(importLiteral) : host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode); return getSourceFileToImportFromResolved(importLiteral, resolved, oldToNew, program.getSourceFiles()); } diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 8d81db5d470cb..d3148d5ae60f5 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -29,7 +29,6 @@ import { getDirectoryPath, getEffectiveBaseTypeNode, getInvokedExpression, - getModeForUsageLocation, getNameFromPropertyName, getNameOfDeclaration, getObjectFlags, @@ -203,7 +202,7 @@ export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile if (!symbol && isModuleSpecifierLike(fallbackNode)) { // We couldn't resolve the module specifier as an external module, but it could // be that module resolution succeeded but the target was not a module. - const ref = program.getResolvedModule(sourceFile, fallbackNode.text, getModeForUsageLocation(sourceFile, fallbackNode, program.getCompilerOptions()))?.resolvedModule; + const ref = program.getResolvedModuleFromModuleSpecifier(fallbackNode)?.resolvedModule; if (ref) { return [{ name: fallbackNode.text, @@ -359,7 +358,7 @@ export function getReferenceAtPosition(sourceFile: SourceFile, position: number, if (sourceFile.imports.length || sourceFile.moduleAugmentations.length) { const node = getTouchingToken(sourceFile, position); let resolution: ResolvedModuleWithFailedLookupLocations | undefined; - if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && (resolution = program.getResolvedModule(sourceFile, node.text, getModeForUsageLocation(sourceFile, node, program.getCompilerOptions())))) { + if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && (resolution = program.getResolvedModuleFromModuleSpecifier(node))) { const verifiedFileName = resolution.resolvedModule?.resolvedFileName; const fileName = verifiedFileName || resolvePath(getDirectoryPath(sourceFile.fileName), node.text); return { diff --git a/src/services/refactors/moveToFile.ts b/src/services/refactors/moveToFile.ts index 65cb59a07c778..1c2a7a6e70265 100644 --- a/src/services/refactors/moveToFile.ts +++ b/src/services/refactors/moveToFile.ts @@ -51,7 +51,6 @@ import { getDecorators, getDirectoryPath, getLocaleSpecificMessage, - getModeForUsageLocation, getModifiers, getPropertySymbolFromBindingElement, getQuotePreference, @@ -314,7 +313,7 @@ function getTargetFileImportsAndAddExportInOldFile( // Recomputing module specifier const moduleSpecifier = moduleSpecifierFromImport(i); const compilerOptions = program.getCompilerOptions(); - const resolved = program.getResolvedModule(oldFile, moduleSpecifier.text, getModeForUsageLocation(oldFile, moduleSpecifier, compilerOptions)); + const resolved = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier); const fileName = resolved?.resolvedModule?.resolvedFileName; if (fileName && targetSourceFile) { const newModuleSpecifier = getModuleSpecifier(compilerOptions, targetSourceFile, targetSourceFile.fileName, fileName, createModuleSpecifierResolutionHost(program, host)); diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index c50df9ee96643..1c0339f7c1488 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -52,7 +52,6 @@ import { getEffectiveTypeRoots, getEmitModuleResolutionKind, getLeadingCommentRanges, - getModeForUsageLocation, getModuleSpecifierEndingPreference, getOwnKeys, getPackageJsonTypesVersionsPaths, @@ -203,7 +202,7 @@ export function getStringLiteralCompletions( } if (isInString(sourceFile, position, contextToken)) { if (!contextToken || !isStringLiteralLike(contextToken)) return undefined; - const entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program.getTypeChecker(), options, host, preferences); + const entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program, host, preferences); return convertStringLiteralCompletions(entries, contextToken, sourceFile, host, program, log, options, preferences, position, includeSymbol); } } @@ -281,10 +280,10 @@ function convertStringLiteralCompletions( } /** @internal */ -export function getStringLiteralCompletionDetails(name: string, sourceFile: SourceFile, position: number, contextToken: Node | undefined, checker: TypeChecker, options: CompilerOptions, host: LanguageServiceHost, cancellationToken: CancellationToken, preferences: UserPreferences) { +export function getStringLiteralCompletionDetails(name: string, sourceFile: SourceFile, position: number, contextToken: Node | undefined, program: Program, host: LanguageServiceHost, cancellationToken: CancellationToken, preferences: UserPreferences) { if (!contextToken || !isStringLiteralLike(contextToken)) return undefined; - const completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host, preferences); - return completions && stringLiteralCompletionDetails(name, contextToken, completions, sourceFile, checker, cancellationToken); + const completions = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program, host, preferences); + return completions && stringLiteralCompletionDetails(name, contextToken, completions, sourceFile, program.getTypeChecker(), cancellationToken); } function stringLiteralCompletionDetails(name: string, location: Node, completion: StringLiteralCompletion, sourceFile: SourceFile, checker: TypeChecker, cancellationToken: CancellationToken): CompletionEntryDetails | undefined { @@ -361,13 +360,14 @@ interface StringLiteralCompletionsFromTypes { readonly isNewIdentifier: boolean; } type StringLiteralCompletion = { readonly kind: StringLiteralCompletionKind.Paths; readonly paths: readonly PathCompletion[]; } | StringLiteralCompletionsFromProperties | StringLiteralCompletionsFromTypes; -function getStringLiteralCompletionEntries(sourceFile: SourceFile, node: StringLiteralLike, position: number, typeChecker: TypeChecker, compilerOptions: CompilerOptions, host: LanguageServiceHost, preferences: UserPreferences): StringLiteralCompletion | undefined { +function getStringLiteralCompletionEntries(sourceFile: SourceFile, node: StringLiteralLike, position: number, program: Program, host: LanguageServiceHost, preferences: UserPreferences): StringLiteralCompletion | undefined { + const typeChecker = program.getTypeChecker(); const parent = walkUpParentheses(node.parent); switch (parent.kind) { case SyntaxKind.LiteralType: { const grandParent = walkUpParentheses(parent.parent); if (grandParent.kind === SyntaxKind.ImportType) { - return { kind: StringLiteralCompletionKind.Paths, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + return { kind: StringLiteralCompletionKind.Paths, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, program, host, preferences) }; } return fromUnionableLiteralType(grandParent); } @@ -424,7 +424,7 @@ function getStringLiteralCompletionEntries(sourceFile: SourceFile, node: StringL // import x = require("/*completion position*/"); // var y = require("/*completion position*/"); // export * from "/*completion position*/"; - return { kind: StringLiteralCompletionKind.Paths, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + return { kind: StringLiteralCompletionKind.Paths, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, program, host, preferences) }; case SyntaxKind.CaseClause: const tracker = newCaseClauseTracker(typeChecker, (parent as CaseClause).parent.clauses); const contextualTypes = fromContextualType(); @@ -577,16 +577,18 @@ function addReplacementSpans(text: string, textStart: number, names: readonly Na return names.map(({ name, kind, extension }): PathCompletion => (name.includes(directorySeparator) || name.includes(altDirectorySeparator)) ? { name, kind, extension, span: wholeSpan } : { name, kind, extension, span }); } -function getStringLiteralCompletionsFromModuleNames(sourceFile: SourceFile, node: LiteralExpression, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker, preferences: UserPreferences): readonly PathCompletion[] { - return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences)); +function getStringLiteralCompletionsFromModuleNames(sourceFile: SourceFile, node: LiteralExpression, program: Program, host: LanguageServiceHost, preferences: UserPreferences): readonly PathCompletion[] { + return addReplacementSpans(node.text, node.getStart(sourceFile) + 1, getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, program, host, preferences)); } -function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile: SourceFile, node: LiteralExpression, compilerOptions: CompilerOptions, host: LanguageServiceHost, typeChecker: TypeChecker, preferences: UserPreferences): readonly NameAndKind[] { +function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile: SourceFile, node: LiteralExpression, program: Program, host: LanguageServiceHost, preferences: UserPreferences): readonly NameAndKind[] { const literalValue = normalizeSlashes(node.text); - const mode = isStringLiteralLike(node) ? getModeForUsageLocation(sourceFile, node, compilerOptions) : undefined; + const mode = isStringLiteralLike(node) ? program.getModeForUsageLocation(sourceFile, node) : undefined; const scriptPath = sourceFile.path; const scriptDirectory = getDirectoryPath(scriptPath); + const compilerOptions = program.getCompilerOptions(); + const typeChecker = program.getTypeChecker(); const extensionOptions = getExtensionOptions(compilerOptions, ReferenceKind.ModuleSpecifier, sourceFile, typeChecker, preferences, mode); return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && !compilerOptions.paths && (isRootedDiskPath(literalValue) || isUrl(literalValue)) diff --git a/src/services/suggestionDiagnostics.ts b/src/services/suggestionDiagnostics.ts index 6026c126d0cd8..cc597320d58ad 100644 --- a/src/services/suggestionDiagnostics.ts +++ b/src/services/suggestionDiagnostics.ts @@ -23,7 +23,6 @@ import { getAllowSyntheticDefaultImports, getAssignmentDeclarationKind, getFunctionFlags, - getModeForUsageLocation, hasInitializer, hasPropertyAccessExpressionWithName, Identifier, @@ -88,7 +87,7 @@ export function computeSuggestionDiagnostics(sourceFile: SourceFile, program: Pr const importNode = importFromModuleSpecifier(moduleSpecifier); const name = importNameForConvertToDefaultImport(importNode); if (!name) continue; - const module = program.getResolvedModule(sourceFile, moduleSpecifier.text, getModeForUsageLocation(sourceFile, moduleSpecifier, program.getCompilerOptions()))?.resolvedModule; + const module = program.getResolvedModuleFromModuleSpecifier(moduleSpecifier)?.resolvedModule; const resolvedFile = module && program.getSourceFile(module.resolvedFileName); if (resolvedFile && resolvedFile.externalModuleIndicator && resolvedFile.externalModuleIndicator !== true && isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) { diags.push(createDiagnosticForNode(name, Diagnostics.Import_may_be_converted_to_a_default_import)); diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 49926223784cd..4e098892ad2d2 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -6660,6 +6660,7 @@ declare namespace ts { }; isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; + getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode; getProjectReferences(): readonly ProjectReference[] | undefined; getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined; } @@ -9911,12 +9912,14 @@ declare namespace ts { */ function getModeForResolutionAtIndex(file: SourceFile, index: number, compilerOptions: CompilerOptions): ResolutionMode; /** - * Calculates the final resolution mode for a given module reference node. This is generally the explicitly provided resolution mode, if - * one exists, or the mode of the containing source file. (Excepting import=require, which is always commonjs, and dynamic import, which is always esm). - * Notably, this function always returns `undefined` if the containing file has an `undefined` `impliedNodeFormat` - this field is only set when - * `moduleResolution` is `node16`+. + * Use `program.getModeForUsageLocation`, which retrieves the correct `compilerOptions`, instead of this function whenever possible. + * Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import + * attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may + * depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. * @param file The file the import or import-like reference is contained within * @param usage The module reference string + * @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options + * should be the options of the referenced project, not the referencing project. * @returns The final resolution mode of the import */ function getModeForUsageLocation( From 521031d3fde2d201b6c8158476104661832b9575 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Tue, 16 Jan 2024 14:55:28 -0800 Subject: [PATCH 24/31] Fix missed location --- src/compiler/program.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index f631acd902294..66030b8bd0039 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1197,7 +1197,7 @@ export function getReferencedFileLocation(program: Program, ref: ReferencedFile) switch (kind) { case FileIncludeKind.Import: const importLiteral = getModuleNameStringLiteralAt(file, index); - packageId = program.getResolvedModule(file, importLiteral.text, getModeForResolutionAtIndex(file, index, program.getCompilerOptions()))?.resolvedModule?.packageId; + packageId = program.getResolvedModule(file, importLiteral.text, program.getModeForUsageLocation(file, importLiteral))?.resolvedModule?.packageId; if (importLiteral.pos === -1) return { file, packageId, text: importLiteral.text }; pos = skipTrivia(file.text, importLiteral.pos); end = importLiteral.end; From 2a205c47fa68b95edf93fe5078e9ddaea87f8983 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Tue, 16 Jan 2024 15:54:37 -0800 Subject: [PATCH 25/31] Fix more missed locations --- src/compiler/program.ts | 13 +++---------- src/compiler/resolutionCache.ts | 4 ++-- src/compiler/utilities.ts | 10 ++-------- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 66030b8bd0039..26db3517fb048 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1014,8 +1014,7 @@ function getTypeReferenceResolutionName(entry: return !isString(entry) ? toFileNameLowerCase(entry.fileName) : entry; } -/** @internal */ -export const typeReferenceResolutionNameAndModeGetter: ResolutionNameAndModeGetter = { +const typeReferenceResolutionNameAndModeGetter: ResolutionNameAndModeGetter = { getName: getTypeReferenceResolutionName, getMode: (entry, file) => getModeForFileReference(entry, file?.impliedNodeFormat), }; @@ -2541,12 +2540,9 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg // ensure that module resolution results are still correct const resolutionsChanged = hasChangesInResolutions( moduleNames, - newSourceFile, resolutions, - (name, mode) => oldProgram!.getResolvedModule(newSourceFile, name, mode), + oldProgram.getResolvedModuleFromModuleSpecifier, moduleResolutionIsEqualTo, - moduleResolutionNameAndModeGetter, - oldProgram.getCompilerOptions(), ); if (resolutionsChanged) structureIsReused = StructureIsReused.SafeModules; const typesReferenceDirectives = newSourceFile.typeReferenceDirectives; @@ -2555,12 +2551,9 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg // ensure that types resolutions are still correct const typeReferenceResolutionsChanged = hasChangesInResolutions( typesReferenceDirectives, - newSourceFile, typeReferenceResolutions, - (name, mode) => oldProgram?.getResolvedTypeReferenceDirective(newSourceFile, name, mode), + name => oldProgram!.getResolvedTypeReferenceDirective(newSourceFile, getTypeReferenceResolutionName(name), getModeForFileReference(name, newSourceFile.impliedNodeFormat)), typeDirectiveIsEqualTo, - typeReferenceResolutionNameAndModeGetter, - oldProgram.getCompilerOptions(), ); if (typeReferenceResolutionsChanged) structureIsReused = StructureIsReused.SafeModules; } diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts index eb6e28074135a..375083077b241 100644 --- a/src/compiler/resolutionCache.ts +++ b/src/compiler/resolutionCache.ts @@ -822,7 +822,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD const seenNamesInFile = createModeAwareCache(); for (const entry of entries) { const name = loader.nameAndMode.getName(entry); - const mode = loader.nameAndMode.getMode(entry, containingSourceFile, options); + const mode = loader.nameAndMode.getMode(entry, containingSourceFile, redirectedReference?.commandLine.options || options); let resolution = resolutionsInFile.get(name, mode); // Resolution is valid if it is present and not invalidated if ( @@ -881,7 +881,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD reusedNames?.forEach(entry => seenNamesInFile.set( loader.nameAndMode.getName(entry), - loader.nameAndMode.getMode(entry, containingSourceFile, options), + loader.nameAndMode.getMode(entry, containingSourceFile, redirectedReference?.commandLine.options || options), true, ) ); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 6dfb15f8275ec..4680a78c5ace2 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -469,7 +469,6 @@ import { RequireOrImportCall, RequireVariableStatement, ResolutionMode, - ResolutionNameAndModeGetter, ResolvedModuleFull, ResolvedModuleWithFailedLookupLocations, ResolvedTypeReferenceDirective, @@ -837,21 +836,16 @@ export function typeDirectiveIsEqualTo(oldResolution: ResolvedTypeReferenceDirec /** @internal */ export function hasChangesInResolutions( names: readonly K[], - newSourceFile: SourceFile, newResolutions: readonly V[], - getOldResolution: (name: string, mode: ResolutionMode) => V | undefined, + getOldResolution: (name: K) => V | undefined, comparer: (oldResolution: V, newResolution: V) => boolean, - nameAndModeGetter: ResolutionNameAndModeGetter, - compilerOptions: CompilerOptions, ): boolean { Debug.assert(names.length === newResolutions.length); for (let i = 0; i < names.length; i++) { const newResolution = newResolutions[i]; const entry = names[i]; - const name = nameAndModeGetter.getName(entry); - const mode = nameAndModeGetter.getMode(entry, newSourceFile, compilerOptions); - const oldResolution = getOldResolution(name, mode); + const oldResolution = getOldResolution(entry); const changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) : newResolution; From c4c170a75ae2c15a5b44e1afc8b1aa2a812b71db Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Tue, 16 Jan 2024 16:06:48 -0800 Subject: [PATCH 26/31] Update API baseline --- tests/baselines/reference/api/typescript.d.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 4e098892ad2d2..774da4bef3290 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -6660,6 +6660,13 @@ declare namespace ts { }; isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; + /** + * Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import + * attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may + * depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other + * `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no + * impact on module resolution, emit, or type checking. + */ getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode; getProjectReferences(): readonly ProjectReference[] | undefined; getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined; @@ -9915,7 +9922,9 @@ declare namespace ts { * Use `program.getModeForUsageLocation`, which retrieves the correct `compilerOptions`, instead of this function whenever possible. * Calculates the final resolution mode for a given module reference node. This is the resolution mode explicitly provided via import * attributes, if present, or the syntax the usage would have if emitted to JavaScript. In `--module node16` or `nodenext`, this may - * depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. + * depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the input syntax of the reference. In other + * `module` modes, when overriding import attributes are not provided, this function returns `undefined`, as the result would have no + * impact on module resolution, emit, or type checking. * @param file The file the import or import-like reference is contained within * @param usage The module reference string * @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options From 902fa1348607f397f1bb1b2e247156d4c98da351 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 17 Jan 2024 12:14:21 -0800 Subject: [PATCH 27/31] Old module specifier nodes not bound in watch/builder programs or something --- src/compiler/program.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 26db3517fb048..708d7bc0935e6 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2541,7 +2541,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg const resolutionsChanged = hasChangesInResolutions( moduleNames, resolutions, - oldProgram.getResolvedModuleFromModuleSpecifier, + name => oldProgram.getResolvedModule(newSourceFile, name.text, oldProgram.getModeForUsageLocation(newSourceFile, name)), moduleResolutionIsEqualTo, ); if (resolutionsChanged) structureIsReused = StructureIsReused.SafeModules; From 2121c2ded8f1033f713d475b66d39c88b26246ca Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 17 Jan 2024 12:15:38 -0800 Subject: [PATCH 28/31] Need ! until LKG bump --- src/compiler/program.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 708d7bc0935e6..86cb0e1f6bd24 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2541,7 +2541,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg const resolutionsChanged = hasChangesInResolutions( moduleNames, resolutions, - name => oldProgram.getResolvedModule(newSourceFile, name.text, oldProgram.getModeForUsageLocation(newSourceFile, name)), + name => oldProgram!.getResolvedModule(newSourceFile, name.text, oldProgram!.getModeForUsageLocation(newSourceFile, name)), moduleResolutionIsEqualTo, ); if (resolutionsChanged) structureIsReused = StructureIsReused.SafeModules; From 2c33ae340f540baf58889235e6a9513e1036efa2 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 17 Jan 2024 15:41:01 -0800 Subject: [PATCH 29/31] Guard against undefined `compilerOptions` in changed public API; expose `program.getModeForResolutionAtIndex` --- src/compiler/program.ts | 22 ++++++++++++++----- src/compiler/types.ts | 8 +++++++ tests/baselines/reference/api/typescript.d.ts | 19 +++++++++++++--- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 86cb0e1f6bd24..d9f1ed9d803cb 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -852,17 +852,22 @@ export function getModeForFileReference(ref: FileReference | string, containingF } /** - * Calculates the final resolution mode for an import at some index within a file's imports list. This is generally the explicitly - * defined mode of the import if provided, or, if not, the mode of the containing file (with some exceptions: import=require is always commonjs, dynamic import is always esm). - * If you have an actual import node, prefer using getModeForUsageLocation on the reference string node. + * Use `program.getModeForResolutionAtIndex`, which retrieves the correct `compilerOptions`, instead of this function whenever possible. + * Calculates the final resolution mode for an import at some index within a file's `imports` list. This is the resolution mode + * explicitly provided via import attributes, if present, or the syntax the usage would have if emitted to JavaScript. In + * `--module node16` or `nodenext`, this may depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the + * input syntax of the reference. In other `module` modes, when overriding import attributes are not provided, this function returns + * `undefined`, as the result would have no impact on module resolution, emit, or type checking. * @param file File to fetch the resolution mode within * @param index Index into the file's complete resolution list to get the resolution of - this is a concatenation of the file's imports and module augmentations + * @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options + * should be the options of the referenced project, not the referencing project. */ export function getModeForResolutionAtIndex(file: SourceFile, index: number, compilerOptions: CompilerOptions): ResolutionMode; /** @internal */ // eslint-disable-next-line @typescript-eslint/unified-signatures export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number, compilerOptions: CompilerOptions): ResolutionMode; -export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number, compilerOptions: CompilerOptions): ResolutionMode { +export function getModeForResolutionAtIndex(file: SourceFileImportsList, index: number, compilerOptions?: CompilerOptions): ResolutionMode { // we ensure all elements of file.imports and file.moduleAugmentations have the relevant parent pointers set during program setup, // so it's safe to use them even pre-bind return getModeForUsageLocationWorker(file, getModuleNameStringLiteralAt(file, index), compilerOptions); @@ -896,7 +901,7 @@ export function getModeForUsageLocation(file: { impliedNodeFormat?: ResolutionMo return getModeForUsageLocationWorker(file, usage, compilerOptions); } -function getModeForUsageLocationWorker(file: { impliedNodeFormat?: ResolutionMode; }, usage: StringLiteralLike, compilerOptions: CompilerOptions) { +function getModeForUsageLocationWorker(file: { impliedNodeFormat?: ResolutionMode; }, usage: StringLiteralLike, compilerOptions?: CompilerOptions) { if ((isImportDeclaration(usage.parent) || isExportDeclaration(usage.parent))) { const isTypeOnly = isExclusivelyTypeOnlyImportOrExport(usage.parent); if (isTypeOnly) { @@ -912,7 +917,7 @@ function getModeForUsageLocationWorker(file: { impliedNodeFormat?: ResolutionMod return override; } } - if (getEmitModuleKind(compilerOptions) === ModuleKind.Preserve) { + if (compilerOptions && getEmitModuleKind(compilerOptions) === ModuleKind.Preserve) { return (usage.parent.parent && isImportEqualsDeclaration(usage.parent.parent) || isRequireCall(usage.parent, /*requireStringLiteralLikeArgument*/ false)) ? ModuleKind.CommonJS : ModuleKind.ESNext; @@ -1898,6 +1903,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg isSourceFileFromExternalLibrary, isSourceFileDefaultLibrary, getModeForUsageLocation, + getModeForResolutionAtIndex, getSourceFileFromReference, getLibFileFromReference, sourceFileToPackageName, @@ -4999,6 +5005,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg const optionsForFile = getRedirectReferenceForResolution(file)?.commandLine.options || options; return getModeForUsageLocationWorker(file, usage, optionsForFile); } + + function getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode { + return getModeForUsageLocation(file, getModuleNameStringLiteralAt(file, index)); + } } interface HostForUseSourceOfProjectReferenceRedirect { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f1da7fed9bc4d..bbba4574b5a98 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4770,6 +4770,14 @@ export interface Program extends ScriptReferenceHost { * impact on module resolution, emit, or type checking. */ getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode; + /** + * Calculates the final resolution mode for an import at some index within a file's `imports` list. This is the resolution mode + * explicitly provided via import attributes, if present, or the syntax the usage would have if emitted to JavaScript. In + * `--module node16` or `nodenext`, this may depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the + * input syntax of the reference. In other `module` modes, when overriding import attributes are not provided, this function returns + * `undefined`, as the result would have no impact on module resolution, emit, or type checking. + */ + getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode; // For testing purposes only. // This is set on created program to let us know how the program was created using old program diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 774da4bef3290..4cd615c365e44 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -6668,6 +6668,14 @@ declare namespace ts { * impact on module resolution, emit, or type checking. */ getModeForUsageLocation(file: SourceFile, usage: StringLiteralLike): ResolutionMode; + /** + * Calculates the final resolution mode for an import at some index within a file's `imports` list. This is the resolution mode + * explicitly provided via import attributes, if present, or the syntax the usage would have if emitted to JavaScript. In + * `--module node16` or `nodenext`, this may depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the + * input syntax of the reference. In other `module` modes, when overriding import attributes are not provided, this function returns + * `undefined`, as the result would have no impact on module resolution, emit, or type checking. + */ + getModeForResolutionAtIndex(file: SourceFile, index: number): ResolutionMode; getProjectReferences(): readonly ProjectReference[] | undefined; getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined; } @@ -9911,11 +9919,16 @@ declare namespace ts { */ function getModeForFileReference(ref: FileReference | string, containingFileMode: ResolutionMode): ResolutionMode; /** - * Calculates the final resolution mode for an import at some index within a file's imports list. This is generally the explicitly - * defined mode of the import if provided, or, if not, the mode of the containing file (with some exceptions: import=require is always commonjs, dynamic import is always esm). - * If you have an actual import node, prefer using getModeForUsageLocation on the reference string node. + * Use `program.getModeForResolutionAtIndex`, which retrieves the correct `compilerOptions`, instead of this function whenever possible. + * Calculates the final resolution mode for an import at some index within a file's `imports` list. This is the resolution mode + * explicitly provided via import attributes, if present, or the syntax the usage would have if emitted to JavaScript. In + * `--module node16` or `nodenext`, this may depend on the file's `impliedNodeFormat`. In `--module preserve`, it depends only on the + * input syntax of the reference. In other `module` modes, when overriding import attributes are not provided, this function returns + * `undefined`, as the result would have no impact on module resolution, emit, or type checking. * @param file File to fetch the resolution mode within * @param index Index into the file's complete resolution list to get the resolution of - this is a concatenation of the file's imports and module augmentations + * @param compilerOptions The compiler options for the program that owns the file. If the file belongs to a referenced project, the compiler options + * should be the options of the referenced project, not the referencing project. */ function getModeForResolutionAtIndex(file: SourceFile, index: number, compilerOptions: CompilerOptions): ResolutionMode; /** From 31119955e1ca9c93722e19d021045c1b40b5d8d7 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 19 Jan 2024 10:59:45 -0800 Subject: [PATCH 30/31] Fix old program resolution lookups --- src/compiler/program.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index d9f1ed9d803cb..6c3608191203b 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2184,7 +2184,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg const moduleName = moduleNames[i]; // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions if (file === oldSourceFile && !hasInvalidatedResolutions(file.path)) { - const oldResolution = oldProgram?.getResolvedModule(file, moduleName.text, oldProgram.getModeForUsageLocation(file, moduleName)); + const oldResolution = oldProgram?.getResolvedModule(file, moduleName.text, getModeForUsageLocation(file, moduleName)); if (oldResolution?.resolvedModule) { if (isTraceEnabled(options, host)) { trace( @@ -2252,7 +2252,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg // If we change our policy of rechecking failed lookups on each program create, // we should adjust the value returned here. function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName: StringLiteralLike): boolean { - const resolutionToFile = oldProgram?.getResolvedModule(file, moduleName.text, oldProgram.getModeForUsageLocation(file, moduleName))?.resolvedModule; + const resolutionToFile = oldProgram?.getResolvedModule(file, moduleName.text, getModeForUsageLocation(file, moduleName))?.resolvedModule; const resolvedFile = resolutionToFile && oldProgram!.getSourceFile(resolutionToFile.resolvedFileName); if (resolutionToFile && resolvedFile) { // In the old program, we resolved to an ambient module that was in the same @@ -2547,7 +2547,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg const resolutionsChanged = hasChangesInResolutions( moduleNames, resolutions, - name => oldProgram!.getResolvedModule(newSourceFile, name.text, oldProgram!.getModeForUsageLocation(newSourceFile, name)), + name => oldProgram!.getResolvedModule(newSourceFile, name.text, getModeForUsageLocation(newSourceFile, name)), moduleResolutionIsEqualTo, ); if (resolutionsChanged) structureIsReused = StructureIsReused.SafeModules; @@ -4044,7 +4044,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg const resolutions = resolvedModulesProcessing?.get(file.path) || resolveModuleNamesReusingOldState(moduleNames, file); Debug.assert(resolutions.length === moduleNames.length); - const optionsForFile = (useSourceOfProjectReferenceRedirect ? getRedirectReferenceForResolution(file)?.commandLine.options : undefined) || options; + const optionsForFile = getRedirectReferenceForResolution(file)?.commandLine.options || options; const resolutionsInFile = createModeAwareCache(); (resolvedModules ??= new Map()).set(file.path, resolutionsInFile); for (let index = 0; index < moduleNames.length; index++) { From eeba65311c77add7498fb4d085a07bb71bdb6c5a Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 19 Jan 2024 11:25:48 -0800 Subject: [PATCH 31/31] Update protocol module/moduleResolution --- src/server/protocol.ts | 8 ++++++++ tests/baselines/reference/api/typescript.d.ts | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/server/protocol.ts b/src/server/protocol.ts index e0964cea6d9d6..29d11637cffb9 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -3751,11 +3751,19 @@ export const enum ModuleKind { ES6 = "ES6", ES2015 = "ES2015", ESNext = "ESNext", + Node16 = "Node16", + NodeNext = "NodeNext", + Preserve = "Preserve", } export const enum ModuleResolutionKind { Classic = "Classic", + /** @deprecated Renamed to `Node10` */ Node = "Node", + Node10 = "Node10", + Node16 = "Node16", + NodeNext = "NodeNext", + Bundler = "Bundler", } export const enum NewLineKind { diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 4cd615c365e44..d4e51ed1759e4 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3036,10 +3036,18 @@ declare namespace ts { ES6 = "ES6", ES2015 = "ES2015", ESNext = "ESNext", + Node16 = "Node16", + NodeNext = "NodeNext", + Preserve = "Preserve", } enum ModuleResolutionKind { Classic = "Classic", + /** @deprecated Renamed to `Node10` */ Node = "Node", + Node10 = "Node10", + Node16 = "Node16", + NodeNext = "NodeNext", + Bundler = "Bundler", } enum NewLineKind { Crlf = "Crlf",