From e9f0a1af539edfb5dde48a257bc4e81520d80968 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 28 Jul 2022 09:20:32 -0700 Subject: [PATCH 01/41] WIP --- src/compiler/commandLineParser.ts | 1 + src/compiler/moduleNameResolver.ts | 67 ++++++++++++++++++- src/compiler/types.ts | 2 + src/testRunner/compilerRunner.ts | 1 + .../moduleResolution/minimal_relative.ts | 47 +++++++++++++ 5 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 tests/cases/conformance/moduleResolution/minimal_relative.ts diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 370461abd8559..646807980fc8f 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -835,6 +835,7 @@ namespace ts { classic: ModuleResolutionKind.Classic, node16: ModuleResolutionKind.Node16, nodenext: ModuleResolutionKind.NodeNext, + minimal: ModuleResolutionKind.Minimal, })), affectsModuleResolution: true, paramType: Diagnostics.STRATEGY, diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 68780ef26aab3..bf8fbb5ca37eb 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -25,6 +25,10 @@ namespace ts { return r && { path: r.path, extension: r.ext, packageId }; } + function createLoaderWithNoPackageId

(loader: (...args: P) => PathAndExtension | undefined): (...args: P) => Resolved | undefined { + return (...args) => noPackageId(loader(...args)); + } + function noPackageId(r: PathAndExtension | undefined): Resolved | undefined { return withPackageId(/*packageInfo*/ undefined, r); } @@ -1013,6 +1017,9 @@ namespace ts { case ModuleResolutionKind.Classic: result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; + case ModuleResolutionKind.Minimal: + result = minimalModuleNameResolver(moduleName, containingFile, compilerOptions, host); + break; default: return Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`); } @@ -1550,7 +1557,10 @@ namespace ts { function loadModuleFromFileNoImplicitExtensions(extensions: Extensions, candidate: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined { // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" - if (hasJSFileExtension(candidate) || (fileExtensionIs(candidate, Extension.Json) && state.compilerOptions.resolveJsonModule)) { + if (hasJSFileExtension(candidate) || + (state.compilerOptions.resolveJsonModule && fileExtensionIs(candidate, Extension.Json)) || + (shouldResolveTsExtension(state.compilerOptions) && fileExtensionIsOneOf(candidate, supportedTSExtensionsFlat)) + ) { const extensionless = removeFileExtension(candidate); const extension = candidate.substring(extensionless.length); if (state.traceEnabled) { @@ -1610,6 +1620,13 @@ namespace ts { case Extension.Json: candidate += Extension.Json; return useDts ? tryExtension(Extension.Dts) : undefined; + case Extension.Ts: + case Extension.Tsx: + case Extension.Dts: + if (shouldResolveTsExtension(state.compilerOptions)) { + return tryExtension(originalExtension); + } + // falls through default: return tryExtension(Extension.Ts) || tryExtension(Extension.Tsx) || (useDts ? tryExtension(Extension.Dts) : undefined); } @@ -2636,6 +2653,54 @@ namespace ts { } } + export function minimalModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations { + const traceEnabled = isTraceEnabled(compilerOptions, host); + const failedLookupLocations: string[] = []; + const affectingLocations: string[] = []; + const containingDirectory = getDirectoryPath(containingFile); + const diagnostics: Diagnostic[] = []; + const state: ModuleResolutionState = { + compilerOptions, + host, + traceEnabled, + failedLookupLocations, + affectingLocations, + packageJsonInfoCache: undefined, + features: NodeResolutionFeatures.None, + conditions: [], + requestContainingDirectory: containingDirectory, + reportDiagnostic: diag => void diagnostics.push(diag), + }; + + const candidate = normalizePath(combinePaths(containingDirectory, moduleName)); + return createResolvedModuleWithFailedLookupLocations( + tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript), + /*isExternalLibraryImport*/ false, + failedLookupLocations, + affectingLocations, + diagnostics, + state.resultFromCache); + + function tryResolve(extensions: Extensions) { + const resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, createLoaderWithNoPackageId(loadModuleFromFileNoImplicitExtensions), state); + if (resolvedUsingSettings) { + return resolvedUsingSettings; + } + const resolvedRelative = loadModuleFromFileNoImplicitExtensions(extensions, candidate, /*onlyRecordFailures*/ false, state); + if (resolvedRelative) { + return noPackageId(resolvedRelative); + } + } + } + + export function shouldResolveTsExtension(compilerOptions: CompilerOptions) { + return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Minimal; + } + + export function shouldAllowTsExtension(compilerOptions: CompilerOptions) { + return shouldResolveTsExtension(compilerOptions) && !!compilerOptions.noEmit; + } + /** * A host may load a module from a global cache of typings. * This is the minumum code needed to expose that functionality; the rest is in the host. diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f93f36c369157..d5e5dbbb27ab2 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -6246,6 +6246,8 @@ namespace ts { // In turn, we offer both a `NodeNext` moving resolution target, and a `Node16` version-anchored resolution target Node16 = 3, NodeNext = 99, // Not simply `Node16` so that compiled code linked against TS can use the `Next` value reliably (same as with `ModuleKind`) + + Minimal = 100, } export enum ModuleDetectionKind { diff --git a/src/testRunner/compilerRunner.ts b/src/testRunner/compilerRunner.ts index a6c67a17ee186..2fcda0891a652 100644 --- a/src/testRunner/compilerRunner.ts +++ b/src/testRunner/compilerRunner.ts @@ -121,6 +121,7 @@ namespace Harness { "moduleDetection", "target", "jsx", + "noEmit", "removeComments", "importHelpers", "importHelpers", diff --git a/tests/cases/conformance/moduleResolution/minimal_relative.ts b/tests/cases/conformance/moduleResolution/minimal_relative.ts new file mode 100644 index 0000000000000..48fda19b7c3eb --- /dev/null +++ b/tests/cases/conformance/moduleResolution/minimal_relative.ts @@ -0,0 +1,47 @@ +// @moduleResolution: minimal +// @outDir: dist +// @noEmit: true,false +// @traceResolution: true + +// @Filename: /project/a.ts +export {}; + +// @Filename: /project/b.ts +export {}; + +// @Filename: /project/b.js +export {}; + +// @Filename: /project/b.d.ts +export {}; + +// @Filename: /project/c.ts +export {}; + +// @Filename: /project/c.tsx +export {}; + +// @Filename: /project/d/index.ts +export {}; + +// @Filename: /project/e +export {}; + +// @Filename: /project/main.ts +import {} from "./a"; +import {} from "./a.js"; +import {} from "./a.ts"; + +import {} from "./b"; +import {} from "./b.js"; +import {} from "./b.ts"; +import {} from "./b.d.ts"; + +import {} from "./c.ts"; +import {} from "./c.tsx"; + +import {} from "./d"; +import {} from "./d/index"; +import {} from "./d/index.ts"; + +import {} from "./e"; From 5f9cf9db8d71dcc98ffe41b49cde8f181b6beb31 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 29 Jul 2022 13:07:11 -0700 Subject: [PATCH 02/41] Add extension error back unless noEmit is set --- src/compiler/checker.ts | 30 +++--- src/compiler/moduleNameResolver.ts | 47 ++++++--- src/compiler/types.ts | 5 + src/services/shims.ts | 2 +- src/testRunner/unittests/moduleResolution.ts | 9 +- src/testRunner/unittests/tscWatch/watchApi.ts | 1 + .../reference/api/tsserverlibrary.d.ts | 11 ++- tests/baselines/reference/api/typescript.d.ts | 11 ++- .../minimal_relative(noemit=false).errors.txt | 95 +++++++++++++++++++ .../minimal_relative(noemit=false).js | 58 +++++++++++ .../minimal_relative(noemit=false).symbols | 38 ++++++++ .../minimal_relative(noemit=false).trace.json | 57 +++++++++++ .../minimal_relative(noemit=false).types | 38 ++++++++ .../minimal_relative(noemit=true).errors.txt | 75 +++++++++++++++ .../minimal_relative(noemit=true).symbols | 38 ++++++++ .../minimal_relative(noemit=true).trace.json | 57 +++++++++++ .../minimal_relative(noemit=true).types | 38 ++++++++ 17 files changed, 582 insertions(+), 28 deletions(-) create mode 100644 tests/baselines/reference/minimal_relative(noemit=false).errors.txt create mode 100644 tests/baselines/reference/minimal_relative(noemit=false).js create mode 100644 tests/baselines/reference/minimal_relative(noemit=false).symbols create mode 100644 tests/baselines/reference/minimal_relative(noemit=false).trace.json create mode 100644 tests/baselines/reference/minimal_relative(noemit=false).types create mode 100644 tests/baselines/reference/minimal_relative(noemit=true).errors.txt create mode 100644 tests/baselines/reference/minimal_relative(noemit=true).symbols create mode 100644 tests/baselines/reference/minimal_relative(noemit=true).trace.json create mode 100644 tests/baselines/reference/minimal_relative(noemit=true).types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7768b78ef3ecd..bbcb97e7c881f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3570,6 +3570,10 @@ namespace ts { if (resolutionDiagnostic) { error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName); } + if (resolvedModule.resolvedUsingTsExtension && !shouldAllowTsExtension(compilerOptions)) { + const tsExtension = Debug.checkDefined(tryExtractTSExtension(moduleReference)); + errorOnTSExtensionImport(tsExtension); + } if (sourceFile.symbol) { if (resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) { errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference); @@ -3642,17 +3646,7 @@ namespace ts { const resolutionIsNode16OrNext = moduleResolutionKind === ModuleResolutionKind.Node16 || moduleResolutionKind === ModuleResolutionKind.NodeNext; if (tsExtension) { - const diag = Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; - const importSourceWithoutExtension = removeExtension(moduleReference, tsExtension); - let replacedImportSource = importSourceWithoutExtension; - /** - * Direct users to import source with .js extension if outputting an ES module. - * @see https://github.com/microsoft/TypeScript/issues/42151 - */ - if (moduleKind >= ModuleKind.ES2015) { - replacedImportSource += tsExtension === Extension.Mts ? ".mjs" : tsExtension === Extension.Cts ? ".cjs" : ".js"; - } - error(errorNode, diag, tsExtension, replacedImportSource); + errorOnTSExtensionImport(tsExtension); } else if (!compilerOptions.resolveJsonModule && fileExtensionIs(moduleReference, Extension.Json) && @@ -3678,6 +3672,20 @@ namespace ts { } } return undefined; + + function errorOnTSExtensionImport(tsExtension: string) { + const diag = Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; + const importSourceWithoutExtension = removeExtension(moduleReference, tsExtension); + let replacedImportSource = importSourceWithoutExtension; + /** + * Direct users to import source with .js extension if outputting an ES module. + * @see https://github.com/microsoft/TypeScript/issues/42151 + */ + if (moduleKind >= ModuleKind.ES2015 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Minimal) { + replacedImportSource += tsExtension === Extension.Mts ? ".mjs" : tsExtension === Extension.Cts ? ".cjs" : ".js"; + } + error(errorNode, diag, tsExtension, replacedImportSource); + } } function errorOnImplicitAnyModule(isError: boolean, errorNode: Node, { packageId, resolvedFileName }: ResolvedModuleFull, moduleReference: string): void { diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index bf8fbb5ca37eb..5bec091015037 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -22,7 +22,7 @@ namespace ts { }; } } - return r && { path: r.path, extension: r.ext, packageId }; + return r && { path: r.path, extension: r.ext, packageId, resolvedUsingTsExtension: r.resolvedUsingTsExtension }; } function createLoaderWithNoPackageId

(loader: (...args: P) => PathAndExtension | undefined): (...args: P) => Resolved | undefined { @@ -36,7 +36,7 @@ namespace ts { function removeIgnoredPackageId(r: Resolved | undefined): PathAndExtension | undefined { if (r) { Debug.assert(r.packageId === undefined); - return { path: r.path, ext: r.extension }; + return { path: r.path, ext: r.extension, resolvedUsingTsExtension: r.resolvedUsingTsExtension }; } } @@ -55,6 +55,7 @@ namespace ts { * Note: This is a file name with preserved original casing, not a normalized `Path`. */ originalPath?: string | true; + resolvedUsingTsExtension: boolean | undefined; } /** Result of trying to resolve a module at a file. Needs to have 'packageId' added later. */ @@ -62,6 +63,7 @@ namespace ts { path: string; // (Use a different name than `extension` to make sure Resolved isn't assignable to PathAndExtension.) ext: Extension; + resolvedUsingTsExtension: boolean | undefined; } /** @@ -104,7 +106,14 @@ namespace ts { return resultFromCache; } return { - resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport, packageId: resolved.packageId }, + resolvedModule: resolved && { + resolvedFileName: resolved.path, + originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, + extension: resolved.extension, + isExternalLibraryImport, + packageId: resolved.packageId, + resolvedUsingTsExtension: !!resolved.resolvedUsingTsExtension, + }, failedLookupLocations, affectingLocations, resolutionDiagnostics: diagnostics, @@ -1573,7 +1582,7 @@ namespace ts { function loadJSOrExactTSFileName(extensions: Extensions, candidate: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined { if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && fileExtensionIsOneOf(candidate, supportedTSExtensionsFlat)) { const result = tryFile(candidate, onlyRecordFailures, state); - return result !== undefined ? { path: candidate, ext: tryExtractTSExtension(candidate) as Extension } : undefined; + return result !== undefined ? { path: candidate, ext: tryExtractTSExtension(candidate) as Extension, resolvedUsingTsExtension: undefined } : undefined; } return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state); @@ -1624,7 +1633,7 @@ namespace ts { case Extension.Tsx: case Extension.Dts: if (shouldResolveTsExtension(state.compilerOptions)) { - return tryExtension(originalExtension); + return tryExtension(originalExtension, /*resolvedUsingTsExtension*/ true); } // falls through default: @@ -1650,9 +1659,9 @@ namespace ts { return tryExtension(Extension.Json); } - function tryExtension(ext: Extension): PathAndExtension | undefined { + function tryExtension(ext: Extension, resolvedUsingTsExtension?: boolean): PathAndExtension | undefined { const path = tryFile(candidate + ext, onlyRecordFailures, state); - return path === undefined ? undefined : { path, ext }; + return path === undefined ? undefined : { path, ext, resolvedUsingTsExtension }; } } @@ -1978,9 +1987,9 @@ namespace ts { } /** Resolve from an arbitrarily specified file. Return `undefined` if it has an unsupported extension. */ - function resolvedIfExtensionMatches(extensions: Extensions, path: string): PathAndExtension | undefined { + function resolvedIfExtensionMatches(extensions: Extensions, path: string, resolvedUsingTsExtension?: boolean): PathAndExtension | undefined { const ext = tryGetExtensionFromPath(path); - return ext !== undefined && extensionIsOk(extensions, ext) ? { path, ext } : undefined; + return ext !== undefined && extensionIsOk(extensions, ext) ? { path, ext, resolvedUsingTsExtension } : undefined; } /** True if `extension` is one of the supported `extensions`. */ @@ -2179,7 +2188,13 @@ namespace ts { if (isImports && !startsWith(target, "../") && !startsWith(target, "/") && !isRootedDiskPath(target)) { const combinedLookup = pattern ? target.replace(/\*/g, subpath) : target + subpath; const result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, [extensions], redirectedReference); - return toSearchResult(result.resolvedModule ? { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId, originalPath: result.resolvedModule.originalPath } : undefined); + return toSearchResult(result.resolvedModule ? { + path: result.resolvedModule.resolvedFileName, + extension: result.resolvedModule.extension, + packageId: result.resolvedModule.packageId, + originalPath: result.resolvedModule.originalPath, + resolvedUsingTsExtension: result.resolvedModule.resolvedUsingTsExtension + } : undefined); } if (state.traceEnabled) { trace(state.host, Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName); @@ -2528,7 +2543,7 @@ namespace ts { if (extension !== undefined) { const path = tryFile(candidate, onlyRecordFailures, state); if (path !== undefined) { - return noPackageId({ path, ext: extension }); + return noPackageId({ path, ext: extension, resolvedUsingTsExtension: undefined }); } } return loader(extensions, candidate, onlyRecordFailures || !directoryProbablyExists(getDirectoryPath(candidate), state.host), state); @@ -2588,7 +2603,15 @@ namespace ts { trace(state.host, Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory); } state.resultFromCache = result; - return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, originalPath: result.resolvedModule.originalPath || true, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } }; + return { + value: result.resolvedModule && { + path: result.resolvedModule.resolvedFileName, + originalPath: result.resolvedModule.originalPath || true, + extension: result.resolvedModule.extension, + packageId: result.resolvedModule.packageId, + resolvedUsingTsExtension: result.resolvedModule.resolvedUsingTsExtension + } + }; } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d5e5dbbb27ab2..4f2c65d876578 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -6853,6 +6853,11 @@ namespace ts { resolvedFileName: string; /** True if `resolvedFileName` comes from `node_modules`. */ isExternalLibraryImport?: boolean; + /** + * True if the original module reference used a .ts extension to refer directly to a .ts file, + * which should produce an error during checking if emit is enabled. + */ + resolvedUsingTsExtension: boolean; } /** diff --git a/src/services/shims.ts b/src/services/shims.ts index 6d313b695ce67..72b7c936863ea 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -362,7 +362,7 @@ namespace ts { const resolutionsInFile = JSON.parse(this.shimHost.getModuleResolutionsForFile!(containingFile)) as MapLike; // TODO: GH#18217 return map(moduleNames, name => { const result = getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result, extension: extensionFromPath(result), isExternalLibraryImport: false } : undefined; + return result ? { resolvedFileName: result, extension: extensionFromPath(result), isExternalLibraryImport: false, resolvedUsingTsExtension: false } : undefined; }); }; } diff --git a/src/testRunner/unittests/moduleResolution.ts b/src/testRunner/unittests/moduleResolution.ts index 1f85f97827c16..abf0c48773385 100644 --- a/src/testRunner/unittests/moduleResolution.ts +++ b/src/testRunner/unittests/moduleResolution.ts @@ -24,8 +24,8 @@ namespace ts { assert.deepEqual(actual.failedLookupLocations, expectedFailedLookupLocations, `Failed lookup locations should match - expected has ${expectedFailedLookupLocations.length}, actual has ${actual.failedLookupLocations.length}`); } - export function createResolvedModule(resolvedFileName: string, isExternalLibraryImport = false): ResolvedModuleFull { - return { resolvedFileName, extension: extensionFromPath(resolvedFileName), isExternalLibraryImport }; + export function createResolvedModule(resolvedFileName: string, isExternalLibraryImport = false, resolvedUsingTsExtension = false): ResolvedModuleFull { + return { resolvedFileName, extension: extensionFromPath(resolvedFileName), isExternalLibraryImport, resolvedUsingTsExtension }; } interface File { @@ -214,6 +214,7 @@ namespace ts { resolvedFileName: "/sub/node_modules/a/index.ts", isExternalLibraryImport: true, extension: Extension.Ts, + resolvedUsingTsExtension: false, }, failedLookupLocations: [], affectingLocations: [], @@ -229,6 +230,7 @@ namespace ts { resolvedFileName: "/sub/directory/node_modules/b/index.ts", isExternalLibraryImport: true, extension: Extension.Ts, + resolvedUsingTsExtension: false, }, failedLookupLocations: [], affectingLocations: [], @@ -246,6 +248,7 @@ namespace ts { resolvedFileName: "/bar/node_modules/c/index.ts", isExternalLibraryImport: true, extension: Extension.Ts, + resolvedUsingTsExtension: false, }, failedLookupLocations: [], affectingLocations: [], @@ -262,6 +265,7 @@ namespace ts { resolvedFileName: "/foo/index.ts", isExternalLibraryImport: true, extension: Extension.Ts, + resolvedUsingTsExtension: false, }, failedLookupLocations: [], affectingLocations: [], @@ -277,6 +281,7 @@ namespace ts { resolvedFileName: "d:/bar/node_modules/e/index.ts", isExternalLibraryImport: true, extension: Extension.Ts, + resolvedUsingTsExtension: false, }, failedLookupLocations: [], affectingLocations: [], diff --git a/src/testRunner/unittests/tscWatch/watchApi.ts b/src/testRunner/unittests/tscWatch/watchApi.ts index 477a982eafde2..89b7359309903 100644 --- a/src/testRunner/unittests/tscWatch/watchApi.ts +++ b/src/testRunner/unittests/tscWatch/watchApi.ts @@ -35,6 +35,7 @@ namespace ts.tscWatch { resolvedFileName: resolvedModule.resolvedFileName, isExternalLibraryImport: resolvedModule.isExternalLibraryImport, originalFileName: resolvedModule.originalPath, + resolvedUsingTsExtension: false, }; }); const watch = createWatchProgram(host); diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index bbc5c38476cdd..1fe485492ffd2 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2926,7 +2926,8 @@ declare namespace ts { Classic = 1, NodeJs = 2, Node16 = 3, - NodeNext = 99 + NodeNext = 99, + Minimal = 100 } export enum ModuleDetectionKind { /** @@ -3221,6 +3222,11 @@ declare namespace ts { resolvedFileName: string; /** True if `resolvedFileName` comes from `node_modules`. */ isExternalLibraryImport?: boolean; + /** + * True if the original module reference used a .ts extension to refer directly to a .ts file, + * which should produce an error during checking if emit is enabled. + */ + resolvedUsingTsExtension: boolean; } /** * ResolvedModule with an explicitly provided `extension` property. @@ -5028,6 +5034,9 @@ declare namespace ts { export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations; export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function minimalModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + export function shouldResolveTsExtension(compilerOptions: CompilerOptions): boolean; + export function shouldAllowTsExtension(compilerOptions: CompilerOptions): boolean; export {}; } declare namespace ts { diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index f9e5f2d0bdebf..62ea676e7dd8d 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2926,7 +2926,8 @@ declare namespace ts { Classic = 1, NodeJs = 2, Node16 = 3, - NodeNext = 99 + NodeNext = 99, + Minimal = 100 } export enum ModuleDetectionKind { /** @@ -3221,6 +3222,11 @@ declare namespace ts { resolvedFileName: string; /** True if `resolvedFileName` comes from `node_modules`. */ isExternalLibraryImport?: boolean; + /** + * True if the original module reference used a .ts extension to refer directly to a .ts file, + * which should produce an error during checking if emit is enabled. + */ + resolvedUsingTsExtension: boolean; } /** * ResolvedModule with an explicitly provided `extension` property. @@ -5028,6 +5034,9 @@ declare namespace ts { export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations; export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function minimalModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; + export function shouldResolveTsExtension(compilerOptions: CompilerOptions): boolean; + export function shouldAllowTsExtension(compilerOptions: CompilerOptions): boolean; export {}; } declare namespace ts { diff --git a/tests/baselines/reference/minimal_relative(noemit=false).errors.txt b/tests/baselines/reference/minimal_relative(noemit=false).errors.txt new file mode 100644 index 0000000000000..fde1ffef20104 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(noemit=false).errors.txt @@ -0,0 +1,95 @@ +error TS5056: Cannot write file 'dist/c.js' because it would be overwritten by multiple input files. +error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. + The file is in the program because: + Root file specified for compilation +error TS6504: File '/project/b.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 +/project/main.ts(1,16): error TS2307: Cannot find module './a' or its corresponding type declarations. +/project/main.ts(3,16): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './a.js' instead. +/project/main.ts(5,16): error TS2307: Cannot find module './b' or its corresponding type declarations. +/project/main.ts(7,16): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './b.js' instead. +/project/main.ts(8,16): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './b.js' instead. +/project/main.ts(10,16): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './c.js' instead. +/project/main.ts(11,16): error TS2691: An import path cannot end with a '.tsx' extension. Consider importing './c.js' instead. +/project/main.ts(11,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. +/project/main.ts(13,16): error TS2307: Cannot find module './d' or its corresponding type declarations. +/project/main.ts(14,16): error TS2307: Cannot find module './d/index' or its corresponding type declarations. +/project/main.ts(15,16): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './d/index.js' instead. +/project/main.ts(17,16): error TS2307: Cannot find module './e' or its corresponding type declarations. + + +!!! error TS5056: Cannot write file 'dist/c.js' because it would be overwritten by multiple input files. +!!! error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. +!!! error TS6231: The file is in the program because: +!!! error TS6231: Root file specified for compilation +!!! error TS6504: File '/project/b.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 +==== /project/a.ts (0 errors) ==== + export {}; + +==== /project/b.ts (0 errors) ==== + export {}; + +==== /project/b.js (0 errors) ==== + export {}; + +==== /project/b.d.ts (0 errors) ==== + export {}; + +==== /project/c.ts (0 errors) ==== + export {}; + +==== /project/c.tsx (0 errors) ==== + export {}; + +==== /project/d/index.ts (0 errors) ==== + export {}; + +==== /project/e (0 errors) ==== + export {}; + +==== /project/main.ts (12 errors) ==== + import {} from "./a"; + ~~~~~ +!!! error TS2307: Cannot find module './a' or its corresponding type declarations. + import {} from "./a.js"; + import {} from "./a.ts"; + ~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.ts' extension. Consider importing './a.js' instead. + + import {} from "./b"; + ~~~~~ +!!! error TS2307: Cannot find module './b' or its corresponding type declarations. + import {} from "./b.js"; + import {} from "./b.ts"; + ~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.ts' extension. Consider importing './b.js' instead. + import {} from "./b.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './b.js' instead. + + import {} from "./c.ts"; + ~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.ts' extension. Consider importing './c.js' instead. + import {} from "./c.tsx"; + ~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.tsx' extension. Consider importing './c.js' instead. + ~~~~~~~~~ +!!! error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. + + import {} from "./d"; + ~~~~~ +!!! error TS2307: Cannot find module './d' or its corresponding type declarations. + import {} from "./d/index"; + ~~~~~~~~~~~ +!!! error TS2307: Cannot find module './d/index' or its corresponding type declarations. + import {} from "./d/index.ts"; + ~~~~~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.ts' extension. Consider importing './d/index.js' instead. + + import {} from "./e"; + ~~~~~ +!!! error TS2307: Cannot find module './e' or its corresponding type declarations. + \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(noemit=false).js b/tests/baselines/reference/minimal_relative(noemit=false).js new file mode 100644 index 0000000000000..ca36c746501fb --- /dev/null +++ b/tests/baselines/reference/minimal_relative(noemit=false).js @@ -0,0 +1,58 @@ +//// [tests/cases/conformance/moduleResolution/minimal_relative.ts] //// + +//// [a.ts] +export {}; + +//// [b.ts] +export {}; + +//// [b.js] +export {}; + +//// [b.d.ts] +export {}; + +//// [c.ts] +export {}; + +//// [c.tsx] +export {}; + +//// [index.ts] +export {}; + +//// [e] +export {}; + +//// [main.ts] +import {} from "./a"; +import {} from "./a.js"; +import {} from "./a.ts"; + +import {} from "./b"; +import {} from "./b.js"; +import {} from "./b.ts"; +import {} from "./b.d.ts"; + +import {} from "./c.ts"; +import {} from "./c.tsx"; + +import {} from "./d"; +import {} from "./d/index"; +import {} from "./d/index.ts"; + +import {} from "./e"; + + +//// [a.js] +"use strict"; +exports.__esModule = true; +//// [b.js] +"use strict"; +exports.__esModule = true; +//// [index.js] +"use strict"; +exports.__esModule = true; +//// [main.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/minimal_relative(noemit=false).symbols b/tests/baselines/reference/minimal_relative(noemit=false).symbols new file mode 100644 index 0000000000000..42b5e186aa78d --- /dev/null +++ b/tests/baselines/reference/minimal_relative(noemit=false).symbols @@ -0,0 +1,38 @@ +=== /project/a.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.tsx === +export {}; +No type information for this code. +No type information for this code.=== /project/d/index.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/main.ts === +import {} from "./a"; +No type information for this code.import {} from "./a.js"; +No type information for this code.import {} from "./a.ts"; +No type information for this code. +No type information for this code.import {} from "./b"; +No type information for this code.import {} from "./b.js"; +No type information for this code.import {} from "./b.ts"; +No type information for this code.import {} from "./b.d.ts"; +No type information for this code. +No type information for this code.import {} from "./c.ts"; +No type information for this code.import {} from "./c.tsx"; +No type information for this code. +No type information for this code.import {} from "./d"; +No type information for this code.import {} from "./d/index"; +No type information for this code.import {} from "./d/index.ts"; +No type information for this code. +No type information for this code.import {} from "./e"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(noemit=false).trace.json b/tests/baselines/reference/minimal_relative(noemit=false).trace.json new file mode 100644 index 0000000000000..33784890cf65f --- /dev/null +++ b/tests/baselines/reference/minimal_relative(noemit=false).trace.json @@ -0,0 +1,57 @@ +[ + "======== Resolving module './a' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './a' was not resolved. ========", + "======== Resolving module './a.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/a.js' has a '.js' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/a.ts' has a '.ts' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './b' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './b' was not resolved. ========", + "======== Resolving module './b.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.js' has a '.js' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.ts' has a '.ts' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/b.d.ts' exist - use it as a name resolution result.", + "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", + "======== Resolving module './c.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/c.ts' has a '.ts' extension - stripping it.", + "File '/project/c.ts' exist - use it as a name resolution result.", + "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", + "======== Resolving module './c.tsx' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", + "File '/project/c.tsx' exist - use it as a name resolution result.", + "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", + "======== Resolving module './d' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './d' was not resolved. ========", + "======== Resolving module './d/index' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './d/index' was not resolved. ========", + "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './e' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './e' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(noemit=false).types b/tests/baselines/reference/minimal_relative(noemit=false).types new file mode 100644 index 0000000000000..42b5e186aa78d --- /dev/null +++ b/tests/baselines/reference/minimal_relative(noemit=false).types @@ -0,0 +1,38 @@ +=== /project/a.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.tsx === +export {}; +No type information for this code. +No type information for this code.=== /project/d/index.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/main.ts === +import {} from "./a"; +No type information for this code.import {} from "./a.js"; +No type information for this code.import {} from "./a.ts"; +No type information for this code. +No type information for this code.import {} from "./b"; +No type information for this code.import {} from "./b.js"; +No type information for this code.import {} from "./b.ts"; +No type information for this code.import {} from "./b.d.ts"; +No type information for this code. +No type information for this code.import {} from "./c.ts"; +No type information for this code.import {} from "./c.tsx"; +No type information for this code. +No type information for this code.import {} from "./d"; +No type information for this code.import {} from "./d/index"; +No type information for this code.import {} from "./d/index.ts"; +No type information for this code. +No type information for this code.import {} from "./e"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(noemit=true).errors.txt b/tests/baselines/reference/minimal_relative(noemit=true).errors.txt new file mode 100644 index 0000000000000..7c405129a243d --- /dev/null +++ b/tests/baselines/reference/minimal_relative(noemit=true).errors.txt @@ -0,0 +1,75 @@ +error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. + The file is in the program because: + Root file specified for compilation +error TS6504: File '/project/b.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 +/project/main.ts(1,16): error TS2307: Cannot find module './a' or its corresponding type declarations. +/project/main.ts(5,16): error TS2307: Cannot find module './b' or its corresponding type declarations. +/project/main.ts(11,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. +/project/main.ts(13,16): error TS2307: Cannot find module './d' or its corresponding type declarations. +/project/main.ts(14,16): error TS2307: Cannot find module './d/index' or its corresponding type declarations. +/project/main.ts(17,16): error TS2307: Cannot find module './e' or its corresponding type declarations. + + +!!! error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. +!!! error TS6231: The file is in the program because: +!!! error TS6231: Root file specified for compilation +!!! error TS6504: File '/project/b.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 +==== /project/a.ts (0 errors) ==== + export {}; + +==== /project/b.ts (0 errors) ==== + export {}; + +==== /project/b.js (0 errors) ==== + export {}; + +==== /project/b.d.ts (0 errors) ==== + export {}; + +==== /project/c.ts (0 errors) ==== + export {}; + +==== /project/c.tsx (0 errors) ==== + export {}; + +==== /project/d/index.ts (0 errors) ==== + export {}; + +==== /project/e (0 errors) ==== + export {}; + +==== /project/main.ts (6 errors) ==== + import {} from "./a"; + ~~~~~ +!!! error TS2307: Cannot find module './a' or its corresponding type declarations. + import {} from "./a.js"; + import {} from "./a.ts"; + + import {} from "./b"; + ~~~~~ +!!! error TS2307: Cannot find module './b' or its corresponding type declarations. + import {} from "./b.js"; + import {} from "./b.ts"; + import {} from "./b.d.ts"; + + import {} from "./c.ts"; + import {} from "./c.tsx"; + ~~~~~~~~~ +!!! error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. + + import {} from "./d"; + ~~~~~ +!!! error TS2307: Cannot find module './d' or its corresponding type declarations. + import {} from "./d/index"; + ~~~~~~~~~~~ +!!! error TS2307: Cannot find module './d/index' or its corresponding type declarations. + import {} from "./d/index.ts"; + + import {} from "./e"; + ~~~~~ +!!! error TS2307: Cannot find module './e' or its corresponding type declarations. + \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(noemit=true).symbols b/tests/baselines/reference/minimal_relative(noemit=true).symbols new file mode 100644 index 0000000000000..42b5e186aa78d --- /dev/null +++ b/tests/baselines/reference/minimal_relative(noemit=true).symbols @@ -0,0 +1,38 @@ +=== /project/a.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.tsx === +export {}; +No type information for this code. +No type information for this code.=== /project/d/index.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/main.ts === +import {} from "./a"; +No type information for this code.import {} from "./a.js"; +No type information for this code.import {} from "./a.ts"; +No type information for this code. +No type information for this code.import {} from "./b"; +No type information for this code.import {} from "./b.js"; +No type information for this code.import {} from "./b.ts"; +No type information for this code.import {} from "./b.d.ts"; +No type information for this code. +No type information for this code.import {} from "./c.ts"; +No type information for this code.import {} from "./c.tsx"; +No type information for this code. +No type information for this code.import {} from "./d"; +No type information for this code.import {} from "./d/index"; +No type information for this code.import {} from "./d/index.ts"; +No type information for this code. +No type information for this code.import {} from "./e"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(noemit=true).trace.json b/tests/baselines/reference/minimal_relative(noemit=true).trace.json new file mode 100644 index 0000000000000..33784890cf65f --- /dev/null +++ b/tests/baselines/reference/minimal_relative(noemit=true).trace.json @@ -0,0 +1,57 @@ +[ + "======== Resolving module './a' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './a' was not resolved. ========", + "======== Resolving module './a.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/a.js' has a '.js' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/a.ts' has a '.ts' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './b' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './b' was not resolved. ========", + "======== Resolving module './b.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.js' has a '.js' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.ts' has a '.ts' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/b.d.ts' exist - use it as a name resolution result.", + "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", + "======== Resolving module './c.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/c.ts' has a '.ts' extension - stripping it.", + "File '/project/c.ts' exist - use it as a name resolution result.", + "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", + "======== Resolving module './c.tsx' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", + "File '/project/c.tsx' exist - use it as a name resolution result.", + "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", + "======== Resolving module './d' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './d' was not resolved. ========", + "======== Resolving module './d/index' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './d/index' was not resolved. ========", + "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './e' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './e' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(noemit=true).types b/tests/baselines/reference/minimal_relative(noemit=true).types new file mode 100644 index 0000000000000..42b5e186aa78d --- /dev/null +++ b/tests/baselines/reference/minimal_relative(noemit=true).types @@ -0,0 +1,38 @@ +=== /project/a.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.tsx === +export {}; +No type information for this code. +No type information for this code.=== /project/d/index.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/main.ts === +import {} from "./a"; +No type information for this code.import {} from "./a.js"; +No type information for this code.import {} from "./a.ts"; +No type information for this code. +No type information for this code.import {} from "./b"; +No type information for this code.import {} from "./b.js"; +No type information for this code.import {} from "./b.ts"; +No type information for this code.import {} from "./b.d.ts"; +No type information for this code. +No type information for this code.import {} from "./c.ts"; +No type information for this code.import {} from "./c.tsx"; +No type information for this code. +No type information for this code.import {} from "./d"; +No type information for this code.import {} from "./d/index"; +No type information for this code.import {} from "./d/index.ts"; +No type information for this code. +No type information for this code.import {} from "./e"; +No type information for this code. +No type information for this code. \ No newline at end of file From 2421cf58ab4527288c26668e0e1e39e19a598dfe Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 29 Jul 2022 13:46:17 -0700 Subject: [PATCH 03/41] Add non-relative tests --- .../reference/minimal_nonRelative.errors.txt | 18 +++++ .../reference/minimal_nonRelative.trace.json | 14 ++++ .../minimal_pathsAndBaseUrl.errors.txt | 38 ++++++++++ .../minimal_pathsAndBaseUrl.trace.json | 73 +++++++++++++++++++ .../moduleResolution/minimal_nonRelative.ts | 14 ++++ .../minimal_pathsAndBaseUrl.ts | 35 +++++++++ 6 files changed, 192 insertions(+) create mode 100644 tests/baselines/reference/minimal_nonRelative.errors.txt create mode 100644 tests/baselines/reference/minimal_nonRelative.trace.json create mode 100644 tests/baselines/reference/minimal_pathsAndBaseUrl.errors.txt create mode 100644 tests/baselines/reference/minimal_pathsAndBaseUrl.trace.json create mode 100644 tests/cases/conformance/moduleResolution/minimal_nonRelative.ts create mode 100644 tests/cases/conformance/moduleResolution/minimal_pathsAndBaseUrl.ts diff --git a/tests/baselines/reference/minimal_nonRelative.errors.txt b/tests/baselines/reference/minimal_nonRelative.errors.txt new file mode 100644 index 0000000000000..9229d86fe597c --- /dev/null +++ b/tests/baselines/reference/minimal_nonRelative.errors.txt @@ -0,0 +1,18 @@ +/main.ts(1,16): error TS2307: Cannot find module 'foo' or its corresponding type declarations. +/main.ts(2,16): error TS2307: Cannot find module 'bar' or its corresponding type declarations. + + +==== /node_modules/@types/foo/index.d.ts (0 errors) ==== + export {}; + +==== /node_modules/bar/index.d.ts (0 errors) ==== + export {}; + +==== /main.ts (2 errors) ==== + import {} from "foo"; + ~~~~~ +!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. + import {} from "bar"; + ~~~~~ +!!! error TS2307: Cannot find module 'bar' or its corresponding type declarations. + \ No newline at end of file diff --git a/tests/baselines/reference/minimal_nonRelative.trace.json b/tests/baselines/reference/minimal_nonRelative.trace.json new file mode 100644 index 0000000000000..769cebfe4261f --- /dev/null +++ b/tests/baselines/reference/minimal_nonRelative.trace.json @@ -0,0 +1,14 @@ +[ + "======== Resolving module 'foo' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name 'foo' was not resolved. ========", + "======== Resolving module 'bar' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name 'bar' was not resolved. ========", + "======== Resolving type reference directive 'foo', containing file '__inferred type names__.ts', root directory '/node_modules/@types'. ========", + "Resolving with primary search path '/node_modules/@types'.", + "File '/node_modules/@types/foo/package.json' does not exist.", + "File '/node_modules/@types/foo/index.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/@types/foo/index.d.ts', result '/node_modules/@types/foo/index.d.ts'.", + "======== Type reference directive 'foo' was successfully resolved to '/node_modules/@types/foo/index.d.ts', primary: true. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/minimal_pathsAndBaseUrl.errors.txt b/tests/baselines/reference/minimal_pathsAndBaseUrl.errors.txt new file mode 100644 index 0000000000000..a1b7074087d13 --- /dev/null +++ b/tests/baselines/reference/minimal_pathsAndBaseUrl.errors.txt @@ -0,0 +1,38 @@ +/main.ts(4,16): error TS2307: Cannot find module 'hello' or its corresponding type declarations. + + +==== /tsconfig.json (0 errors) ==== + { + "compilerOptions": { + "moduleResolution": "minimal", + "noEmit": true, + "baseUrl": ".", + "paths": { + "*": [ + "*", + "./vendor/*", + "./vendor/*/index.d.ts", + "./apps/*" + ] + } + } + } + +==== /vendor/foo/index.d.ts (0 errors) ==== + export {}; + +==== /apps/hello.ts (0 errors) ==== + export {}; + +==== /foo.ts (0 errors) ==== + export {}; + +==== /main.ts (1 errors) ==== + import {} from "foo"; + import {} from "foo/index.js"; + import {} from "hello.ts"; + import {} from "hello"; + ~~~~~~~ +!!! error TS2307: Cannot find module 'hello' or its corresponding type declarations. + import {} from "foo.js"; + \ No newline at end of file diff --git a/tests/baselines/reference/minimal_pathsAndBaseUrl.trace.json b/tests/baselines/reference/minimal_pathsAndBaseUrl.trace.json new file mode 100644 index 0000000000000..9d8aa1165d31a --- /dev/null +++ b/tests/baselines/reference/minimal_pathsAndBaseUrl.trace.json @@ -0,0 +1,73 @@ +[ + "======== Resolving module 'foo' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo'.", + "'paths' option is specified, looking for a pattern to match module name 'foo'.", + "Module name 'foo', matched pattern '*'.", + "Trying substitution '*', candidate module location: 'foo'.", + "Trying substitution './vendor/*', candidate module location: './vendor/foo'.", + "Trying substitution './vendor/*/index.d.ts', candidate module location: './vendor/foo/index.d.ts'.", + "File '/vendor/foo/index.d.ts' exist - use it as a name resolution result.", + "======== Module name 'foo' was successfully resolved to '/vendor/foo/index.d.ts'. ========", + "======== Resolving module 'foo/index.js' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo/index.js'.", + "'paths' option is specified, looking for a pattern to match module name 'foo/index.js'.", + "Module name 'foo/index.js', matched pattern '*'.", + "Trying substitution '*', candidate module location: 'foo/index.js'.", + "File name '/foo/index.js' has a '.js' extension - stripping it.", + "Trying substitution './vendor/*', candidate module location: './vendor/foo/index.js'.", + "File name '/vendor/foo/index.js' has a '.js' extension - stripping it.", + "File '/vendor/foo/index.ts' does not exist.", + "File '/vendor/foo/index.tsx' does not exist.", + "File '/vendor/foo/index.d.ts' exist - use it as a name resolution result.", + "======== Module name 'foo/index.js' was successfully resolved to '/vendor/foo/index.d.ts'. ========", + "======== Resolving module 'hello.ts' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'hello.ts'.", + "'paths' option is specified, looking for a pattern to match module name 'hello.ts'.", + "Module name 'hello.ts', matched pattern '*'.", + "Trying substitution '*', candidate module location: 'hello.ts'.", + "File name '/hello.ts' has a '.ts' extension - stripping it.", + "File '/hello.ts' does not exist.", + "Trying substitution './vendor/*', candidate module location: './vendor/hello.ts'.", + "File name '/vendor/hello.ts' has a '.ts' extension - stripping it.", + "File '/vendor/hello.ts' does not exist.", + "Trying substitution './vendor/*/index.d.ts', candidate module location: './vendor/hello.ts/index.d.ts'.", + "File '/vendor/hello.ts/index.d.ts' does not exist.", + "File name '/vendor/hello.ts/index.d.ts' has a '.d.ts' extension - stripping it.", + "Trying substitution './apps/*', candidate module location: './apps/hello.ts'.", + "File name '/apps/hello.ts' has a '.ts' extension - stripping it.", + "File '/apps/hello.ts' exist - use it as a name resolution result.", + "======== Module name 'hello.ts' was successfully resolved to '/apps/hello.ts'. ========", + "======== Resolving module 'hello' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'hello'.", + "'paths' option is specified, looking for a pattern to match module name 'hello'.", + "Module name 'hello', matched pattern '*'.", + "Trying substitution '*', candidate module location: 'hello'.", + "Trying substitution './vendor/*', candidate module location: './vendor/hello'.", + "Trying substitution './vendor/*/index.d.ts', candidate module location: './vendor/hello/index.d.ts'.", + "File '/vendor/hello/index.d.ts' does not exist.", + "File name '/vendor/hello/index.d.ts' has a '.d.ts' extension - stripping it.", + "Trying substitution './apps/*', candidate module location: './apps/hello'.", + "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'hello'.", + "'paths' option is specified, looking for a pattern to match module name 'hello'.", + "Module name 'hello', matched pattern '*'.", + "Trying substitution '*', candidate module location: 'hello'.", + "Trying substitution './vendor/*', candidate module location: './vendor/hello'.", + "Trying substitution './vendor/*/index.d.ts', candidate module location: './vendor/hello/index.d.ts'.", + "File '/vendor/hello/index.d.ts' does not exist.", + "File name '/vendor/hello/index.d.ts' has a '.d.ts' extension - stripping it.", + "Trying substitution './apps/*', candidate module location: './apps/hello'.", + "======== Module name 'hello' was not resolved. ========", + "======== Resolving module 'foo.js' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo.js'.", + "'paths' option is specified, looking for a pattern to match module name 'foo.js'.", + "Module name 'foo.js', matched pattern '*'.", + "Trying substitution '*', candidate module location: 'foo.js'.", + "File name '/foo.js' has a '.js' extension - stripping it.", + "File '/foo.ts' exist - use it as a name resolution result.", + "======== Module name 'foo.js' was successfully resolved to '/foo.ts'. ========" +] \ No newline at end of file diff --git a/tests/cases/conformance/moduleResolution/minimal_nonRelative.ts b/tests/cases/conformance/moduleResolution/minimal_nonRelative.ts new file mode 100644 index 0000000000000..e055574fc2739 --- /dev/null +++ b/tests/cases/conformance/moduleResolution/minimal_nonRelative.ts @@ -0,0 +1,14 @@ +// @moduleResolution: minimal +// @noEmit: true +// @traceResolution: true +// @noTypesAndSymbols: true + +// @Filename: /node_modules/@types/foo/index.d.ts +export {}; + +// @Filename: /node_modules/bar/index.d.ts +export {}; + +// @Filename: /main.ts +import {} from "foo"; +import {} from "bar"; diff --git a/tests/cases/conformance/moduleResolution/minimal_pathsAndBaseUrl.ts b/tests/cases/conformance/moduleResolution/minimal_pathsAndBaseUrl.ts new file mode 100644 index 0000000000000..a7fb1a2c4ebb6 --- /dev/null +++ b/tests/cases/conformance/moduleResolution/minimal_pathsAndBaseUrl.ts @@ -0,0 +1,35 @@ +// @traceResolution: true +// @noTypesAndSymbols: true + +// @Filename: /tsconfig.json +{ + "compilerOptions": { + "moduleResolution": "minimal", + "noEmit": true, + "baseUrl": ".", + "paths": { + "*": [ + "*", + "./vendor/*", + "./vendor/*/index.d.ts", + "./apps/*" + ] + } + } +} + +// @Filename: /vendor/foo/index.d.ts +export {}; + +// @Filename: /apps/hello.ts +export {}; + +// @Filename: /foo.ts +export {}; + +// @Filename: /main.ts +import {} from "foo"; +import {} from "foo/index.js"; +import {} from "hello.ts"; +import {} from "hello"; +import {} from "foo.js"; From 660026e966000df368516a156f53e3652f913ef2 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 29 Jul 2022 15:02:41 -0700 Subject: [PATCH 04/41] Add error for importing from declaration file --- src/compiler/checker.ts | 24 +++++++++++++++---- src/compiler/diagnosticMessages.json | 4 ++++ .../minimal_relative(noemit=false).errors.txt | 19 ++++++++------- .../minimal_relative(noemit=false).js | 1 + .../minimal_relative(noemit=false).symbols | 1 + .../minimal_relative(noemit=false).types | 1 + .../minimal_relative(noemit=true).errors.txt | 14 +++++++---- .../minimal_relative(noemit=true).symbols | 1 + .../minimal_relative(noemit=true).types | 1 + .../moduleResolution/minimal_relative.ts | 1 + 10 files changed, 49 insertions(+), 18 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bbcb97e7c881f..eb5d398dc4c35 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3570,10 +3570,23 @@ namespace ts { if (resolutionDiagnostic) { error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName); } - if (resolvedModule.resolvedUsingTsExtension && !shouldAllowTsExtension(compilerOptions)) { + + if (resolvedModule.resolvedUsingTsExtension && isDeclarationFileName(moduleReference)) { + const importOrExport = + findAncestor(location, isImportDeclaration)?.importClause || + findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration)) as ImportEqualsDeclaration | ExportDeclaration | undefined; + if (importOrExport && !importOrExport.isTypeOnly || findAncestor(location, isImportCall)) { + error( + errorNode, + Diagnostics.A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead, + getSuggestedImportSource(Debug.checkDefined(tryExtractTSExtension(moduleReference)))); + } + } + else if (resolvedModule.resolvedUsingTsExtension && !shouldAllowTsExtension(compilerOptions)) { const tsExtension = Debug.checkDefined(tryExtractTSExtension(moduleReference)); errorOnTSExtensionImport(tsExtension); } + if (sourceFile.symbol) { if (resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) { errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference); @@ -3675,16 +3688,19 @@ namespace ts { function errorOnTSExtensionImport(tsExtension: string) { const diag = Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; + error(errorNode, diag, tsExtension, getSuggestedImportSource(tsExtension)); + } + + function getSuggestedImportSource(tsExtension: string) { const importSourceWithoutExtension = removeExtension(moduleReference, tsExtension); - let replacedImportSource = importSourceWithoutExtension; /** * Direct users to import source with .js extension if outputting an ES module. * @see https://github.com/microsoft/TypeScript/issues/42151 */ if (moduleKind >= ModuleKind.ES2015 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Minimal) { - replacedImportSource += tsExtension === Extension.Mts ? ".mjs" : tsExtension === Extension.Cts ? ".cjs" : ".js"; + return importSourceWithoutExtension + (tsExtension === Extension.Mts ? ".mjs" : tsExtension === Extension.Cts ? ".cjs" : ".js"); } - error(errorNode, diag, tsExtension, replacedImportSource); + return importSourceWithoutExtension; } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index dc22ff2b4b7e3..718d8845e85bc 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3515,6 +3515,10 @@ "category": "Error", "code": 2844 }, + "A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '{0}' instead?": { + "category": "Error", + "code": 2845 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/tests/baselines/reference/minimal_relative(noemit=false).errors.txt b/tests/baselines/reference/minimal_relative(noemit=false).errors.txt index fde1ffef20104..04640dbdd2934 100644 --- a/tests/baselines/reference/minimal_relative(noemit=false).errors.txt +++ b/tests/baselines/reference/minimal_relative(noemit=false).errors.txt @@ -9,14 +9,14 @@ error TS6504: File '/project/b.js' is a JavaScript file. Did you mean to enable /project/main.ts(3,16): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './a.js' instead. /project/main.ts(5,16): error TS2307: Cannot find module './b' or its corresponding type declarations. /project/main.ts(7,16): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './b.js' instead. -/project/main.ts(8,16): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './b.js' instead. -/project/main.ts(10,16): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './c.js' instead. -/project/main.ts(11,16): error TS2691: An import path cannot end with a '.tsx' extension. Consider importing './c.js' instead. -/project/main.ts(11,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. -/project/main.ts(13,16): error TS2307: Cannot find module './d' or its corresponding type declarations. -/project/main.ts(14,16): error TS2307: Cannot find module './d/index' or its corresponding type declarations. -/project/main.ts(15,16): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './d/index.js' instead. -/project/main.ts(17,16): error TS2307: Cannot find module './e' or its corresponding type declarations. +/project/main.ts(8,16): error TS2845: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? +/project/main.ts(11,16): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './c.js' instead. +/project/main.ts(12,16): error TS2691: An import path cannot end with a '.tsx' extension. Consider importing './c.js' instead. +/project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. +/project/main.ts(14,16): error TS2307: Cannot find module './d' or its corresponding type declarations. +/project/main.ts(15,16): error TS2307: Cannot find module './d/index' or its corresponding type declarations. +/project/main.ts(16,16): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './d/index.js' instead. +/project/main.ts(18,16): error TS2307: Cannot find module './e' or its corresponding type declarations. !!! error TS5056: Cannot write file 'dist/c.js' because it would be overwritten by multiple input files. @@ -68,7 +68,8 @@ error TS6504: File '/project/b.js' is a JavaScript file. Did you mean to enable !!! error TS2691: An import path cannot end with a '.ts' extension. Consider importing './b.js' instead. import {} from "./b.d.ts"; ~~~~~~~~~~ -!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './b.js' instead. +!!! error TS2845: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? + import type {} from "./b.d.ts"; import {} from "./c.ts"; ~~~~~~~~ diff --git a/tests/baselines/reference/minimal_relative(noemit=false).js b/tests/baselines/reference/minimal_relative(noemit=false).js index ca36c746501fb..4044dbad4adb8 100644 --- a/tests/baselines/reference/minimal_relative(noemit=false).js +++ b/tests/baselines/reference/minimal_relative(noemit=false).js @@ -33,6 +33,7 @@ import {} from "./b"; import {} from "./b.js"; import {} from "./b.ts"; import {} from "./b.d.ts"; +import type {} from "./b.d.ts"; import {} from "./c.ts"; import {} from "./c.tsx"; diff --git a/tests/baselines/reference/minimal_relative(noemit=false).symbols b/tests/baselines/reference/minimal_relative(noemit=false).symbols index 42b5e186aa78d..13a097c71c1b7 100644 --- a/tests/baselines/reference/minimal_relative(noemit=false).symbols +++ b/tests/baselines/reference/minimal_relative(noemit=false).symbols @@ -25,6 +25,7 @@ No type information for this code.import {} from "./b"; No type information for this code.import {} from "./b.js"; No type information for this code.import {} from "./b.ts"; No type information for this code.import {} from "./b.d.ts"; +No type information for this code.import type {} from "./b.d.ts"; No type information for this code. No type information for this code.import {} from "./c.ts"; No type information for this code.import {} from "./c.tsx"; diff --git a/tests/baselines/reference/minimal_relative(noemit=false).types b/tests/baselines/reference/minimal_relative(noemit=false).types index 42b5e186aa78d..13a097c71c1b7 100644 --- a/tests/baselines/reference/minimal_relative(noemit=false).types +++ b/tests/baselines/reference/minimal_relative(noemit=false).types @@ -25,6 +25,7 @@ No type information for this code.import {} from "./b"; No type information for this code.import {} from "./b.js"; No type information for this code.import {} from "./b.ts"; No type information for this code.import {} from "./b.d.ts"; +No type information for this code.import type {} from "./b.d.ts"; No type information for this code. No type information for this code.import {} from "./c.ts"; No type information for this code.import {} from "./c.tsx"; diff --git a/tests/baselines/reference/minimal_relative(noemit=true).errors.txt b/tests/baselines/reference/minimal_relative(noemit=true).errors.txt index 7c405129a243d..b5584db1abe5f 100644 --- a/tests/baselines/reference/minimal_relative(noemit=true).errors.txt +++ b/tests/baselines/reference/minimal_relative(noemit=true).errors.txt @@ -6,10 +6,11 @@ error TS6504: File '/project/b.js' is a JavaScript file. Did you mean to enable Root file specified for compilation /project/main.ts(1,16): error TS2307: Cannot find module './a' or its corresponding type declarations. /project/main.ts(5,16): error TS2307: Cannot find module './b' or its corresponding type declarations. -/project/main.ts(11,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. -/project/main.ts(13,16): error TS2307: Cannot find module './d' or its corresponding type declarations. -/project/main.ts(14,16): error TS2307: Cannot find module './d/index' or its corresponding type declarations. -/project/main.ts(17,16): error TS2307: Cannot find module './e' or its corresponding type declarations. +/project/main.ts(8,16): error TS2845: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? +/project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. +/project/main.ts(14,16): error TS2307: Cannot find module './d' or its corresponding type declarations. +/project/main.ts(15,16): error TS2307: Cannot find module './d/index' or its corresponding type declarations. +/project/main.ts(18,16): error TS2307: Cannot find module './e' or its corresponding type declarations. !!! error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. @@ -42,7 +43,7 @@ error TS6504: File '/project/b.js' is a JavaScript file. Did you mean to enable ==== /project/e (0 errors) ==== export {}; -==== /project/main.ts (6 errors) ==== +==== /project/main.ts (7 errors) ==== import {} from "./a"; ~~~~~ !!! error TS2307: Cannot find module './a' or its corresponding type declarations. @@ -55,6 +56,9 @@ error TS6504: File '/project/b.js' is a JavaScript file. Did you mean to enable import {} from "./b.js"; import {} from "./b.ts"; import {} from "./b.d.ts"; + ~~~~~~~~~~ +!!! error TS2845: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? + import type {} from "./b.d.ts"; import {} from "./c.ts"; import {} from "./c.tsx"; diff --git a/tests/baselines/reference/minimal_relative(noemit=true).symbols b/tests/baselines/reference/minimal_relative(noemit=true).symbols index 42b5e186aa78d..13a097c71c1b7 100644 --- a/tests/baselines/reference/minimal_relative(noemit=true).symbols +++ b/tests/baselines/reference/minimal_relative(noemit=true).symbols @@ -25,6 +25,7 @@ No type information for this code.import {} from "./b"; No type information for this code.import {} from "./b.js"; No type information for this code.import {} from "./b.ts"; No type information for this code.import {} from "./b.d.ts"; +No type information for this code.import type {} from "./b.d.ts"; No type information for this code. No type information for this code.import {} from "./c.ts"; No type information for this code.import {} from "./c.tsx"; diff --git a/tests/baselines/reference/minimal_relative(noemit=true).types b/tests/baselines/reference/minimal_relative(noemit=true).types index 42b5e186aa78d..13a097c71c1b7 100644 --- a/tests/baselines/reference/minimal_relative(noemit=true).types +++ b/tests/baselines/reference/minimal_relative(noemit=true).types @@ -25,6 +25,7 @@ No type information for this code.import {} from "./b"; No type information for this code.import {} from "./b.js"; No type information for this code.import {} from "./b.ts"; No type information for this code.import {} from "./b.d.ts"; +No type information for this code.import type {} from "./b.d.ts"; No type information for this code. No type information for this code.import {} from "./c.ts"; No type information for this code.import {} from "./c.tsx"; diff --git a/tests/cases/conformance/moduleResolution/minimal_relative.ts b/tests/cases/conformance/moduleResolution/minimal_relative.ts index 48fda19b7c3eb..b3428c435e48a 100644 --- a/tests/cases/conformance/moduleResolution/minimal_relative.ts +++ b/tests/cases/conformance/moduleResolution/minimal_relative.ts @@ -36,6 +36,7 @@ import {} from "./b"; import {} from "./b.js"; import {} from "./b.ts"; import {} from "./b.d.ts"; +import type {} from "./b.d.ts"; import {} from "./c.ts"; import {} from "./c.tsx"; From f49a36851f8425d957a6b3259d4cd79479f6e605 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 14 Sep 2022 14:05:41 -0700 Subject: [PATCH 05/41] Update unit test --- src/testRunner/unittests/config/commandLineParsing.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index e2b48977106b6..07ecbb7393328 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -237,7 +237,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.", + messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext', 'minimal'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, From af03675a085d6b799b8b7ce7e8f6f4baf4008ea9 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 14 Sep 2022 16:52:42 -0700 Subject: [PATCH 06/41] Add explicit flag for importing from .ts extensions --- src/compiler/checker.ts | 4 +- src/compiler/commandLineParser.ts | 8 ++ src/compiler/diagnosticMessages.json | 16 ++- src/compiler/moduleNameResolver.ts | 8 +- src/compiler/program.ts | 4 + src/compiler/types.ts | 1 + src/testRunner/compilerRunner.ts | 1 + .../minimal_pathsAndBaseUrl.errors.txt | 1 + ...sextensions=false,noemit=false).errors.txt | 107 ++++++++++++++++++ ...portingtsextensions=false,noemit=false).js | 64 +++++++++++ ...ngtsextensions=false,noemit=false).symbols | 44 +++++++ ...sextensions=false,noemit=false).trace.json | 68 +++++++++++ ...tingtsextensions=false,noemit=false).types | 44 +++++++ ...tsextensions=false,noemit=true).errors.txt | 105 +++++++++++++++++ ...ingtsextensions=false,noemit=true).symbols | 44 +++++++ ...tsextensions=false,noemit=true).trace.json | 68 +++++++++++ ...rtingtsextensions=false,noemit=true).types | 44 +++++++ ...tsextensions=true,noemit=false).errors.txt | 94 +++++++++++++++ ...mportingtsextensions=true,noemit=false).js | 64 +++++++++++ ...ingtsextensions=true,noemit=false).symbols | 44 +++++++ ...tsextensions=true,noemit=false).trace.json | 68 +++++++++++ ...rtingtsextensions=true,noemit=false).types | 44 +++++++ ...gtsextensions=true,noemit=true).errors.txt | 90 +++++++++++++++ ...tingtsextensions=true,noemit=true).symbols | 44 +++++++ ...gtsextensions=true,noemit=true).trace.json | 68 +++++++++++ ...ortingtsextensions=true,noemit=true).types | 44 +++++++ .../minimal_pathsAndBaseUrl.ts | 1 + .../moduleResolution/minimal_relative.ts | 6 + 28 files changed, 1190 insertions(+), 8 deletions(-) create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).errors.txt create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).js create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).symbols create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).trace.json create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).types create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).errors.txt create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).symbols create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).trace.json create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).types create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).errors.txt create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).js create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).symbols create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).trace.json create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).types create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).errors.txt create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).symbols create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).trace.json create mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d7d6c3148b9e4..36e21f63f35d5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3620,9 +3620,9 @@ namespace ts { getSuggestedImportSource(Debug.checkDefined(tryExtractTSExtension(moduleReference)))); } } - else if (resolvedModule.resolvedUsingTsExtension && !shouldAllowTsExtension(compilerOptions)) { + else if (resolvedModule.resolvedUsingTsExtension && !shouldAllowImportingTsExtension(compilerOptions, currentSourceFile.fileName)) { const tsExtension = Debug.checkDefined(tryExtractTSExtension(moduleReference)); - errorOnTSExtensionImport(tsExtension); + error(errorNode, Diagnostics.An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled, tsExtension); } if (sourceFile.symbol) { diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 541871714593f..f3ffc50336dc0 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -956,6 +956,14 @@ namespace ts { category: Diagnostics.Modules, description: Diagnostics.List_of_file_name_suffixes_to_search_when_resolving_a_module, }, + { + name: "allowImportingTsExtensions", + type: "boolean", + affectsModuleResolution: true, + category: Diagnostics.Modules, + description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_minimal_and_either_noEmit_or_emitDeclarationOnly_to_be_set, + defaultValueDescription: false, + }, // Source Maps { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4d74c87d16799..c6614d6482b14 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4229,6 +4229,14 @@ "category": "Error", "code": 5095 }, + "Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'minimal' and either 'noEmit' or 'emitDeclarationOnly' is set.": { + "category": "Error", + "code": 5096 + }, + "An import path can only end with a '{0}' extension when 'allowImportingTsExtensions' is enabled.": { + "category": "Error", + "code": 5097 + }, "Generates a sourcemap for each corresponding '.d.ts' file.": { "category": "Message", @@ -4451,10 +4459,6 @@ "category": "Message", "code": 6066 }, - "Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6).": { - "category": "Message", - "code": 6069 - }, "Initializes a TypeScript project and creates a tsconfig.json file.": { "category": "Message", "code": 6070 @@ -5418,6 +5422,10 @@ "category": "Message", "code": 6401 }, + "Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set.": { + "category": "Message", + "code": 6402 + }, "The expected type comes from property '{0}' which is declared here on type '{1}'": { "category": "Message", diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index c61ba110532bb..6fc614ab5dc1a 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -2716,8 +2716,12 @@ namespace ts { return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Minimal; } - export function shouldAllowTsExtension(compilerOptions: CompilerOptions) { - return shouldResolveTsExtension(compilerOptions) && !!compilerOptions.noEmit; + // Program errors validate that `noEmit` or `emitDeclarationOnly` is also set, + // so this function doesn't check them to avoid propagating errors. + export function shouldAllowImportingTsExtension(compilerOptions: CompilerOptions, fromFileName?: string) { + return shouldResolveTsExtension(compilerOptions) && ( + !!compilerOptions.allowImportingTsExtensions || + fromFileName && isDeclarationFileName(fromFileName)); } /** diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 412f307eae4bf..676c5507ee143 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -3657,6 +3657,10 @@ namespace ts { createOptionValueDiagnostic("importsNotUsedAsValues", Diagnostics.Option_preserveValueImports_can_only_be_used_when_module_is_set_to_es2015_or_later); } + if (options.allowImportingTsExtensions && !(getEmitModuleResolutionKind(options) === ModuleResolutionKind.Minimal && (options.noEmit || options.emitDeclarationOnly))) { + createOptionValueDiagnostic("allowImportingTsExtensions", Diagnostics.Option_allowImportingTsExtensions_can_only_be_used_when_moduleResolution_is_set_to_minimal_and_either_noEmit_or_emitDeclarationOnly_is_set); + } + // If the emit is enabled make sure that every output file is unique and not overwriting any of the input files if (!options.noEmit && !options.suppressOutputPathCheck) { const emitHost = getEmitHost(); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index fa3fdd92df5e0..2790fb700ffa3 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -6543,6 +6543,7 @@ namespace ts { export interface CompilerOptions { /*@internal*/ all?: boolean; + allowImportingTsExtensions?: boolean; allowJs?: boolean; /*@internal*/ allowNonTsExtensions?: boolean; allowSyntheticDefaultImports?: boolean; diff --git a/src/testRunner/compilerRunner.ts b/src/testRunner/compilerRunner.ts index 00daa90668848..22ae1b9c6e469 100644 --- a/src/testRunner/compilerRunner.ts +++ b/src/testRunner/compilerRunner.ts @@ -119,6 +119,7 @@ namespace Harness { "module", "moduleResolution", "moduleDetection", + "allowImportingTsExtensions", "target", "jsx", "noEmit", diff --git a/tests/baselines/reference/minimal_pathsAndBaseUrl.errors.txt b/tests/baselines/reference/minimal_pathsAndBaseUrl.errors.txt index a1b7074087d13..31490691952d2 100644 --- a/tests/baselines/reference/minimal_pathsAndBaseUrl.errors.txt +++ b/tests/baselines/reference/minimal_pathsAndBaseUrl.errors.txt @@ -6,6 +6,7 @@ "compilerOptions": { "moduleResolution": "minimal", "noEmit": true, + "allowImportingTsExtensions": true, "baseUrl": ".", "paths": { "*": [ diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).errors.txt b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).errors.txt new file mode 100644 index 0000000000000..1a1ce3a5447b2 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).errors.txt @@ -0,0 +1,107 @@ +error TS5056: Cannot write file 'dist/c.js' because it would be overwritten by multiple input files. +error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. + The file is in the program because: + Root file specified for compilation +error TS6504: File '/project/b.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 +/project/main.ts(1,16): error TS2307: Cannot find module './a' or its corresponding type declarations. +/project/main.ts(3,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(5,16): error TS2307: Cannot find module './b' or its corresponding type declarations. +/project/main.ts(7,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(8,16): error TS2845: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? +/project/main.ts(11,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(12,16): error TS5097: An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. +/project/main.ts(14,16): error TS2307: Cannot find module './d' or its corresponding type declarations. +/project/main.ts(15,16): error TS2307: Cannot find module './d/index' or its corresponding type declarations. +/project/main.ts(16,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(18,16): error TS2307: Cannot find module './e' or its corresponding type declarations. +/project/types.d.ts(2,16): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. +/project/types.d.ts(3,21): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. + + +!!! error TS5056: Cannot write file 'dist/c.js' because it would be overwritten by multiple input files. +!!! error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. +!!! error TS6231: The file is in the program because: +!!! error TS6231: Root file specified for compilation +!!! error TS6504: File '/project/b.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 +==== /project/a.ts (0 errors) ==== + export {}; + +==== /project/b.ts (0 errors) ==== + export {}; + +==== /project/b.js (0 errors) ==== + export {}; + +==== /project/b.d.ts (0 errors) ==== + export {}; + +==== /project/c.ts (0 errors) ==== + export {}; + +==== /project/c.tsx (0 errors) ==== + export {}; + +==== /project/d/index.ts (0 errors) ==== + export {}; + +==== /project/e (0 errors) ==== + export {}; + +==== /project/main.ts (12 errors) ==== + import {} from "./a"; + ~~~~~ +!!! error TS2307: Cannot find module './a' or its corresponding type declarations. + import {} from "./a.js"; + import {} from "./a.ts"; + ~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + + import {} from "./b"; + ~~~~~ +!!! error TS2307: Cannot find module './b' or its corresponding type declarations. + import {} from "./b.js"; + import {} from "./b.ts"; + ~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + import {} from "./b.d.ts"; + ~~~~~~~~~~ +!!! error TS2845: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? + import type {} from "./b.d.ts"; + + import {} from "./c.ts"; + ~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + import {} from "./c.tsx"; + ~~~~~~~~~ +!!! error TS5097: An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled. + ~~~~~~~~~ +!!! error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. + + import {} from "./d"; + ~~~~~ +!!! error TS2307: Cannot find module './d' or its corresponding type declarations. + import {} from "./d/index"; + ~~~~~~~~~~~ +!!! error TS2307: Cannot find module './d/index' or its corresponding type declarations. + import {} from "./d/index.ts"; + ~~~~~~~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + + import {} from "./e"; + ~~~~~ +!!! error TS2307: Cannot find module './e' or its corresponding type declarations. + +==== /project/types.d.ts (2 errors) ==== + import {} from "./a.ts"; + import {} from "./a.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. + import type {} from "./a.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. + \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).js b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).js new file mode 100644 index 0000000000000..2eeeabf051a24 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).js @@ -0,0 +1,64 @@ +//// [tests/cases/conformance/moduleResolution/minimal_relative.ts] //// + +//// [a.ts] +export {}; + +//// [b.ts] +export {}; + +//// [b.js] +export {}; + +//// [b.d.ts] +export {}; + +//// [c.ts] +export {}; + +//// [c.tsx] +export {}; + +//// [index.ts] +export {}; + +//// [e] +export {}; + +//// [main.ts] +import {} from "./a"; +import {} from "./a.js"; +import {} from "./a.ts"; + +import {} from "./b"; +import {} from "./b.js"; +import {} from "./b.ts"; +import {} from "./b.d.ts"; +import type {} from "./b.d.ts"; + +import {} from "./c.ts"; +import {} from "./c.tsx"; + +import {} from "./d"; +import {} from "./d/index"; +import {} from "./d/index.ts"; + +import {} from "./e"; + +//// [types.d.ts] +import {} from "./a.ts"; +import {} from "./a.d.ts"; +import type {} from "./a.d.ts"; + + +//// [a.js] +"use strict"; +exports.__esModule = true; +//// [b.js] +"use strict"; +exports.__esModule = true; +//// [index.js] +"use strict"; +exports.__esModule = true; +//// [main.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).symbols b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).symbols new file mode 100644 index 0000000000000..8087e521944d1 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).symbols @@ -0,0 +1,44 @@ +=== /project/a.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.tsx === +export {}; +No type information for this code. +No type information for this code.=== /project/d/index.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/main.ts === +import {} from "./a"; +No type information for this code.import {} from "./a.js"; +No type information for this code.import {} from "./a.ts"; +No type information for this code. +No type information for this code.import {} from "./b"; +No type information for this code.import {} from "./b.js"; +No type information for this code.import {} from "./b.ts"; +No type information for this code.import {} from "./b.d.ts"; +No type information for this code.import type {} from "./b.d.ts"; +No type information for this code. +No type information for this code.import {} from "./c.ts"; +No type information for this code.import {} from "./c.tsx"; +No type information for this code. +No type information for this code.import {} from "./d"; +No type information for this code.import {} from "./d/index"; +No type information for this code.import {} from "./d/index.ts"; +No type information for this code. +No type information for this code.import {} from "./e"; +No type information for this code. +No type information for this code.=== /project/types.d.ts === +import {} from "./a.ts"; +No type information for this code.import {} from "./a.d.ts"; +No type information for this code.import type {} from "./a.d.ts"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).trace.json b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).trace.json new file mode 100644 index 0000000000000..40a02fe86a714 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).trace.json @@ -0,0 +1,68 @@ +[ + "======== Resolving module './a' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './a' was not resolved. ========", + "======== Resolving module './a.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/a.js' has a '.js' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/a.ts' has a '.ts' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './b' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './b' was not resolved. ========", + "======== Resolving module './b.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.js' has a '.js' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.ts' has a '.ts' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/b.d.ts' exist - use it as a name resolution result.", + "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", + "======== Resolving module './c.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/c.ts' has a '.ts' extension - stripping it.", + "File '/project/c.ts' exist - use it as a name resolution result.", + "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", + "======== Resolving module './c.tsx' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", + "File '/project/c.tsx' exist - use it as a name resolution result.", + "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", + "======== Resolving module './d' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './d' was not resolved. ========", + "======== Resolving module './d/index' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './d/index' was not resolved. ========", + "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './e' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './e' was not resolved. ========", + "======== Resolving module './a.ts' from '/project/types.d.ts'. ========", + "Resolution for module './a.ts' was found in cache from location '/project'.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/a.d.ts' does not exist.", + "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/a.js' does not exist.", + "File '/project/a.jsx' does not exist.", + "======== Module name './a.d.ts' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).types b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).types new file mode 100644 index 0000000000000..8087e521944d1 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).types @@ -0,0 +1,44 @@ +=== /project/a.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.tsx === +export {}; +No type information for this code. +No type information for this code.=== /project/d/index.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/main.ts === +import {} from "./a"; +No type information for this code.import {} from "./a.js"; +No type information for this code.import {} from "./a.ts"; +No type information for this code. +No type information for this code.import {} from "./b"; +No type information for this code.import {} from "./b.js"; +No type information for this code.import {} from "./b.ts"; +No type information for this code.import {} from "./b.d.ts"; +No type information for this code.import type {} from "./b.d.ts"; +No type information for this code. +No type information for this code.import {} from "./c.ts"; +No type information for this code.import {} from "./c.tsx"; +No type information for this code. +No type information for this code.import {} from "./d"; +No type information for this code.import {} from "./d/index"; +No type information for this code.import {} from "./d/index.ts"; +No type information for this code. +No type information for this code.import {} from "./e"; +No type information for this code. +No type information for this code.=== /project/types.d.ts === +import {} from "./a.ts"; +No type information for this code.import {} from "./a.d.ts"; +No type information for this code.import type {} from "./a.d.ts"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).errors.txt b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).errors.txt new file mode 100644 index 0000000000000..be1af8b2bad51 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).errors.txt @@ -0,0 +1,105 @@ +error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. + The file is in the program because: + Root file specified for compilation +error TS6504: File '/project/b.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 +/project/main.ts(1,16): error TS2307: Cannot find module './a' or its corresponding type declarations. +/project/main.ts(3,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(5,16): error TS2307: Cannot find module './b' or its corresponding type declarations. +/project/main.ts(7,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(8,16): error TS2845: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? +/project/main.ts(11,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(12,16): error TS5097: An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. +/project/main.ts(14,16): error TS2307: Cannot find module './d' or its corresponding type declarations. +/project/main.ts(15,16): error TS2307: Cannot find module './d/index' or its corresponding type declarations. +/project/main.ts(16,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(18,16): error TS2307: Cannot find module './e' or its corresponding type declarations. +/project/types.d.ts(2,16): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. +/project/types.d.ts(3,21): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. + + +!!! error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. +!!! error TS6231: The file is in the program because: +!!! error TS6231: Root file specified for compilation +!!! error TS6504: File '/project/b.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 +==== /project/a.ts (0 errors) ==== + export {}; + +==== /project/b.ts (0 errors) ==== + export {}; + +==== /project/b.js (0 errors) ==== + export {}; + +==== /project/b.d.ts (0 errors) ==== + export {}; + +==== /project/c.ts (0 errors) ==== + export {}; + +==== /project/c.tsx (0 errors) ==== + export {}; + +==== /project/d/index.ts (0 errors) ==== + export {}; + +==== /project/e (0 errors) ==== + export {}; + +==== /project/main.ts (12 errors) ==== + import {} from "./a"; + ~~~~~ +!!! error TS2307: Cannot find module './a' or its corresponding type declarations. + import {} from "./a.js"; + import {} from "./a.ts"; + ~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + + import {} from "./b"; + ~~~~~ +!!! error TS2307: Cannot find module './b' or its corresponding type declarations. + import {} from "./b.js"; + import {} from "./b.ts"; + ~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + import {} from "./b.d.ts"; + ~~~~~~~~~~ +!!! error TS2845: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? + import type {} from "./b.d.ts"; + + import {} from "./c.ts"; + ~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + import {} from "./c.tsx"; + ~~~~~~~~~ +!!! error TS5097: An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled. + ~~~~~~~~~ +!!! error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. + + import {} from "./d"; + ~~~~~ +!!! error TS2307: Cannot find module './d' or its corresponding type declarations. + import {} from "./d/index"; + ~~~~~~~~~~~ +!!! error TS2307: Cannot find module './d/index' or its corresponding type declarations. + import {} from "./d/index.ts"; + ~~~~~~~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + + import {} from "./e"; + ~~~~~ +!!! error TS2307: Cannot find module './e' or its corresponding type declarations. + +==== /project/types.d.ts (2 errors) ==== + import {} from "./a.ts"; + import {} from "./a.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. + import type {} from "./a.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. + \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).symbols b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).symbols new file mode 100644 index 0000000000000..8087e521944d1 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).symbols @@ -0,0 +1,44 @@ +=== /project/a.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.tsx === +export {}; +No type information for this code. +No type information for this code.=== /project/d/index.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/main.ts === +import {} from "./a"; +No type information for this code.import {} from "./a.js"; +No type information for this code.import {} from "./a.ts"; +No type information for this code. +No type information for this code.import {} from "./b"; +No type information for this code.import {} from "./b.js"; +No type information for this code.import {} from "./b.ts"; +No type information for this code.import {} from "./b.d.ts"; +No type information for this code.import type {} from "./b.d.ts"; +No type information for this code. +No type information for this code.import {} from "./c.ts"; +No type information for this code.import {} from "./c.tsx"; +No type information for this code. +No type information for this code.import {} from "./d"; +No type information for this code.import {} from "./d/index"; +No type information for this code.import {} from "./d/index.ts"; +No type information for this code. +No type information for this code.import {} from "./e"; +No type information for this code. +No type information for this code.=== /project/types.d.ts === +import {} from "./a.ts"; +No type information for this code.import {} from "./a.d.ts"; +No type information for this code.import type {} from "./a.d.ts"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).trace.json b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).trace.json new file mode 100644 index 0000000000000..40a02fe86a714 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).trace.json @@ -0,0 +1,68 @@ +[ + "======== Resolving module './a' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './a' was not resolved. ========", + "======== Resolving module './a.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/a.js' has a '.js' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/a.ts' has a '.ts' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './b' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './b' was not resolved. ========", + "======== Resolving module './b.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.js' has a '.js' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.ts' has a '.ts' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/b.d.ts' exist - use it as a name resolution result.", + "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", + "======== Resolving module './c.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/c.ts' has a '.ts' extension - stripping it.", + "File '/project/c.ts' exist - use it as a name resolution result.", + "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", + "======== Resolving module './c.tsx' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", + "File '/project/c.tsx' exist - use it as a name resolution result.", + "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", + "======== Resolving module './d' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './d' was not resolved. ========", + "======== Resolving module './d/index' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './d/index' was not resolved. ========", + "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './e' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './e' was not resolved. ========", + "======== Resolving module './a.ts' from '/project/types.d.ts'. ========", + "Resolution for module './a.ts' was found in cache from location '/project'.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/a.d.ts' does not exist.", + "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/a.js' does not exist.", + "File '/project/a.jsx' does not exist.", + "======== Module name './a.d.ts' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).types b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).types new file mode 100644 index 0000000000000..8087e521944d1 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).types @@ -0,0 +1,44 @@ +=== /project/a.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.tsx === +export {}; +No type information for this code. +No type information for this code.=== /project/d/index.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/main.ts === +import {} from "./a"; +No type information for this code.import {} from "./a.js"; +No type information for this code.import {} from "./a.ts"; +No type information for this code. +No type information for this code.import {} from "./b"; +No type information for this code.import {} from "./b.js"; +No type information for this code.import {} from "./b.ts"; +No type information for this code.import {} from "./b.d.ts"; +No type information for this code.import type {} from "./b.d.ts"; +No type information for this code. +No type information for this code.import {} from "./c.ts"; +No type information for this code.import {} from "./c.tsx"; +No type information for this code. +No type information for this code.import {} from "./d"; +No type information for this code.import {} from "./d/index"; +No type information for this code.import {} from "./d/index.ts"; +No type information for this code. +No type information for this code.import {} from "./e"; +No type information for this code. +No type information for this code.=== /project/types.d.ts === +import {} from "./a.ts"; +No type information for this code.import {} from "./a.d.ts"; +No type information for this code.import type {} from "./a.d.ts"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).errors.txt b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).errors.txt new file mode 100644 index 0000000000000..68fea4b6506d7 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).errors.txt @@ -0,0 +1,94 @@ +error TS5056: Cannot write file 'dist/c.js' because it would be overwritten by multiple input files. +error TS5096: Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'minimal' and either 'noEmit' or 'emitDeclarationOnly' is set. +error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. + The file is in the program because: + Root file specified for compilation +error TS6504: File '/project/b.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 +/project/main.ts(1,16): error TS2307: Cannot find module './a' or its corresponding type declarations. +/project/main.ts(5,16): error TS2307: Cannot find module './b' or its corresponding type declarations. +/project/main.ts(8,16): error TS2845: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? +/project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. +/project/main.ts(14,16): error TS2307: Cannot find module './d' or its corresponding type declarations. +/project/main.ts(15,16): error TS2307: Cannot find module './d/index' or its corresponding type declarations. +/project/main.ts(18,16): error TS2307: Cannot find module './e' or its corresponding type declarations. +/project/types.d.ts(2,16): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. +/project/types.d.ts(3,21): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. + + +!!! error TS5056: Cannot write file 'dist/c.js' because it would be overwritten by multiple input files. +!!! error TS5096: Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'minimal' and either 'noEmit' or 'emitDeclarationOnly' is set. +!!! error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. +!!! error TS6231: The file is in the program because: +!!! error TS6231: Root file specified for compilation +!!! error TS6504: File '/project/b.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 +==== /project/a.ts (0 errors) ==== + export {}; + +==== /project/b.ts (0 errors) ==== + export {}; + +==== /project/b.js (0 errors) ==== + export {}; + +==== /project/b.d.ts (0 errors) ==== + export {}; + +==== /project/c.ts (0 errors) ==== + export {}; + +==== /project/c.tsx (0 errors) ==== + export {}; + +==== /project/d/index.ts (0 errors) ==== + export {}; + +==== /project/e (0 errors) ==== + export {}; + +==== /project/main.ts (7 errors) ==== + import {} from "./a"; + ~~~~~ +!!! error TS2307: Cannot find module './a' or its corresponding type declarations. + import {} from "./a.js"; + import {} from "./a.ts"; + + import {} from "./b"; + ~~~~~ +!!! error TS2307: Cannot find module './b' or its corresponding type declarations. + import {} from "./b.js"; + import {} from "./b.ts"; + import {} from "./b.d.ts"; + ~~~~~~~~~~ +!!! error TS2845: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? + import type {} from "./b.d.ts"; + + import {} from "./c.ts"; + import {} from "./c.tsx"; + ~~~~~~~~~ +!!! error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. + + import {} from "./d"; + ~~~~~ +!!! error TS2307: Cannot find module './d' or its corresponding type declarations. + import {} from "./d/index"; + ~~~~~~~~~~~ +!!! error TS2307: Cannot find module './d/index' or its corresponding type declarations. + import {} from "./d/index.ts"; + + import {} from "./e"; + ~~~~~ +!!! error TS2307: Cannot find module './e' or its corresponding type declarations. + +==== /project/types.d.ts (2 errors) ==== + import {} from "./a.ts"; + import {} from "./a.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. + import type {} from "./a.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. + \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).js b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).js new file mode 100644 index 0000000000000..2eeeabf051a24 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).js @@ -0,0 +1,64 @@ +//// [tests/cases/conformance/moduleResolution/minimal_relative.ts] //// + +//// [a.ts] +export {}; + +//// [b.ts] +export {}; + +//// [b.js] +export {}; + +//// [b.d.ts] +export {}; + +//// [c.ts] +export {}; + +//// [c.tsx] +export {}; + +//// [index.ts] +export {}; + +//// [e] +export {}; + +//// [main.ts] +import {} from "./a"; +import {} from "./a.js"; +import {} from "./a.ts"; + +import {} from "./b"; +import {} from "./b.js"; +import {} from "./b.ts"; +import {} from "./b.d.ts"; +import type {} from "./b.d.ts"; + +import {} from "./c.ts"; +import {} from "./c.tsx"; + +import {} from "./d"; +import {} from "./d/index"; +import {} from "./d/index.ts"; + +import {} from "./e"; + +//// [types.d.ts] +import {} from "./a.ts"; +import {} from "./a.d.ts"; +import type {} from "./a.d.ts"; + + +//// [a.js] +"use strict"; +exports.__esModule = true; +//// [b.js] +"use strict"; +exports.__esModule = true; +//// [index.js] +"use strict"; +exports.__esModule = true; +//// [main.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).symbols b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).symbols new file mode 100644 index 0000000000000..8087e521944d1 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).symbols @@ -0,0 +1,44 @@ +=== /project/a.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.tsx === +export {}; +No type information for this code. +No type information for this code.=== /project/d/index.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/main.ts === +import {} from "./a"; +No type information for this code.import {} from "./a.js"; +No type information for this code.import {} from "./a.ts"; +No type information for this code. +No type information for this code.import {} from "./b"; +No type information for this code.import {} from "./b.js"; +No type information for this code.import {} from "./b.ts"; +No type information for this code.import {} from "./b.d.ts"; +No type information for this code.import type {} from "./b.d.ts"; +No type information for this code. +No type information for this code.import {} from "./c.ts"; +No type information for this code.import {} from "./c.tsx"; +No type information for this code. +No type information for this code.import {} from "./d"; +No type information for this code.import {} from "./d/index"; +No type information for this code.import {} from "./d/index.ts"; +No type information for this code. +No type information for this code.import {} from "./e"; +No type information for this code. +No type information for this code.=== /project/types.d.ts === +import {} from "./a.ts"; +No type information for this code.import {} from "./a.d.ts"; +No type information for this code.import type {} from "./a.d.ts"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).trace.json b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).trace.json new file mode 100644 index 0000000000000..40a02fe86a714 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).trace.json @@ -0,0 +1,68 @@ +[ + "======== Resolving module './a' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './a' was not resolved. ========", + "======== Resolving module './a.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/a.js' has a '.js' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/a.ts' has a '.ts' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './b' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './b' was not resolved. ========", + "======== Resolving module './b.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.js' has a '.js' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.ts' has a '.ts' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/b.d.ts' exist - use it as a name resolution result.", + "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", + "======== Resolving module './c.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/c.ts' has a '.ts' extension - stripping it.", + "File '/project/c.ts' exist - use it as a name resolution result.", + "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", + "======== Resolving module './c.tsx' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", + "File '/project/c.tsx' exist - use it as a name resolution result.", + "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", + "======== Resolving module './d' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './d' was not resolved. ========", + "======== Resolving module './d/index' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './d/index' was not resolved. ========", + "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './e' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './e' was not resolved. ========", + "======== Resolving module './a.ts' from '/project/types.d.ts'. ========", + "Resolution for module './a.ts' was found in cache from location '/project'.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/a.d.ts' does not exist.", + "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/a.js' does not exist.", + "File '/project/a.jsx' does not exist.", + "======== Module name './a.d.ts' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).types b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).types new file mode 100644 index 0000000000000..8087e521944d1 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).types @@ -0,0 +1,44 @@ +=== /project/a.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.tsx === +export {}; +No type information for this code. +No type information for this code.=== /project/d/index.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/main.ts === +import {} from "./a"; +No type information for this code.import {} from "./a.js"; +No type information for this code.import {} from "./a.ts"; +No type information for this code. +No type information for this code.import {} from "./b"; +No type information for this code.import {} from "./b.js"; +No type information for this code.import {} from "./b.ts"; +No type information for this code.import {} from "./b.d.ts"; +No type information for this code.import type {} from "./b.d.ts"; +No type information for this code. +No type information for this code.import {} from "./c.ts"; +No type information for this code.import {} from "./c.tsx"; +No type information for this code. +No type information for this code.import {} from "./d"; +No type information for this code.import {} from "./d/index"; +No type information for this code.import {} from "./d/index.ts"; +No type information for this code. +No type information for this code.import {} from "./e"; +No type information for this code. +No type information for this code.=== /project/types.d.ts === +import {} from "./a.ts"; +No type information for this code.import {} from "./a.d.ts"; +No type information for this code.import type {} from "./a.d.ts"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).errors.txt b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).errors.txt new file mode 100644 index 0000000000000..3ae5b03e5a120 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).errors.txt @@ -0,0 +1,90 @@ +error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. + The file is in the program because: + Root file specified for compilation +error TS6504: File '/project/b.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 +/project/main.ts(1,16): error TS2307: Cannot find module './a' or its corresponding type declarations. +/project/main.ts(5,16): error TS2307: Cannot find module './b' or its corresponding type declarations. +/project/main.ts(8,16): error TS2845: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? +/project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. +/project/main.ts(14,16): error TS2307: Cannot find module './d' or its corresponding type declarations. +/project/main.ts(15,16): error TS2307: Cannot find module './d/index' or its corresponding type declarations. +/project/main.ts(18,16): error TS2307: Cannot find module './e' or its corresponding type declarations. +/project/types.d.ts(2,16): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. +/project/types.d.ts(3,21): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. + + +!!! error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. +!!! error TS6231: The file is in the program because: +!!! error TS6231: Root file specified for compilation +!!! error TS6504: File '/project/b.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 +==== /project/a.ts (0 errors) ==== + export {}; + +==== /project/b.ts (0 errors) ==== + export {}; + +==== /project/b.js (0 errors) ==== + export {}; + +==== /project/b.d.ts (0 errors) ==== + export {}; + +==== /project/c.ts (0 errors) ==== + export {}; + +==== /project/c.tsx (0 errors) ==== + export {}; + +==== /project/d/index.ts (0 errors) ==== + export {}; + +==== /project/e (0 errors) ==== + export {}; + +==== /project/main.ts (7 errors) ==== + import {} from "./a"; + ~~~~~ +!!! error TS2307: Cannot find module './a' or its corresponding type declarations. + import {} from "./a.js"; + import {} from "./a.ts"; + + import {} from "./b"; + ~~~~~ +!!! error TS2307: Cannot find module './b' or its corresponding type declarations. + import {} from "./b.js"; + import {} from "./b.ts"; + import {} from "./b.d.ts"; + ~~~~~~~~~~ +!!! error TS2845: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? + import type {} from "./b.d.ts"; + + import {} from "./c.ts"; + import {} from "./c.tsx"; + ~~~~~~~~~ +!!! error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. + + import {} from "./d"; + ~~~~~ +!!! error TS2307: Cannot find module './d' or its corresponding type declarations. + import {} from "./d/index"; + ~~~~~~~~~~~ +!!! error TS2307: Cannot find module './d/index' or its corresponding type declarations. + import {} from "./d/index.ts"; + + import {} from "./e"; + ~~~~~ +!!! error TS2307: Cannot find module './e' or its corresponding type declarations. + +==== /project/types.d.ts (2 errors) ==== + import {} from "./a.ts"; + import {} from "./a.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. + import type {} from "./a.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. + \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).symbols b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).symbols new file mode 100644 index 0000000000000..8087e521944d1 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).symbols @@ -0,0 +1,44 @@ +=== /project/a.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.tsx === +export {}; +No type information for this code. +No type information for this code.=== /project/d/index.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/main.ts === +import {} from "./a"; +No type information for this code.import {} from "./a.js"; +No type information for this code.import {} from "./a.ts"; +No type information for this code. +No type information for this code.import {} from "./b"; +No type information for this code.import {} from "./b.js"; +No type information for this code.import {} from "./b.ts"; +No type information for this code.import {} from "./b.d.ts"; +No type information for this code.import type {} from "./b.d.ts"; +No type information for this code. +No type information for this code.import {} from "./c.ts"; +No type information for this code.import {} from "./c.tsx"; +No type information for this code. +No type information for this code.import {} from "./d"; +No type information for this code.import {} from "./d/index"; +No type information for this code.import {} from "./d/index.ts"; +No type information for this code. +No type information for this code.import {} from "./e"; +No type information for this code. +No type information for this code.=== /project/types.d.ts === +import {} from "./a.ts"; +No type information for this code.import {} from "./a.d.ts"; +No type information for this code.import type {} from "./a.d.ts"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).trace.json b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).trace.json new file mode 100644 index 0000000000000..40a02fe86a714 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).trace.json @@ -0,0 +1,68 @@ +[ + "======== Resolving module './a' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './a' was not resolved. ========", + "======== Resolving module './a.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/a.js' has a '.js' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/a.ts' has a '.ts' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './b' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './b' was not resolved. ========", + "======== Resolving module './b.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.js' has a '.js' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.ts' has a '.ts' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/b.d.ts' exist - use it as a name resolution result.", + "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", + "======== Resolving module './c.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/c.ts' has a '.ts' extension - stripping it.", + "File '/project/c.ts' exist - use it as a name resolution result.", + "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", + "======== Resolving module './c.tsx' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", + "File '/project/c.tsx' exist - use it as a name resolution result.", + "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", + "======== Resolving module './d' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './d' was not resolved. ========", + "======== Resolving module './d/index' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './d/index' was not resolved. ========", + "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './e' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "======== Module name './e' was not resolved. ========", + "======== Resolving module './a.ts' from '/project/types.d.ts'. ========", + "Resolution for module './a.ts' was found in cache from location '/project'.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", + "Explicitly specified module resolution kind: 'Minimal'.", + "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/a.d.ts' does not exist.", + "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/a.js' does not exist.", + "File '/project/a.jsx' does not exist.", + "======== Module name './a.d.ts' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).types b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).types new file mode 100644 index 0000000000000..8087e521944d1 --- /dev/null +++ b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).types @@ -0,0 +1,44 @@ +=== /project/a.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/b.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/c.tsx === +export {}; +No type information for this code. +No type information for this code.=== /project/d/index.ts === +export {}; +No type information for this code. +No type information for this code.=== /project/main.ts === +import {} from "./a"; +No type information for this code.import {} from "./a.js"; +No type information for this code.import {} from "./a.ts"; +No type information for this code. +No type information for this code.import {} from "./b"; +No type information for this code.import {} from "./b.js"; +No type information for this code.import {} from "./b.ts"; +No type information for this code.import {} from "./b.d.ts"; +No type information for this code.import type {} from "./b.d.ts"; +No type information for this code. +No type information for this code.import {} from "./c.ts"; +No type information for this code.import {} from "./c.tsx"; +No type information for this code. +No type information for this code.import {} from "./d"; +No type information for this code.import {} from "./d/index"; +No type information for this code.import {} from "./d/index.ts"; +No type information for this code. +No type information for this code.import {} from "./e"; +No type information for this code. +No type information for this code.=== /project/types.d.ts === +import {} from "./a.ts"; +No type information for this code.import {} from "./a.d.ts"; +No type information for this code.import type {} from "./a.d.ts"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/cases/conformance/moduleResolution/minimal_pathsAndBaseUrl.ts b/tests/cases/conformance/moduleResolution/minimal_pathsAndBaseUrl.ts index a7fb1a2c4ebb6..74ae8ffcde21e 100644 --- a/tests/cases/conformance/moduleResolution/minimal_pathsAndBaseUrl.ts +++ b/tests/cases/conformance/moduleResolution/minimal_pathsAndBaseUrl.ts @@ -6,6 +6,7 @@ "compilerOptions": { "moduleResolution": "minimal", "noEmit": true, + "allowImportingTsExtensions": true, "baseUrl": ".", "paths": { "*": [ diff --git a/tests/cases/conformance/moduleResolution/minimal_relative.ts b/tests/cases/conformance/moduleResolution/minimal_relative.ts index b3428c435e48a..21eb4828223f5 100644 --- a/tests/cases/conformance/moduleResolution/minimal_relative.ts +++ b/tests/cases/conformance/moduleResolution/minimal_relative.ts @@ -1,6 +1,7 @@ // @moduleResolution: minimal // @outDir: dist // @noEmit: true,false +// @allowImportingTsExtensions: true,false // @traceResolution: true // @Filename: /project/a.ts @@ -46,3 +47,8 @@ import {} from "./d/index"; import {} from "./d/index.ts"; import {} from "./e"; + +// @Filename: /project/types.d.ts +import {} from "./a.ts"; +import {} from "./a.d.ts"; +import type {} from "./a.d.ts"; From 496ef994efcde07a1bceff1c3651e18dc647dfa1 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 15 Sep 2022 13:35:48 -0700 Subject: [PATCH 07/41] Add module specifier resolution changes --- src/compiler/moduleSpecifiers.ts | 115 +++++++++++------- .../reference/api/tsserverlibrary.d.ts | 3 +- tests/baselines/reference/api/typescript.d.ts | 3 +- .../allowImportingTsExtensions/tsconfig.json | 5 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../tsconfig.json | 1 + .../declarationDir-is-specified.js | 1 + ...-outDir-and-declarationDir-is-specified.js | 1 + .../when-outDir-is-specified.js | 1 + .../with-outFile.js | 1 + ...e-is-specified-with-declaration-enabled.js | 1 + .../without-outDir-or-outFile-is-specified.js | 1 + 21 files changed, 94 insertions(+), 49 deletions(-) create mode 100644 tests/baselines/reference/showConfig/Shows tsconfig for single option/allowImportingTsExtensions/tsconfig.json diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index 32640fcb81579..1f560927e3e55 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -8,44 +8,76 @@ namespace ts.moduleSpecifiers { // Processed preferences interface Preferences { readonly relativePreference: RelativePreference; - readonly ending: Ending; + /** + * @param syntaxImpliedNodeFormat Used when the import syntax implies ESM or CJS irrespective of the mode of the file. + */ + getAllowedEndingsInPrefererredOrder(syntaxImpliedNodeFormat?: SourceFile["impliedNodeFormat"]): Ending[]; } - function getPreferences(host: ModuleSpecifierResolutionHost, { importModuleSpecifierPreference, importModuleSpecifierEnding }: UserPreferences, compilerOptions: CompilerOptions, importingSourceFile: SourceFile): Preferences { + function getPreferences( + host: ModuleSpecifierResolutionHost, + { importModuleSpecifierPreference, importModuleSpecifierEnding }: UserPreferences, + compilerOptions: CompilerOptions, + importingSourceFile: SourceFile, + oldImportSpecifier?: string, + ): Preferences { + const preferredEnding = getPreferredEnding(); return { relativePreference: + oldImportSpecifier !== undefined ? (isExternalModuleNameRelative(oldImportSpecifier) ? + RelativePreference.Relative : + RelativePreference.NonRelative) : importModuleSpecifierPreference === "relative" ? RelativePreference.Relative : importModuleSpecifierPreference === "non-relative" ? RelativePreference.NonRelative : importModuleSpecifierPreference === "project-relative" ? RelativePreference.ExternalNonRelative : RelativePreference.Shortest, - ending: getEnding(), + getAllowedEndingsInPrefererredOrder: syntaxImpliedNodeFormat => { + if (syntaxImpliedNodeFormat === ModuleKind.ESNext || + getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Minimal || + isFormatRequiringExtensions() + ) { + return [Ending.JsExtension]; + } + if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Classic) { + return [Ending.Index, Ending.JsExtension]; + } + switch (preferredEnding) { + case Ending.JsExtension: return [Ending.JsExtension, Ending.Minimal, Ending.Index]; + case Ending.Index: return [Ending.Index, Ending.Minimal, Ending.JsExtension]; + case Ending.Minimal: return [Ending.Minimal, Ending.Index, Ending.JsExtension]; + default: Debug.assertNever(preferredEnding); + } + }, }; - function getEnding(): Ending { + + function getPreferredEnding(): Ending { + if (oldImportSpecifier !== undefined) { + if (hasJSFileExtension(oldImportSpecifier)) return Ending.JsExtension; + if (endsWith(oldImportSpecifier, "/index")) return Ending.Index; + } switch (importModuleSpecifierEnding) { case "minimal": return Ending.Minimal; case "index": return Ending.Index; case "js": return Ending.JsExtension; - default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? Ending.JsExtension - : getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeJs ? Ending.Index : Ending.Minimal; + default: return usesJsExtensionOnImports(importingSourceFile) ? Ending.JsExtension : Ending.Minimal; } } - } - - function getPreferencesForUpdate(compilerOptions: CompilerOptions, oldImportSpecifier: string, importingSourceFileName: Path, host: ModuleSpecifierResolutionHost): Preferences { - return { - relativePreference: isExternalModuleNameRelative(oldImportSpecifier) ? RelativePreference.Relative : RelativePreference.NonRelative, - ending: hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ? - Ending.JsExtension : - getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeJs || endsWith(oldImportSpecifier, "index") ? Ending.Index : Ending.Minimal, - }; - } - function isFormatRequiringExtensions(compilerOptions: CompilerOptions, importingSourceFileName: Path, host: ModuleSpecifierResolutionHost) { - if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node16 - && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) { - return false; + function isFormatRequiringExtensions() { + switch (getEmitModuleResolutionKind(compilerOptions)) { + case ModuleResolutionKind.Minimal: + return true; + case ModuleResolutionKind.Node16: + case ModuleResolutionKind.NodeNext: + return getImpliedNodeFormatForFile( + importingSourceFile.path, + host.getPackageJsonInfoCache?.(), + getModuleResolutionHost(host), compilerOptions, + ) !== ModuleKind.CommonJS; + default: + return false; + } } - return getImpliedNodeFormatForFile(importingSourceFileName, host.getPackageJsonInfoCache?.(), getModuleResolutionHost(host), compilerOptions) !== ModuleKind.CommonJS; } function getModuleResolutionHost(host: ModuleSpecifierResolutionHost): ModuleResolutionHost { @@ -72,7 +104,7 @@ namespace ts.moduleSpecifiers { oldImportSpecifier: string, options: ModuleSpecifierOptions = {}, ): string | undefined { - const res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host), {}, options); + const res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile, oldImportSpecifier), {}, options); if (res === oldImportSpecifier) return undefined; return res; } @@ -293,11 +325,13 @@ namespace ts.moduleSpecifiers { return { getCanonicalFileName, importingSourceFileName, sourceDirectory }; } - function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOptions: CompilerOptions, host: ModuleSpecifierResolutionHost, importMode: SourceFile["impliedNodeFormat"], { ending, relativePreference }: Preferences): string { + function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOptions: CompilerOptions, host: ModuleSpecifierResolutionHost, importMode: SourceFile["impliedNodeFormat"], { getAllowedEndingsInPrefererredOrder, relativePreference }: Preferences): string { const { baseUrl, paths, rootDirs } = compilerOptions; const { sourceDirectory, getCanonicalFileName } = info; + const allowedEndings = getAllowedEndingsInPrefererredOrder(importMode); + const ending = allowedEndings[0]; const relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || - removeExtensionAndIndexPostFix(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); + processEnding(ensurePathIsNonModuleName(getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); if (!baseUrl && !paths || relativePreference === RelativePreference.Relative) { return relativePath; } @@ -308,8 +342,8 @@ namespace ts.moduleSpecifiers { return relativePath; } - const fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions); - const nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths; + const fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions); + const nonRelative = fromPaths === undefined && baseUrl !== undefined ? processEnding(relativeToBaseUrl, ending, compilerOptions) : fromPaths; if (!nonRelative) { return relativePath; } @@ -558,18 +592,6 @@ namespace ts.moduleSpecifiers { } } - function getAllowedEndings(preferredEnding: Ending, compilerOptions: CompilerOptions, importMode: SourceFile["impliedNodeFormat"]) { - if (getEmitModuleResolutionKind(compilerOptions) >= ModuleResolutionKind.Node16 && importMode === ModuleKind.ESNext) { - return [Ending.JsExtension]; - } - switch (preferredEnding) { - case Ending.JsExtension: return [Ending.JsExtension, Ending.Minimal, Ending.Index]; - case Ending.Index: return [Ending.Index, Ending.Minimal, Ending.JsExtension]; - case Ending.Minimal: return [Ending.Minimal, Ending.Index, Ending.JsExtension]; - default: Debug.assertNever(preferredEnding); - } - } - function tryGetModuleNameFromPaths(relativeToBaseUrl: string, paths: MapLike, allowedEndings: Ending[], host: ModuleSpecifierResolutionHost, compilerOptions: CompilerOptions): string | undefined { for (const key in paths) { for (const patternText of paths[key]) { @@ -613,7 +635,7 @@ namespace ts.moduleSpecifiers { // sorted among the others for a particular value of `importModuleSpecifierEnding`. const candidates: { ending: Ending | undefined, value: string }[] = allowedEndings.map(ending => ({ ending, - value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) + value: processEnding(relativeToBaseUrl, ending, compilerOptions) })); if (tryGetExtensionFromPath(pattern)) { candidates.push({ ending: undefined, value: relativeToBaseUrl }); @@ -650,7 +672,7 @@ namespace ts.moduleSpecifiers { // `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is // that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally // everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.) - return ending !== Ending.Minimal || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host); + return ending !== Ending.Minimal || value === processEnding(relativeToBaseUrl, ending, compilerOptions, host); } } @@ -733,13 +755,11 @@ namespace ts.moduleSpecifiers { const normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); const relativePath = normalizedSourcePath !== undefined ? ensurePathIsNonModuleName(getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath; - return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs - ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) - : removeFileExtension(relativePath); + return processEnding(relativePath, ending, compilerOptions); } function tryGetModuleNameAsNodeModule({ path, isRedirect }: ModulePath, { getCanonicalFileName, sourceDirectory }: Info, importingSourceFile: SourceFile , host: ModuleSpecifierResolutionHost, options: CompilerOptions, userPreferences: UserPreferences, packageNameOnly?: boolean, overrideMode?: ModuleKind.ESNext | ModuleKind.CommonJS): string | undefined { - if (!host.fileExists || !host.readFile) { + if (!host.fileExists || !host.readFile || getEmitModuleResolutionKind(options) === ModuleResolutionKind.Minimal) { return undefined; } const parts: NodeModulePathParts = getNodeModulePathParts(path)!; @@ -750,6 +770,7 @@ namespace ts.moduleSpecifiers { // Simplify the full file path to something that can be resolved by Node. const preferences = getPreferences(host, userPreferences, options, importingSourceFile); + const allowedEndings = preferences.getAllowedEndingsInPrefererredOrder(); let moduleSpecifier = path; let isPackageRootPath = false; if (!packageNameOnly) { @@ -776,7 +797,7 @@ namespace ts.moduleSpecifiers { // try with next level of directory packageRootIndex = path.indexOf(directorySeparator, packageRootIndex + 1); if (packageRootIndex === -1) { - moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host); + moduleSpecifier = processEnding(moduleFileName, allowedEndings[0], options, host); break; } } @@ -832,7 +853,7 @@ namespace ts.moduleSpecifiers { const fromPaths = tryGetModuleNameFromPaths( subModuleName, versionPaths.paths, - getAllowedEndings(preferences.ending, options, importMode), + allowedEndings, host, options ); @@ -889,7 +910,7 @@ namespace ts.moduleSpecifiers { }); } - function removeExtensionAndIndexPostFix(fileName: string, ending: Ending, options: CompilerOptions, host?: ModuleSpecifierResolutionHost): string { + function processEnding(fileName: string, ending: Ending, options: CompilerOptions, host?: ModuleSpecifierResolutionHost): string { if (fileExtensionIsOneOf(fileName, [Extension.Json, Extension.Mjs, Extension.Cjs])) return fileName; const noExtension = removeFileExtension(fileName); if (fileName === noExtension) return fileName; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 936b189192bfe..ba647af4fc3eb 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2993,6 +2993,7 @@ declare namespace ts { } export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; export interface CompilerOptions { + allowImportingTsExtensions?: boolean; allowJs?: boolean; allowSyntheticDefaultImports?: boolean; allowUmdGlobalAccess?: boolean; @@ -5059,7 +5060,7 @@ declare namespace ts { export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; export function minimalModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; export function shouldResolveTsExtension(compilerOptions: CompilerOptions): boolean; - export function shouldAllowTsExtension(compilerOptions: CompilerOptions): boolean; + export function shouldAllowImportingTsExtension(compilerOptions: CompilerOptions, fromFileName?: string): boolean | "" | undefined; export {}; } declare namespace ts { diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 5f0a608c6962c..cf28270b66367 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2993,6 +2993,7 @@ declare namespace ts { } export type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | ProjectReference[] | null | undefined; export interface CompilerOptions { + allowImportingTsExtensions?: boolean; allowJs?: boolean; allowSyntheticDefaultImports?: boolean; allowUmdGlobalAccess?: boolean; @@ -5059,7 +5060,7 @@ declare namespace ts { export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; export function minimalModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; export function shouldResolveTsExtension(compilerOptions: CompilerOptions): boolean; - export function shouldAllowTsExtension(compilerOptions: CompilerOptions): boolean; + export function shouldAllowImportingTsExtension(compilerOptions: CompilerOptions, fromFileName?: string): boolean | "" | undefined; export {}; } declare namespace ts { diff --git a/tests/baselines/reference/showConfig/Shows tsconfig for single option/allowImportingTsExtensions/tsconfig.json b/tests/baselines/reference/showConfig/Shows tsconfig for single option/allowImportingTsExtensions/tsconfig.json new file mode 100644 index 0000000000000..88c95f9eb8307 --- /dev/null +++ b/tests/baselines/reference/showConfig/Shows tsconfig for single option/allowImportingTsExtensions/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "allowImportingTsExtensions": true + } +} diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index 75dcaeac2e2b9..5cad175ba34fa 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -35,6 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with --help/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with --help/tsconfig.json index 75dcaeac2e2b9..5cad175ba34fa 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with --help/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with --help/tsconfig.json @@ -35,6 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with --watch/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with --watch/tsconfig.json index 75dcaeac2e2b9..5cad175ba34fa 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with --watch/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with --watch/tsconfig.json @@ -35,6 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json index ce36f2a0fcfd7..e1b9e67e7b66d 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json @@ -35,6 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index a4be57dd3410e..cc29170683efb 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -35,6 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index faa350ae98575..0b6e055e0a2cd 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -35,6 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index 09587994ffbcd..01830a8f79b49 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -35,6 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index abb2dfd47088b..6798430ea05ee 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -35,6 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index 75dcaeac2e2b9..5cad175ba34fa 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -35,6 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index 04aa9196bfc65..6bae69884ebdb 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -35,6 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index 4eb9bb8aa4b84..c6de1fdcc3575 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -35,6 +35,7 @@ "types": ["jquery","mocha"], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/declarationDir-is-specified.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/declarationDir-is-specified.js index 2cf43a8189e28..782dc8bc57911 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/declarationDir-is-specified.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/declarationDir-is-specified.js @@ -56,6 +56,7 @@ interface Array { length: number; [n: number]: T; } // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-and-declarationDir-is-specified.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-and-declarationDir-is-specified.js index 0bdc2d356c5e3..54e482fe2570b 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-and-declarationDir-is-specified.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-and-declarationDir-is-specified.js @@ -56,6 +56,7 @@ interface Array { length: number; [n: number]: T; } // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-is-specified.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-is-specified.js index 673a8e6669886..5b88985795b6e 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-is-specified.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-is-specified.js @@ -56,6 +56,7 @@ interface Array { length: number; [n: number]: T; } // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/with-outFile.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/with-outFile.js index 83e6548b002fb..482495d68b2c7 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/with-outFile.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/with-outFile.js @@ -56,6 +56,7 @@ interface Array { length: number; [n: number]: T; } // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified-with-declaration-enabled.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified-with-declaration-enabled.js index c87baf238012c..a80a8e8c3c89e 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified-with-declaration-enabled.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified-with-declaration-enabled.js @@ -56,6 +56,7 @@ interface Array { length: number; [n: number]: T; } // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified.js index 82310b617cd3d..b1b8e8a3eaedf 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified.js @@ -56,6 +56,7 @@ interface Array { length: number; [n: number]: T; } // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ From 458c12596f10e3f0d347c14b7b89bd61f114a1ab Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 19 Sep 2022 11:11:20 -0700 Subject: [PATCH 08/41] Add auto-import tests --- src/compiler/moduleSpecifiers.ts | 18 ++++-- src/harness/fourslashImpl.ts | 64 +++++++++++++++++--- src/harness/fourslashInterfaceImpl.ts | 4 ++ src/services/utilities.ts | 3 +- tests/cases/fourslash/autoImportsMinimal1.ts | 17 ++++++ tests/cases/fourslash/autoImportsMinimal2.ts | 19 ++++++ tests/cases/fourslash/fourslash.ts | 1 + 7 files changed, 113 insertions(+), 13 deletions(-) create mode 100644 tests/cases/fourslash/autoImportsMinimal1.ts create mode 100644 tests/cases/fourslash/autoImportsMinimal2.ts diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index 1f560927e3e55..119a55565f34d 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -3,7 +3,7 @@ namespace ts.moduleSpecifiers { const enum RelativePreference { Relative, NonRelative, Shortest, ExternalNonRelative } // See UserPreferences#importPathEnding - const enum Ending { Minimal, Index, JsExtension } + const enum Ending { Minimal, Index, JsExtension, TsExtension } // Processed preferences interface Preferences { @@ -36,6 +36,9 @@ namespace ts.moduleSpecifiers { getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Minimal || isFormatRequiringExtensions() ) { + if (shouldAllowImportingTsExtension(compilerOptions, importingSourceFile.fileName)) { + return [Ending.TsExtension, Ending.JsExtension]; + } return [Ending.JsExtension]; } if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Classic) { @@ -43,6 +46,7 @@ namespace ts.moduleSpecifiers { } switch (preferredEnding) { case Ending.JsExtension: return [Ending.JsExtension, Ending.Minimal, Ending.Index]; + case Ending.TsExtension: return [Ending.TsExtension, Ending.TsExtension, Ending.Minimal, Ending.Index]; case Ending.Index: return [Ending.Index, Ending.Minimal, Ending.JsExtension]; case Ending.Minimal: return [Ending.Minimal, Ending.Index, Ending.JsExtension]; default: Debug.assertNever(preferredEnding); @@ -58,8 +62,10 @@ namespace ts.moduleSpecifiers { switch (importModuleSpecifierEnding) { case "minimal": return Ending.Minimal; case "index": return Ending.Index; - case "js": return Ending.JsExtension; - default: return usesJsExtensionOnImports(importingSourceFile) ? Ending.JsExtension : Ending.Minimal; + case "js": return shouldAllowImportingTsExtension(compilerOptions) ? Ending.TsExtension : Ending.JsExtension; + default: return usesExtensionsOnImports(importingSourceFile) + ? shouldAllowImportingTsExtension(compilerOptions) ? Ending.TsExtension : Ending.JsExtension + : Ending.Minimal; } } @@ -403,8 +409,8 @@ namespace ts.moduleSpecifiers { return count; } - function usesJsExtensionOnImports({ imports }: SourceFile): boolean { - return firstDefined(imports, ({ text }) => pathIsRelative(text) ? hasJSFileExtension(text) : undefined) || false; + function usesExtensionsOnImports({ imports }: SourceFile): boolean { + return firstDefined(imports, ({ text }) => pathIsRelative(text) ? (hasJSFileExtension(text) || hasTSFileExtension(text)) : undefined) || false; } function comparePathsByRedirectAndNumberOfDirectorySeparators(a: ModulePath, b: ModulePath) { @@ -928,6 +934,8 @@ namespace ts.moduleSpecifiers { return noExtension; case Ending.JsExtension: return noExtension + getJSExtensionForFile(fileName, options); + case Ending.TsExtension: + return fileName; default: return Debug.assertNever(ending); } diff --git a/src/harness/fourslashImpl.ts b/src/harness/fourslashImpl.ts index 46d2bc242e772..6883a6d25c554 100644 --- a/src/harness/fourslashImpl.ts +++ b/src/harness/fourslashImpl.ts @@ -798,16 +798,20 @@ namespace FourSlash { }); } - private renderMarkers(markers: { text: string, fileName: string, position: number }[]) { + private renderMarkers(markers: { text: string, fileName: string, position: number }[], useTerminalBoldSequence = true) { const filesToDisplay = ts.deduplicate(markers.map(m => m.fileName), ts.equateValues); return filesToDisplay.map(fileName => { const markersToRender = markers.filter(m => m.fileName === fileName).sort((a, b) => b.position - a.position); let fileContent = this.tryGetFileContent(fileName) || ""; for (const marker of markersToRender) { - fileContent = fileContent.slice(0, marker.position) + `\x1b[1;4m/*${marker.text}*/\x1b[0;31m` + fileContent.slice(marker.position); + fileContent = fileContent.slice(0, marker.position) + bold(`/*${marker.text}*/`) + fileContent.slice(marker.position); } return `// @Filename: ${fileName}\n${fileContent}`; }).join("\n\n"); + + function bold(text: string) { + return useTerminalBoldSequence ? `\x1b[1;4m${text}\x1b[0;31m` : text; + } } private verifyDefinitionTextSpan(defs: ts.DefinitionInfoAndBoundSpan, startMarkerName: string) { @@ -3127,6 +3131,48 @@ namespace FourSlash { assert.deepEqual(actualModuleSpecifiers, moduleSpecifiers); } + public baselineAutoImports(markerName: string, preferences?: ts.UserPreferences) { + const marker = this.getMarkerByName(markerName); + const baselineFile = this.getBaselineFileNameForContainingTestFile(`.baseline.md`); + const completionPreferences = { + includeCompletionsForModuleExports: true, + includeCompletionsWithInsertText: true, + allowIncompleteCompletions: true, + includeCompletionsWithSnippetText: true, + ...preferences + }; + + const ext = ts.getAnyExtensionFromPath(this.activeFile.fileName).slice(1); + const lang = ["mts", "cts"].includes(ext) ? "ts" : ext; + let baselineText = codeFence(this.renderMarkers([{ text: "|", fileName: marker.fileName, position: marker.position }], /*useTerminalBoldSequence*/ false), lang) + "\n\n"; + this.goToMarker(marker); + + const completions = this.getCompletionListAtCaret(completionPreferences)!; + + const autoImportCompletions = completions.entries.filter(c => c.hasAction && c.source && c.sortText === ts.Completions.SortText.AutoImportSuggestions); + if (autoImportCompletions.length) { + baselineText += `## From completions\n\n${autoImportCompletions.map(c => `- \`${c.name}\` from \`"${c.source}"\``).join("\n")}\n\n`; + autoImportCompletions.forEach(c => { + const details = this.getCompletionEntryDetails(c.name, c.source, c.data, completionPreferences); + assert(details?.codeActions, `Entry '${c.name}' from "${c.source}" returned no code actions from completion details request`); + assert(details.codeActions.length === 1, `Entry '${c.name}' from "${c.source}" returned more than one code action`); + assert(details.codeActions[0].changes.length === 1, `Entry '${c.name}' from "${c.source}" returned a code action changing more than one file`); + assert(details.codeActions[0].changes[0].fileName === this.activeFile.fileName, `Entry '${c.name}' from "${c.source}" returned a code action changing a different file`); + const changes = details.codeActions[0].changes[0].textChanges; + const completionChange: ts.TextChange = { newText: c.insertText || c.name, span: c.replacementSpan || completions.optionalReplacementSpan || { start: marker.position, length: 0 } }; + const sortedChanges = [...changes, completionChange].sort((a, b) => a.span.start - b.span.start); + let newFileContent = this.activeFile.content; + for (let i = sortedChanges.length - 1; i >= 0; i--) { + newFileContent = newFileContent.substring(0, sortedChanges[i].span.start) + sortedChanges[i].newText + newFileContent.substring(sortedChanges[i].span.start + sortedChanges[i].span.length); + } + baselineText += codeFence(newFileContent, lang) + "\n\n"; + }); + } + + // TODO: do codefixes too + Harness.Baseline.runBaseline(baselineFile, baselineText); + } + public verifyDocCommentTemplate(expected: ts.TextInsertion | undefined, options?: ts.DocCommentTemplateOptions) { const name = "verifyDocCommentTemplate"; const actual = this.languageService.getDocCommentTemplateAtPosition(this.activeFile.fileName, this.currentCaretPosition, options || { generateReturnInDocTemplate: true })!; @@ -4598,10 +4644,10 @@ namespace FourSlash { } return ranges; - } + } - // Adds an _ when the source string and the target string have a whitespace difference - function highlightDifferenceBetweenStrings(source: string, target: string) { + // Adds an _ when the source string and the target string have a whitespace difference + function highlightDifferenceBetweenStrings(source: string, target: string) { const ranges = rangesOfDiffBetweenTwoStrings(source, target); let emTarget = target; ranges.forEach((range, index) => { @@ -4613,9 +4659,13 @@ namespace FourSlash { range.start + 1 + additionalOffset, range.start + range.length + 1 + additionalOffset ); - const after = emTarget.slice(range.start + range.length + 1 + additionalOffset, emTarget.length); + const after = emTarget.slice(range.start + range.length + 1 + additionalOffset, emTarget.length); emTarget = before + lhs + between + rhs + after; }); return emTarget; - } + } + + function codeFence(code: string, lang?: string) { + return `\`\`\`${lang || ""}\n${code}\n\`\`\``; + } } diff --git a/src/harness/fourslashInterfaceImpl.ts b/src/harness/fourslashInterfaceImpl.ts index 4112072d38835..5065b5dba5bc1 100644 --- a/src/harness/fourslashInterfaceImpl.ts +++ b/src/harness/fourslashInterfaceImpl.ts @@ -486,6 +486,10 @@ namespace FourSlashInterface { this.state.verifyImportFixModuleSpecifiers(marker, moduleSpecifiers, preferences); } + public baselineAutoImports(marker: string, preferences?: ts.UserPreferences) { + this.state.baselineAutoImports(marker, preferences); + } + public navigationBar(json: any, options?: { checkSpans?: boolean }) { this.state.verifyNavigationBar(json, options); } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 4d24e57d051ee..b021cd350d563 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1909,8 +1909,9 @@ namespace ts { export function programContainsEsModules(program: Program): boolean { return program.getSourceFiles().some(s => !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!s.externalModuleIndicator); } + // TODO: this function is, at best, poorly named. Use sites are pretty suspicious. export function compilerOptionsIndicateEsModules(compilerOptions: CompilerOptions): boolean { - return !!compilerOptions.module || getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 || !!compilerOptions.noEmit; + return !!compilerOptions.module || getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 || !!compilerOptions.noEmit || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Minimal; } export function createModuleSpecifierResolutionHost(program: Program, host: LanguageServiceHost): ModuleSpecifierResolutionHost { diff --git a/tests/cases/fourslash/autoImportsMinimal1.ts b/tests/cases/fourslash/autoImportsMinimal1.ts new file mode 100644 index 0000000000000..175f731e3abf8 --- /dev/null +++ b/tests/cases/fourslash/autoImportsMinimal1.ts @@ -0,0 +1,17 @@ +/// + +// @moduleResolution: minimal + +// @Filename: /node_modules/@types/foo/index.d.ts +//// export const fromAtTypesFoo: number; + +// @Filename: /node_modules/bar/index.d.ts +//// export const fromBar: number; + +// @Filename: /local.ts +//// export const fromLocal: number; + +// @Filename: /main.ts +//// /**/ + +verify.baselineAutoImports(""); diff --git a/tests/cases/fourslash/autoImportsMinimal2.ts b/tests/cases/fourslash/autoImportsMinimal2.ts new file mode 100644 index 0000000000000..3ab44e1c00da4 --- /dev/null +++ b/tests/cases/fourslash/autoImportsMinimal2.ts @@ -0,0 +1,19 @@ +/// + +// @moduleResolution: minimal +// @allowImportingTsExtensions: true +// @noEmit: true + +// @Filename: /node_modules/@types/foo/index.d.ts +//// export const fromAtTypesFoo: number; + +// @Filename: /node_modules/bar/index.d.ts +//// export const fromBar: number; + +// @Filename: /local.ts +//// export const fromLocal: number; + +// @Filename: /main.ts +//// /**/ + +verify.baselineAutoImports(""); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 76ca5d33314d7..058632b616992 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -370,6 +370,7 @@ declare namespace FourSlashInterface { getAndApplyCodeFix(errorCode?: number, index?: number): void; importFixAtPosition(expectedTextArray: string[], errorCode?: number, options?: UserPreferences): void; importFixModuleSpecifiers(marker: string, moduleSpecifiers: string[], options?: UserPreferences): void; + baselineAutoImports(marker: string, options?: UserPreferences): void; navigationBar(json: any, options?: { checkSpans?: boolean }): void; navigationTree(json: any, options?: { checkSpans?: boolean }): void; From 7d64928117dbad08fa63888118d7b5cbcde9cde4 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 26 Sep 2022 10:55:33 -0700 Subject: [PATCH 09/41] Disallow relative imports into node_modules --- src/compiler/checker.ts | 5 +++- src/compiler/diagnosticMessages.json | 4 +++ src/compiler/moduleNameResolver.ts | 13 ++++++++++ .../reference/minimal_nodeModules.errors.txt | 26 +++++++++++++++++++ .../reference/minimal_nodeModules.js | 21 +++++++++++++++ .../reference/minimal_nodeModules.symbols | 16 ++++++++++++ .../reference/minimal_nodeModules.types | 16 ++++++++++++ .../moduleResolution/minimal_nodeModules.ts | 16 ++++++++++++ 8 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/minimal_nodeModules.errors.txt create mode 100644 tests/baselines/reference/minimal_nodeModules.js create mode 100644 tests/baselines/reference/minimal_nodeModules.symbols create mode 100644 tests/baselines/reference/minimal_nodeModules.types create mode 100644 tests/cases/conformance/moduleResolution/minimal_nodeModules.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 36e21f63f35d5..e9d5b3229213f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3740,7 +3740,10 @@ namespace ts { const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions); const resolutionIsNode16OrNext = moduleResolutionKind === ModuleResolutionKind.Node16 || moduleResolutionKind === ModuleResolutionKind.NodeNext; - if (tsExtension) { + if (moduleResolutionKind === ModuleResolutionKind.Minimal && pathContainsNodeModules(moduleReference)) { + error(errorNode, Diagnostics.Relative_imports_into_node_modules_are_not_allowed); + } + else if (tsExtension) { errorOnTSExtensionImport(tsExtension); } else if (!compilerOptions.resolveJsonModule && diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c6614d6482b14..97238efc34650 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3571,6 +3571,10 @@ "category": "Error", "code": 2845 }, + "Relative imports into 'node_modules' are not allowed.": { + "category": "Error", + "code": 2846 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 6fc614ab5dc1a..7aa263db0a893 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -2705,6 +2705,19 @@ namespace ts { if (resolvedUsingSettings) { return resolvedUsingSettings; } + if (isExternalModuleNameRelative(moduleName) && pathContainsNodeModules(moduleName)) { + // A relative import into node_modules is a problem for a few reasons: + // 1. Portability - if the code gets published as a library, it will very likely break + // 2. It's unclear how we should resolve types. By typical relative import rules, we + // would ignore package.json fields that tell us where to find types and would have + // no special behavior linking up node_modules/@types with their implementations - + // we would only find .d.ts files as siblings of .js files. Any package that puts + // their types in a separate directory, or is typed by @types, would be broken. + // Some of these redirections would be safe to do, but others might reflect + // Node-specific resolution features that would only work with non-relative imports. + // There's a diagnostic issued for this case in the checker. + return noPackageId(/*resolved*/ undefined); + } const resolvedRelative = loadModuleFromFileNoImplicitExtensions(extensions, candidate, /*onlyRecordFailures*/ false, state); if (resolvedRelative) { return noPackageId(resolvedRelative); diff --git a/tests/baselines/reference/minimal_nodeModules.errors.txt b/tests/baselines/reference/minimal_nodeModules.errors.txt new file mode 100644 index 0000000000000..1f114980ccf67 --- /dev/null +++ b/tests/baselines/reference/minimal_nodeModules.errors.txt @@ -0,0 +1,26 @@ +/main.ts(1,16): error TS2307: Cannot find module 'foo' or its corresponding type declarations. +/main.ts(2,16): error TS2846: Relative imports into 'node_modules' are not allowed. +/main.ts(3,21): error TS2846: Relative imports into 'node_modules' are not allowed. + + +==== /node_modules/foo/index.d.ts (0 errors) ==== + import {} from "./other.js"; + export {}; + +==== /node_modules/foo/other.d.ts (0 errors) ==== + export {}; + +==== /node_modules/@types/foo/index.d.ts (0 errors) ==== + export {}; + +==== /main.ts (3 errors) ==== + import {} from "foo"; + ~~~~~ +!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. + import {} from "./node_modules/foo/index.js"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2846: Relative imports into 'node_modules' are not allowed. + import type {} from "./node_modules/@types/foo/index.d.ts"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2846: Relative imports into 'node_modules' are not allowed. + \ No newline at end of file diff --git a/tests/baselines/reference/minimal_nodeModules.js b/tests/baselines/reference/minimal_nodeModules.js new file mode 100644 index 0000000000000..25b341dfcd7e8 --- /dev/null +++ b/tests/baselines/reference/minimal_nodeModules.js @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/moduleResolution/minimal_nodeModules.ts] //// + +//// [index.d.ts] +import {} from "./other.js"; +export {}; + +//// [other.d.ts] +export {}; + +//// [index.d.ts] +export {}; + +//// [main.ts] +import {} from "foo"; +import {} from "./node_modules/foo/index.js"; +import type {} from "./node_modules/@types/foo/index.d.ts"; + + +//// [main.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/minimal_nodeModules.symbols b/tests/baselines/reference/minimal_nodeModules.symbols new file mode 100644 index 0000000000000..584f016b4b220 --- /dev/null +++ b/tests/baselines/reference/minimal_nodeModules.symbols @@ -0,0 +1,16 @@ +=== /node_modules/foo/index.d.ts === +import {} from "./other.js"; +No type information for this code.export {}; +No type information for this code. +No type information for this code.=== /node_modules/foo/other.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /node_modules/@types/foo/index.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /main.ts === +import {} from "foo"; +No type information for this code.import {} from "./node_modules/foo/index.js"; +No type information for this code.import type {} from "./node_modules/@types/foo/index.d.ts"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_nodeModules.types b/tests/baselines/reference/minimal_nodeModules.types new file mode 100644 index 0000000000000..584f016b4b220 --- /dev/null +++ b/tests/baselines/reference/minimal_nodeModules.types @@ -0,0 +1,16 @@ +=== /node_modules/foo/index.d.ts === +import {} from "./other.js"; +No type information for this code.export {}; +No type information for this code. +No type information for this code.=== /node_modules/foo/other.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /node_modules/@types/foo/index.d.ts === +export {}; +No type information for this code. +No type information for this code.=== /main.ts === +import {} from "foo"; +No type information for this code.import {} from "./node_modules/foo/index.js"; +No type information for this code.import type {} from "./node_modules/@types/foo/index.d.ts"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/cases/conformance/moduleResolution/minimal_nodeModules.ts b/tests/cases/conformance/moduleResolution/minimal_nodeModules.ts new file mode 100644 index 0000000000000..1ddb7f9153345 --- /dev/null +++ b/tests/cases/conformance/moduleResolution/minimal_nodeModules.ts @@ -0,0 +1,16 @@ +// @moduleResolution: minimal + +// @Filename: /node_modules/foo/index.d.ts +import {} from "./other.js"; +export {}; + +// @Filename: /node_modules/foo/other.d.ts +export {}; + +// @Filename: /node_modules/@types/foo/index.d.ts +export {}; + +// @Filename: /main.ts +import {} from "foo"; +import {} from "./node_modules/foo/index.js"; +import type {} from "./node_modules/@types/foo/index.d.ts"; From 0249e0a93e08a4365764a0ff92b2b0dfd0daacc0 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 26 Sep 2022 11:35:55 -0700 Subject: [PATCH 10/41] =?UTF-8?q?Ensure=20auto-imports=20don=E2=80=99t=20s?= =?UTF-8?q?uggest=20./node=5Fmodules;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compiler/checker.ts | 23 +++++++++++++++---- src/compiler/moduleNameResolver.ts | 13 ----------- src/services/codefixes/importFixes.ts | 3 ++- src/services/completions.ts | 11 ++++++--- .../reference/autoImportsMinimal1.baseline.md | 15 ++++++++++++ .../reference/autoImportsMinimal2.baseline.md | 15 ++++++++++++ 6 files changed, 59 insertions(+), 21 deletions(-) create mode 100644 tests/baselines/reference/autoImportsMinimal1.baseline.md create mode 100644 tests/baselines/reference/autoImportsMinimal2.baseline.md diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e9d5b3229213f..afc8129b4322a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3598,6 +3598,7 @@ namespace ts { (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 moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions); const resolvedModule = getResolvedModule(currentSourceFile, moduleReference, mode); const resolutionDiagnostic = resolvedModule && getResolutionDiagnostic(compilerOptions, resolvedModule); const sourceFile = resolvedModule @@ -3609,7 +3610,22 @@ namespace ts { error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName); } - if (resolvedModule.resolvedUsingTsExtension && isDeclarationFileName(moduleReference)) { + if (moduleResolutionKind === ModuleResolutionKind.Minimal && pathContainsNodeModules(moduleReference)) { + // A relative import into node_modules is a problem for a few reasons: + // 1. Portability - if the code gets published as a library, it will very likely break + // 2. It's unclear how we should resolve types. By typical relative import rules, we + // would ignore package.json fields that tell us where to find types and would have + // no special behavior linking up node_modules/@types with their implementations - + // we would only find .d.ts files as siblings of .js files. Any package that puts + // their types in a separate directory, or is typed by @types, would be broken. + // Some of these redirections would be safe to do, but others might reflect + // Node-specific resolution features that would only work with non-relative imports. + // The module resolver still returns a result, because it's possible for a module in + // node_modules to end up in the program, and module specifier generation assumes that it + // is always possible to generate a module specifier, even if it also generates a diagnostic. + error(errorNode, Diagnostics.Relative_imports_into_node_modules_are_not_allowed); + } + else if (resolvedModule.resolvedUsingTsExtension && isDeclarationFileName(moduleReference)) { const importOrExport = findAncestor(location, isImportDeclaration)?.importClause || findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration)) as ImportEqualsDeclaration | ExportDeclaration | undefined; @@ -3629,7 +3645,7 @@ namespace ts { if (resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) { errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference); } - if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) { + if (moduleResolutionKind === ModuleResolutionKind.Node16 || moduleResolutionKind === ModuleResolutionKind.NodeNext) { const isSyncImport = (currentSourceFile.impliedNodeFormat === ModuleKind.CommonJS && !findAncestor(location, isImportCall)) || !!findAncestor(location, isImportEqualsDeclaration); const overrideClauseHost = findAncestor(location, l => isImportTypeNode(l) || isExportDeclaration(l) || isImportDeclaration(l)) as ImportTypeNode | ImportDeclaration | ExportDeclaration | undefined; const overrideClause = overrideClauseHost && isImportTypeNode(overrideClauseHost) ? overrideClauseHost.assertions?.assertClause : overrideClauseHost?.assertClause; @@ -3737,7 +3753,6 @@ namespace ts { else { const tsExtension = tryExtractTSExtension(moduleReference); const isExtensionlessRelativePathImport = pathIsRelative(moduleReference) && !hasExtension(moduleReference); - const moduleResolutionKind = getEmitModuleResolutionKind(compilerOptions); const resolutionIsNode16OrNext = moduleResolutionKind === ModuleResolutionKind.Node16 || moduleResolutionKind === ModuleResolutionKind.NodeNext; if (moduleResolutionKind === ModuleResolutionKind.Minimal && pathContainsNodeModules(moduleReference)) { @@ -3748,7 +3763,7 @@ namespace ts { } else if (!compilerOptions.resolveJsonModule && fileExtensionIs(moduleReference, Extension.Json) && - getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Classic && + moduleResolutionKind !== ModuleResolutionKind.Classic && hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); } diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 7aa263db0a893..6fc614ab5dc1a 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -2705,19 +2705,6 @@ namespace ts { if (resolvedUsingSettings) { return resolvedUsingSettings; } - if (isExternalModuleNameRelative(moduleName) && pathContainsNodeModules(moduleName)) { - // A relative import into node_modules is a problem for a few reasons: - // 1. Portability - if the code gets published as a library, it will very likely break - // 2. It's unclear how we should resolve types. By typical relative import rules, we - // would ignore package.json fields that tell us where to find types and would have - // no special behavior linking up node_modules/@types with their implementations - - // we would only find .d.ts files as siblings of .js files. Any package that puts - // their types in a separate directory, or is typed by @types, would be broken. - // Some of these redirections would be safe to do, but others might reflect - // Node-specific resolution features that would only work with non-relative imports. - // There's a diagnostic issued for this case in the checker. - return noPackageId(/*resolved*/ undefined); - } const resolvedRelative = loadModuleFromFileNoImplicitExtensions(extensions, candidate, /*onlyRecordFailures*/ false, state); if (resolvedRelative) { return noPackageId(resolvedRelative); diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 496a5d888a194..11e9d13f8bdf0 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -662,7 +662,8 @@ namespace ts.codefix { const compilerOptions = program.getCompilerOptions(); const moduleSpecifierResolutionHost = createModuleSpecifierResolutionHost(program, host); const getChecker = createGetChecker(program, host); - const rejectNodeModulesRelativePaths = moduleResolutionUsesNodeModules(getEmitModuleResolutionKind(compilerOptions)); + const moduleResolution = getEmitModuleResolutionKind(compilerOptions); + const rejectNodeModulesRelativePaths = moduleResolutionUsesNodeModules(moduleResolution) || moduleResolution === ModuleResolutionKind.Minimal; const getModuleSpecifiers = fromCacheOnly ? (moduleSymbol: Symbol) => ({ moduleSpecifiers: moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }) : (moduleSymbol: Symbol, checker: TypeChecker) => moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); diff --git a/src/services/completions.ts b/src/services/completions.ts index 48e1c28bf01de..439e674f88252 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -169,7 +169,7 @@ namespace ts.Completions { const enum GlobalsSearch { Continue, Success, Fail } - interface ModuleSpecifierResolutioContext { + interface ModuleSpecifierResolutionContext { tryResolve: (exportInfo: readonly SymbolExportInfo[], symbolName: string, isFromAmbientModule: boolean) => ModuleSpecifierResolutionResult; resolvedAny: () => boolean; skippedAny: () => boolean; @@ -190,15 +190,20 @@ namespace ts.Completions { preferences: UserPreferences, isForImportStatementCompletion: boolean, isValidTypeOnlyUseSite: boolean, - cb: (context: ModuleSpecifierResolutioContext) => TReturn, + cb: (context: ModuleSpecifierResolutionContext) => TReturn, ): TReturn { const start = timestamp(); + const moduleResolution = getEmitModuleResolutionKind(program.getCompilerOptions()); // Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because // package.json exports can mean we *can't* resolve a module specifier (that doesn't include a // relative path into node_modules), and we want to filter those completions out entirely. + // Under `--moduleResolution minimal`, we want to reject relative module specifiers into + // node_modules, so need to exhaust any other possibilities for how those can be referenced. // Import statement completions always need specifier resolution because the module specifier is // part of their `insertText`, not the `codeActions` creating edits away from the cursor. - const needsFullResolution = isForImportStatementCompletion || moduleResolutionRespectsExports(getEmitModuleResolutionKind(program.getCompilerOptions())); + const needsFullResolution = isForImportStatementCompletion + || moduleResolutionRespectsExports(moduleResolution) + || moduleResolution === ModuleResolutionKind.Minimal; let skippedAny = false; let ambientCount = 0; let resolvedCount = 0; diff --git a/tests/baselines/reference/autoImportsMinimal1.baseline.md b/tests/baselines/reference/autoImportsMinimal1.baseline.md new file mode 100644 index 0000000000000..cd47cab8187c3 --- /dev/null +++ b/tests/baselines/reference/autoImportsMinimal1.baseline.md @@ -0,0 +1,15 @@ +```ts +// @Filename: /main.ts +/*|*/ +``` + +## From completions + +- `fromLocal` from `"./local.js"` + +```ts +import { fromLocal } from "./local.js"; + +fromLocal +``` + diff --git a/tests/baselines/reference/autoImportsMinimal2.baseline.md b/tests/baselines/reference/autoImportsMinimal2.baseline.md new file mode 100644 index 0000000000000..56cf2c70c336a --- /dev/null +++ b/tests/baselines/reference/autoImportsMinimal2.baseline.md @@ -0,0 +1,15 @@ +```ts +// @Filename: /main.ts +/*|*/ +``` + +## From completions + +- `fromLocal` from `"./local.ts"` + +```ts +import { fromLocal } from "./local.ts"; + +fromLocal +``` + From 6242ee31a7cf36ae2ff29024d0145352220a6c45 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 26 Sep 2022 11:40:13 -0700 Subject: [PATCH 11/41] Test a non-portable declaration emit issue --- ...mal_nodeModules_declarationEmit.errors.txt | 17 +++++++++++++++ .../minimal_nodeModules_declarationEmit.js | 20 ++++++++++++++++++ ...inimal_nodeModules_declarationEmit.symbols | 21 +++++++++++++++++++ .../minimal_nodeModules_declarationEmit.types | 21 +++++++++++++++++++ .../minimal_nodeModules_declarationEmit.ts | 14 +++++++++++++ 5 files changed, 93 insertions(+) create mode 100644 tests/baselines/reference/minimal_nodeModules_declarationEmit.errors.txt create mode 100644 tests/baselines/reference/minimal_nodeModules_declarationEmit.js create mode 100644 tests/baselines/reference/minimal_nodeModules_declarationEmit.symbols create mode 100644 tests/baselines/reference/minimal_nodeModules_declarationEmit.types create mode 100644 tests/cases/conformance/moduleResolution/minimal_nodeModules_declarationEmit.ts diff --git a/tests/baselines/reference/minimal_nodeModules_declarationEmit.errors.txt b/tests/baselines/reference/minimal_nodeModules_declarationEmit.errors.txt new file mode 100644 index 0000000000000..d0ce84ea82c5c --- /dev/null +++ b/tests/baselines/reference/minimal_nodeModules_declarationEmit.errors.txt @@ -0,0 +1,17 @@ +/main.ts(1,14): error TS2742: The inferred type of 'boom' cannot be named without a reference to './node_modules/foo/module.js'. This is likely not portable. A type annotation is necessary. + + +==== /node_modules/foo/module.d.ts (0 errors) ==== + export declare class SomeExportedClass { + private foo: any; + } + + declare global { + function returnsPrivateClassOhNo(): SomeExportedClass; + } + +==== /main.ts (1 errors) ==== + export const boom = returnsPrivateClassOhNo(); + ~~~~ +!!! error TS2742: The inferred type of 'boom' cannot be named without a reference to './node_modules/foo/module.js'. This is likely not portable. A type annotation is necessary. + \ No newline at end of file diff --git a/tests/baselines/reference/minimal_nodeModules_declarationEmit.js b/tests/baselines/reference/minimal_nodeModules_declarationEmit.js new file mode 100644 index 0000000000000..b31f1936f6f13 --- /dev/null +++ b/tests/baselines/reference/minimal_nodeModules_declarationEmit.js @@ -0,0 +1,20 @@ +//// [tests/cases/conformance/moduleResolution/minimal_nodeModules_declarationEmit.ts] //// + +//// [module.d.ts] +export declare class SomeExportedClass { + private foo: any; +} + +declare global { + function returnsPrivateClassOhNo(): SomeExportedClass; +} + +//// [main.ts] +export const boom = returnsPrivateClassOhNo(); + + +//// [main.js] +"use strict"; +exports.__esModule = true; +exports.boom = void 0; +exports.boom = returnsPrivateClassOhNo(); diff --git a/tests/baselines/reference/minimal_nodeModules_declarationEmit.symbols b/tests/baselines/reference/minimal_nodeModules_declarationEmit.symbols new file mode 100644 index 0000000000000..1930da5f26c77 --- /dev/null +++ b/tests/baselines/reference/minimal_nodeModules_declarationEmit.symbols @@ -0,0 +1,21 @@ +=== /node_modules/foo/module.d.ts === +export declare class SomeExportedClass { +>SomeExportedClass : Symbol(SomeExportedClass, Decl(module.d.ts, 0, 0)) + + private foo: any; +>foo : Symbol(SomeExportedClass.foo, Decl(module.d.ts, 0, 40)) +} + +declare global { +>global : Symbol(global, Decl(module.d.ts, 2, 1)) + + function returnsPrivateClassOhNo(): SomeExportedClass; +>returnsPrivateClassOhNo : Symbol(returnsPrivateClassOhNo, Decl(module.d.ts, 4, 16)) +>SomeExportedClass : Symbol(SomeExportedClass, Decl(module.d.ts, 0, 0)) +} + +=== /main.ts === +export const boom = returnsPrivateClassOhNo(); +>boom : Symbol(boom, Decl(main.ts, 0, 12)) +>returnsPrivateClassOhNo : Symbol(returnsPrivateClassOhNo, Decl(module.d.ts, 4, 16)) + diff --git a/tests/baselines/reference/minimal_nodeModules_declarationEmit.types b/tests/baselines/reference/minimal_nodeModules_declarationEmit.types new file mode 100644 index 0000000000000..ab1b8fd4423c6 --- /dev/null +++ b/tests/baselines/reference/minimal_nodeModules_declarationEmit.types @@ -0,0 +1,21 @@ +=== /node_modules/foo/module.d.ts === +export declare class SomeExportedClass { +>SomeExportedClass : SomeExportedClass + + private foo: any; +>foo : any +} + +declare global { +>global : typeof global + + function returnsPrivateClassOhNo(): SomeExportedClass; +>returnsPrivateClassOhNo : () => SomeExportedClass +} + +=== /main.ts === +export const boom = returnsPrivateClassOhNo(); +>boom : import("/node_modules/foo/module").SomeExportedClass +>returnsPrivateClassOhNo() : import("/node_modules/foo/module").SomeExportedClass +>returnsPrivateClassOhNo : () => import("/node_modules/foo/module").SomeExportedClass + diff --git a/tests/cases/conformance/moduleResolution/minimal_nodeModules_declarationEmit.ts b/tests/cases/conformance/moduleResolution/minimal_nodeModules_declarationEmit.ts new file mode 100644 index 0000000000000..b621aeab6431f --- /dev/null +++ b/tests/cases/conformance/moduleResolution/minimal_nodeModules_declarationEmit.ts @@ -0,0 +1,14 @@ +// @moduleResolution: minimal +// @declaration: true + +// @Filename: /node_modules/foo/module.d.ts +export declare class SomeExportedClass { + private foo: any; +} + +declare global { + function returnsPrivateClassOhNo(): SomeExportedClass; +} + +// @Filename: /main.ts +export const boom = returnsPrivateClassOhNo(); From 6cc0e18dca2006e4751f8d1d680fdb42723915aa Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 26 Sep 2022 11:44:03 -0700 Subject: [PATCH 12/41] Test auto-importing TSX file --- tests/baselines/reference/autoImportsMinimal1.baseline.md | 7 +++++++ tests/baselines/reference/autoImportsMinimal2.baseline.md | 7 +++++++ tests/cases/fourslash/autoImportsMinimal1.ts | 3 +++ tests/cases/fourslash/autoImportsMinimal2.ts | 3 +++ 4 files changed, 20 insertions(+) diff --git a/tests/baselines/reference/autoImportsMinimal1.baseline.md b/tests/baselines/reference/autoImportsMinimal1.baseline.md index cd47cab8187c3..c0a6fb0eeaaaa 100644 --- a/tests/baselines/reference/autoImportsMinimal1.baseline.md +++ b/tests/baselines/reference/autoImportsMinimal1.baseline.md @@ -5,8 +5,15 @@ ## From completions +- `Component` from `"./Component.js"` - `fromLocal` from `"./local.js"` +```ts +import { Component } from "./Component.js"; + +Component +``` + ```ts import { fromLocal } from "./local.js"; diff --git a/tests/baselines/reference/autoImportsMinimal2.baseline.md b/tests/baselines/reference/autoImportsMinimal2.baseline.md index 56cf2c70c336a..35b129182eab9 100644 --- a/tests/baselines/reference/autoImportsMinimal2.baseline.md +++ b/tests/baselines/reference/autoImportsMinimal2.baseline.md @@ -5,8 +5,15 @@ ## From completions +- `Component` from `"./Component.tsx"` - `fromLocal` from `"./local.ts"` +```ts +import { Component } from "./Component.tsx"; + +Component +``` + ```ts import { fromLocal } from "./local.ts"; diff --git a/tests/cases/fourslash/autoImportsMinimal1.ts b/tests/cases/fourslash/autoImportsMinimal1.ts index 175f731e3abf8..1796a03b00f28 100644 --- a/tests/cases/fourslash/autoImportsMinimal1.ts +++ b/tests/cases/fourslash/autoImportsMinimal1.ts @@ -11,6 +11,9 @@ // @Filename: /local.ts //// export const fromLocal: number; +// @Filename: /Component.tsx +//// export function Component() { return null; } + // @Filename: /main.ts //// /**/ diff --git a/tests/cases/fourslash/autoImportsMinimal2.ts b/tests/cases/fourslash/autoImportsMinimal2.ts index 3ab44e1c00da4..c98a84aa859be 100644 --- a/tests/cases/fourslash/autoImportsMinimal2.ts +++ b/tests/cases/fourslash/autoImportsMinimal2.ts @@ -13,6 +13,9 @@ // @Filename: /local.ts //// export const fromLocal: number; +// @Filename: /Component.tsx +//// export function Component() { return null; } + // @Filename: /main.ts //// /**/ From 240533a2361babab5e1fe5e38c4ac35fde77c5c8 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 26 Sep 2022 12:59:25 -0700 Subject: [PATCH 13/41] Update path completions --- src/services/stringCompletions.ts | 85 ++++++++++--------- .../fourslash/pathCompletionsMinimal1.ts | 31 +++++++ .../fourslash/pathCompletionsMinimal2.ts | 33 +++++++ 3 files changed, 109 insertions(+), 40 deletions(-) create mode 100644 tests/cases/fourslash/pathCompletionsMinimal1.ts create mode 100644 tests/cases/fourslash/pathCompletionsMinimal2.ts diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index 922e50654bbe1..df0aeb202b2ae 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -377,8 +377,16 @@ namespace ts.Completions.StringCompletions { : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, getIncludeExtensionOption(), typeChecker); function getIncludeExtensionOption() { + const moduleResolution = getEmitModuleResolutionKind(compilerOptions); + if (moduleResolution === ModuleResolutionKind.Minimal) { + return shouldAllowImportingTsExtension(compilerOptions) + ? IncludeExtensionsOption.Include + : IncludeExtensionsOption.ModuleSpecifierCompletion; + } const mode = isStringLiteralLike(node) ? getModeForUsageLocation(sourceFile, node) : undefined; - return preferences.importModuleSpecifierEnding === "js" || mode === ModuleKind.ESNext ? IncludeExtensionsOption.ModuleSpecifierCompletion : IncludeExtensionsOption.Exclude; + return preferences.importModuleSpecifierEnding === "js" || mode === ModuleKind.ESNext + ? IncludeExtensionsOption.ModuleSpecifierCompletion + : IncludeExtensionsOption.Exclude; } } @@ -396,24 +404,14 @@ namespace ts.Completions.StringCompletions { compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); } else { - return arrayFrom(getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath).values()); + return arrayFrom(getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, /*moduleSpecifierIsRelative*/ false, scriptPath).values()); } } - function isEmitResolutionKindUsingNodeModules(compilerOptions: CompilerOptions): boolean { - return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs || - getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node16 || - getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext; - } - - function isEmitModuleResolutionRespectingExportMaps(compilerOptions: CompilerOptions) { - return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node16 || - getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext; - } - function getSupportedExtensionsForModuleResolution(compilerOptions: CompilerOptions): readonly Extension[][] { const extensions = getSupportedExtensions(compilerOptions); - return isEmitResolutionKindUsingNodeModules(compilerOptions) ? + const moduleResolution = getEmitModuleResolutionKind(compilerOptions); + return moduleResolutionUsesNodeModules(moduleResolution) ? getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) : extensions; } @@ -441,7 +439,7 @@ namespace ts.Completions.StringCompletions { const basePath = compilerOptions.project || host.getCurrentDirectory(); const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase); - return flatMap(baseDirectories, baseDirectory => arrayFrom(getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude).values())); + return flatMap(baseDirectories, baseDirectory => arrayFrom(getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, /*moduleSpecifierIsRelative*/ true, exclude).values())); } const enum IncludeExtensionsOption { @@ -454,9 +452,10 @@ namespace ts.Completions.StringCompletions { */ function getCompletionEntriesForDirectoryFragment( fragment: string, - scriptPath: string, + scriptDirectory: string, extensionOptions: ExtensionOptions, host: LanguageServiceHost, + moduleSpecifierIsRelative: boolean, exclude?: string, result = createNameAndKindSet() ): NameAndKindSet { @@ -480,23 +479,25 @@ namespace ts.Completions.StringCompletions { fragment = ensureTrailingDirectorySeparator(fragment); - const absolutePath = resolvePath(scriptPath, fragment); + const absolutePath = resolvePath(scriptDirectory, fragment); const baseDirectory = hasTrailingDirectorySeparator(absolutePath) ? absolutePath : getDirectoryPath(absolutePath); - // check for a version redirect - const packageJsonPath = findPackageJson(baseDirectory, host); - if (packageJsonPath) { - const packageJson = readJson(packageJsonPath, host as { readFile: (filename: string) => string | undefined }); - const typesVersions = (packageJson as any).typesVersions; - if (typeof typesVersions === "object") { - const versionPaths = getPackageJsonTypesVersionsPaths(typesVersions)?.paths; - if (versionPaths) { - const packageDirectory = getDirectoryPath(packageJsonPath); - const pathInPackage = absolutePath.slice(ensureTrailingDirectorySeparator(packageDirectory).length); - if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) { - // A true result means one of the `versionPaths` was matched, which will block relative resolution - // to files and folders from here. All reachable paths given the pattern match are already added. - return result; + if (!moduleSpecifierIsRelative) { + // check for a version redirect + const packageJsonPath = findPackageJson(baseDirectory, host); + if (packageJsonPath) { + const packageJson = readJson(packageJsonPath, host as { readFile: (filename: string) => string | undefined }); + const typesVersions = (packageJson as any).typesVersions; + if (typeof typesVersions === "object") { + const versionPaths = getPackageJsonTypesVersionsPaths(typesVersions)?.paths; + if (versionPaths) { + const packageDirectory = getDirectoryPath(packageJsonPath); + const pathInPackage = absolutePath.slice(ensureTrailingDirectorySeparator(packageDirectory).length); + if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) { + // A true result means one of the `versionPaths` was matched, which will block relative resolution + // to files and folders from here. All reachable paths given the pattern match are already added. + return result; + } } } } @@ -511,7 +512,7 @@ namespace ts.Completions.StringCompletions { if (files) { for (let filePath of files) { filePath = normalizePath(filePath); - if (exclude && comparePaths(filePath, exclude, scriptPath, ignoreCase) === Comparison.EqualTo) { + if (exclude && comparePaths(filePath, exclude, scriptDirectory, ignoreCase) === Comparison.EqualTo) { continue; } @@ -524,9 +525,10 @@ namespace ts.Completions.StringCompletions { const directories = tryGetDirectories(host, baseDirectory); if (directories) { + const moduleResolution = getEmitModuleResolutionKind(host.getCompilationSettings()); for (const directory of directories) { const directoryName = getBaseFileName(normalizePath(directory)); - if (directoryName !== "@types") { + if (directoryName !== "@types" && !(directoryName === "node_modules" && moduleResolution === ModuleResolutionKind.Minimal)) { result.add(directoryResult(directoryName)); } } @@ -638,11 +640,12 @@ namespace ts.Completions.StringCompletions { const { baseUrl, paths } = compilerOptions; const result = createNameAndKindSet(); + const moduleResolution = getEmitModuleResolutionKind(compilerOptions); const extensionOptions = getExtensionOptions(compilerOptions, includeExtensionsOption); if (baseUrl) { const projectDir = compilerOptions.project || host.getCurrentDirectory(); const absolute = normalizePath(combinePaths(projectDir, baseUrl)); - getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result); + getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*moduleSpecifierIsRelative*/ false, /*exclude*/ undefined, result); if (paths) { addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, host, paths); } @@ -653,9 +656,11 @@ namespace ts.Completions.StringCompletions { result.add(nameAndKind(ambientName, ScriptElementKind.externalModuleName, /*extension*/ undefined)); } - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result); + if (moduleResolution !== ModuleResolutionKind.Minimal) { + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result); + } - if (isEmitResolutionKindUsingNodeModules(compilerOptions)) { + if (moduleResolutionUsesNodeModules(moduleResolution)) { // If looking for a global package name, don't just include everything in `node_modules` because that includes dependencies' own dependencies. // (But do if we didn't find anything, e.g. 'package.json' missing.) let foundGlobal = false; @@ -672,10 +677,10 @@ namespace ts.Completions.StringCompletions { let ancestorLookup: (directory: string) => void | undefined = ancestor => { const nodeModules = combinePaths(ancestor, "node_modules"); if (tryDirectoryExists(host, nodeModules)) { - getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result); + getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*moduleSpecifierIsRelative*/ false, /*exclude*/ undefined, result); } }; - if (fragmentDirectory && isEmitModuleResolutionRespectingExportMaps(compilerOptions)) { + if (fragmentDirectory && moduleResolutionRespectsExports(moduleResolution)) { const nodeModulesDirectoryLookup = ancestorLookup; ancestorLookup = ancestor => { const components = getPathComponents(fragment); @@ -876,7 +881,7 @@ namespace ts.Completions.StringCompletions { const [, prefix, kind, toComplete] = match; const scriptPath = getDirectoryPath(sourceFile.path); - const names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, IncludeExtensionsOption.Include), host, sourceFile.path) + const names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, IncludeExtensionsOption.Include), host, /*moduleSpecifierIsRelative*/ true, sourceFile.path) : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions)) : Debug.fail(); return addReplacementSpans(toComplete, range.pos + prefix.length, arrayFrom(names.values())); @@ -917,7 +922,7 @@ namespace ts.Completions.StringCompletions { const baseDirectory = combinePaths(directory, typeDirectoryName); const remainingFragment = tryRemoveDirectoryPrefix(fragmentDirectory, packageName, hostGetCanonicalFileName(host)); if (remainingFragment !== undefined) { - getCompletionEntriesForDirectoryFragment(remainingFragment, baseDirectory, extensionOptions, host, /*exclude*/ undefined, result); + getCompletionEntriesForDirectoryFragment(remainingFragment, baseDirectory, extensionOptions, host, /*moduleSpecifierIsRelative*/ false, /*exclude*/ undefined, result); } } } diff --git a/tests/cases/fourslash/pathCompletionsMinimal1.ts b/tests/cases/fourslash/pathCompletionsMinimal1.ts new file mode 100644 index 0000000000000..a3843b535f648 --- /dev/null +++ b/tests/cases/fourslash/pathCompletionsMinimal1.ts @@ -0,0 +1,31 @@ +/// + +// @moduleResolution: minimal + +// @Filename: /project/node_modules/@types/foo/index.d.ts +//// export const fromAtTypesFoo: number; + +// @Filename: /project/node_modules/bar/index.d.ts +//// export const fromBar: number; + +// @Filename: /project/local.ts +//// export const fromLocal: number; + +// @Filename: /project/Component.tsx +//// export function Component() { return null; } + +// @Filename: /project/main.ts +//// import {} from "/**/"; + +verify.completions({ + isNewIdentifierLocation: true, + marker: "", + exact: [] +}); + +edit.insert("./"); + +verify.completions({ + isNewIdentifierLocation: true, + exact: ["Component.js", "local.js"], +}); diff --git a/tests/cases/fourslash/pathCompletionsMinimal2.ts b/tests/cases/fourslash/pathCompletionsMinimal2.ts new file mode 100644 index 0000000000000..e9a27356b02b3 --- /dev/null +++ b/tests/cases/fourslash/pathCompletionsMinimal2.ts @@ -0,0 +1,33 @@ +/// + +// @moduleResolution: minimal +// @allowImportingTsExtensions: true +// @noEmit: true + +// @Filename: /project/node_modules/@types/foo/index.d.ts +//// export const fromAtTypesFoo: number; + +// @Filename: /project/node_modules/bar/index.d.ts +//// export const fromBar: number; + +// @Filename: /project/local.ts +//// export const fromLocal: number; + +// @Filename: /project/Component.tsx +//// export function Component() { return null; } + +// @Filename: /project/main.ts +//// import {} from "/**/"; + +verify.completions({ + isNewIdentifierLocation: true, + marker: "", + exact: [] +}); + +edit.insert("./"); + +verify.completions({ + isNewIdentifierLocation: true, + exact: ["Component.tsx", "local.ts"], +}); From 619843e0d0bbc116fffe364fe8264dcc3668308b Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Tue, 27 Sep 2022 10:20:31 -0700 Subject: [PATCH 14/41] Fix lint due to merge --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e27ddd533a58e..8842735df2942 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3637,7 +3637,7 @@ namespace ts { else if (resolvedModule.resolvedUsingTsExtension && isDeclarationFileName(moduleReference)) { const importOrExport = findAncestor(location, isImportDeclaration)?.importClause || - findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration)) as ImportEqualsDeclaration | ExportDeclaration | undefined; + findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration)); if (importOrExport && !importOrExport.isTypeOnly || findAncestor(location, isImportCall)) { error( errorNode, From 2ceb4bc284b1fc8b483dcc74fe7ca1d78911db93 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 13 Oct 2022 16:41:07 -0700 Subject: [PATCH 15/41] Remove minimal-specific stuff --- src/compiler/checker.ts | 24 ++--------- src/compiler/commandLineParser.ts | 17 ++++---- src/compiler/diagnosticMessages.json | 4 -- src/compiler/moduleNameResolver.ts | 57 +++------------------------ src/compiler/moduleSpecifiers.ts | 9 +---- src/compiler/program.ts | 2 +- src/compiler/types.ts | 2 - src/compiler/utilities.ts | 4 ++ src/services/codefixes/importFixes.ts | 2 +- src/services/completions.ts | 7 +--- src/services/stringCompletions.ts | 14 ++----- src/services/utilities.ts | 2 +- 12 files changed, 30 insertions(+), 114 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8842735df2942..dd161d5869a45 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3619,22 +3619,7 @@ namespace ts { error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName); } - if (moduleResolutionKind === ModuleResolutionKind.Minimal && pathContainsNodeModules(moduleReference)) { - // A relative import into node_modules is a problem for a few reasons: - // 1. Portability - if the code gets published as a library, it will very likely break - // 2. It's unclear how we should resolve types. By typical relative import rules, we - // would ignore package.json fields that tell us where to find types and would have - // no special behavior linking up node_modules/@types with their implementations - - // we would only find .d.ts files as siblings of .js files. Any package that puts - // their types in a separate directory, or is typed by @types, would be broken. - // Some of these redirections would be safe to do, but others might reflect - // Node-specific resolution features that would only work with non-relative imports. - // The module resolver still returns a result, because it's possible for a module in - // node_modules to end up in the program, and module specifier generation assumes that it - // is always possible to generate a module specifier, even if it also generates a diagnostic. - error(errorNode, Diagnostics.Relative_imports_into_node_modules_are_not_allowed); - } - else if (resolvedModule.resolvedUsingTsExtension && isDeclarationFileName(moduleReference)) { + if (resolvedModule.resolvedUsingTsExtension && isDeclarationFileName(moduleReference)) { const importOrExport = findAncestor(location, isImportDeclaration)?.importClause || findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration)); @@ -3764,10 +3749,7 @@ namespace ts { const isExtensionlessRelativePathImport = pathIsRelative(moduleReference) && !hasExtension(moduleReference); const resolutionIsNode16OrNext = moduleResolutionKind === ModuleResolutionKind.Node16 || moduleResolutionKind === ModuleResolutionKind.NodeNext; - if (moduleResolutionKind === ModuleResolutionKind.Minimal && pathContainsNodeModules(moduleReference)) { - error(errorNode, Diagnostics.Relative_imports_into_node_modules_are_not_allowed); - } - else if (tsExtension) { + if (tsExtension) { errorOnTSExtensionImport(tsExtension); } else if (!compilerOptions.resolveJsonModule && @@ -3806,7 +3788,7 @@ namespace ts { * Direct users to import source with .js extension if outputting an ES module. * @see https://github.com/microsoft/TypeScript/issues/42151 */ - if (moduleKind >= ModuleKind.ES2015 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Minimal) { + if (emitModuleKindIsNonNodeESM(moduleKind) || mode === ModuleKind.ESNext) { return importSourceWithoutExtension + (tsExtension === Extension.Mts ? ".mjs" : tsExtension === Extension.Cts ? ".cjs" : ".js"); } return importSourceWithoutExtension; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 2c15cf46ab842..4f6293017d04f 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -839,7 +839,6 @@ namespace ts { classic: ModuleResolutionKind.Classic, node16: ModuleResolutionKind.Node16, nodenext: ModuleResolutionKind.NodeNext, - minimal: ModuleResolutionKind.Minimal, })), affectsModuleResolution: true, paramType: Diagnostics.STRATEGY, @@ -956,14 +955,14 @@ namespace ts { category: Diagnostics.Modules, description: Diagnostics.List_of_file_name_suffixes_to_search_when_resolving_a_module, }, - { - name: "allowImportingTsExtensions", - type: "boolean", - affectsModuleResolution: true, - category: Diagnostics.Modules, - description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_minimal_and_either_noEmit_or_emitDeclarationOnly_to_be_set, - defaultValueDescription: false, - }, + // { + // name: "allowImportingTsExtensions", + // type: "boolean", + // affectsModuleResolution: true, + // category: Diagnostics.Modules, + // description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_minimal_and_either_noEmit_or_emitDeclarationOnly_to_be_set, + // defaultValueDescription: false, + // }, // Source Maps { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index cea15688a0f65..b2d731f3dfb3c 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3571,10 +3571,6 @@ "category": "Error", "code": 2846 }, - "Relative imports into 'node_modules' are not allowed.": { - "category": "Error", - "code": 2847 - }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index a15f98cd95717..31665e7399bbd 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -25,10 +25,6 @@ namespace ts { return r && { path: r.path, extension: r.ext, packageId, resolvedUsingTsExtension: r.resolvedUsingTsExtension }; } - function createLoaderWithNoPackageId

(loader: (...args: P) => PathAndExtension | undefined): (...args: P) => Resolved | undefined { - return (...args) => noPackageId(loader(...args)); - } - function noPackageId(r: PathAndExtension | undefined): Resolved | undefined { return withPackageId(/*packageInfo*/ undefined, r); } @@ -1033,9 +1029,6 @@ namespace ts { case ModuleResolutionKind.Classic: result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; - case ModuleResolutionKind.Minimal: - result = minimalModuleNameResolver(moduleName, containingFile, compilerOptions, host); - break; default: return Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`); } @@ -1577,7 +1570,7 @@ namespace ts { // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" if (hasJSFileExtension(candidate) || (state.compilerOptions.resolveJsonModule && fileExtensionIs(candidate, Extension.Json)) || - (shouldResolveTsExtension(state.compilerOptions) && fileExtensionIsOneOf(candidate, supportedTSExtensionsFlat)) + (moduleResolutionSupportsResolvingTsExtensions(state.compilerOptions) && fileExtensionIsOneOf(candidate, supportedTSExtensionsFlat)) ) { const extensionless = removeFileExtension(candidate); const extension = candidate.substring(extensionless.length); @@ -1641,7 +1634,7 @@ namespace ts { case Extension.Ts: case Extension.Tsx: case Extension.Dts: - if (shouldResolveTsExtension(state.compilerOptions)) { + if (moduleResolutionSupportsResolvingTsExtensions(state.compilerOptions)) { return tryExtension(originalExtension, /*resolvedUsingTsExtension*/ true); } // falls through @@ -2671,54 +2664,14 @@ namespace ts { } } - export function minimalModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations { - const traceEnabled = isTraceEnabled(compilerOptions, host); - const failedLookupLocations: string[] = []; - const affectingLocations: string[] = []; - const containingDirectory = getDirectoryPath(containingFile); - const diagnostics: Diagnostic[] = []; - const state: ModuleResolutionState = { - compilerOptions, - host, - traceEnabled, - failedLookupLocations, - affectingLocations, - packageJsonInfoCache: undefined, - features: NodeResolutionFeatures.None, - conditions: [], - requestContainingDirectory: containingDirectory, - reportDiagnostic: diag => void diagnostics.push(diag), - }; - - const candidate = normalizePath(combinePaths(containingDirectory, moduleName)); - return createResolvedModuleWithFailedLookupLocations( - tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript), - /*isExternalLibraryImport*/ false, - failedLookupLocations, - affectingLocations, - diagnostics, - state.resultFromCache); - - function tryResolve(extensions: Extensions) { - const resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, createLoaderWithNoPackageId(loadModuleFromFileNoImplicitExtensions), state); - if (resolvedUsingSettings) { - return resolvedUsingSettings; - } - const resolvedRelative = loadModuleFromFileNoImplicitExtensions(extensions, candidate, /*onlyRecordFailures*/ false, state); - if (resolvedRelative) { - return noPackageId(resolvedRelative); - } - } - } - - export function shouldResolveTsExtension(compilerOptions: CompilerOptions) { - return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Minimal; + export function moduleResolutionSupportsResolvingTsExtensions(_compilerOptions: CompilerOptions) { + return false; } // Program errors validate that `noEmit` or `emitDeclarationOnly` is also set, // so this function doesn't check them to avoid propagating errors. export function shouldAllowImportingTsExtension(compilerOptions: CompilerOptions, fromFileName?: string) { - return shouldResolveTsExtension(compilerOptions) && ( + return moduleResolutionSupportsResolvingTsExtensions(compilerOptions) && ( !!compilerOptions.allowImportingTsExtensions || fromFileName && isDeclarationFileName(fromFileName)); } diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index 119a55565f34d..67ce1b5446a6d 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -32,10 +32,7 @@ namespace ts.moduleSpecifiers { importModuleSpecifierPreference === "project-relative" ? RelativePreference.ExternalNonRelative : RelativePreference.Shortest, getAllowedEndingsInPrefererredOrder: syntaxImpliedNodeFormat => { - if (syntaxImpliedNodeFormat === ModuleKind.ESNext || - getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Minimal || - isFormatRequiringExtensions() - ) { + if (syntaxImpliedNodeFormat === ModuleKind.ESNext || isFormatRequiringExtensions()) { if (shouldAllowImportingTsExtension(compilerOptions, importingSourceFile.fileName)) { return [Ending.TsExtension, Ending.JsExtension]; } @@ -71,8 +68,6 @@ namespace ts.moduleSpecifiers { function isFormatRequiringExtensions() { switch (getEmitModuleResolutionKind(compilerOptions)) { - case ModuleResolutionKind.Minimal: - return true; case ModuleResolutionKind.Node16: case ModuleResolutionKind.NodeNext: return getImpliedNodeFormatForFile( @@ -765,7 +760,7 @@ namespace ts.moduleSpecifiers { } function tryGetModuleNameAsNodeModule({ path, isRedirect }: ModulePath, { getCanonicalFileName, sourceDirectory }: Info, importingSourceFile: SourceFile , host: ModuleSpecifierResolutionHost, options: CompilerOptions, userPreferences: UserPreferences, packageNameOnly?: boolean, overrideMode?: ModuleKind.ESNext | ModuleKind.CommonJS): string | undefined { - if (!host.fileExists || !host.readFile || getEmitModuleResolutionKind(options) === ModuleResolutionKind.Minimal) { + if (!host.fileExists || !host.readFile) { return undefined; } const parts: NodeModulePathParts = getNodeModulePathParts(path)!; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 174a0fea3383b..33ae75e0af33e 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -3657,7 +3657,7 @@ namespace ts { createOptionValueDiagnostic("importsNotUsedAsValues", Diagnostics.Option_preserveValueImports_can_only_be_used_when_module_is_set_to_es2015_or_later); } - if (options.allowImportingTsExtensions && !(getEmitModuleResolutionKind(options) === ModuleResolutionKind.Minimal && (options.noEmit || options.emitDeclarationOnly))) { + if (options.allowImportingTsExtensions && !(moduleResolutionSupportsResolvingTsExtensions(options) && (options.noEmit || options.emitDeclarationOnly))) { createOptionValueDiagnostic("allowImportingTsExtensions", Diagnostics.Option_allowImportingTsExtensions_can_only_be_used_when_moduleResolution_is_set_to_minimal_and_either_noEmit_or_emitDeclarationOnly_is_set); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 36beab983c43a..2e8eec8b17dfb 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -6483,8 +6483,6 @@ namespace ts { // In turn, we offer both a `NodeNext` moving resolution target, and a `Node16` version-anchored resolution target Node16 = 3, NodeNext = 99, // Not simply `Node16` so that compiled code linked against TS can use the `Next` value reliably (same as with `ModuleKind`) - - Minimal = 100, } export enum ModuleDetectionKind { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index cdc0db9407b34..df2d11995ac14 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -6371,6 +6371,10 @@ namespace ts { getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 ? ModuleKind.ES2015 : ModuleKind.CommonJS; } + export function emitModuleKindIsNonNodeESM(moduleKind: ModuleKind) { + return moduleKind >= ModuleKind.ES2015 && moduleKind <= ModuleKind.ESNext; + } + export function getEmitModuleResolutionKind(compilerOptions: CompilerOptions) { let moduleResolution = compilerOptions.moduleResolution; if (moduleResolution === undefined) { diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 11e9d13f8bdf0..784588ed5f714 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -663,7 +663,7 @@ namespace ts.codefix { const moduleSpecifierResolutionHost = createModuleSpecifierResolutionHost(program, host); const getChecker = createGetChecker(program, host); const moduleResolution = getEmitModuleResolutionKind(compilerOptions); - const rejectNodeModulesRelativePaths = moduleResolutionUsesNodeModules(moduleResolution) || moduleResolution === ModuleResolutionKind.Minimal; + const rejectNodeModulesRelativePaths = moduleResolutionUsesNodeModules(moduleResolution); const getModuleSpecifiers = fromCacheOnly ? (moduleSymbol: Symbol) => ({ moduleSpecifiers: moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }) : (moduleSymbol: Symbol, checker: TypeChecker) => moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); diff --git a/src/services/completions.ts b/src/services/completions.ts index d23fab3aa0957..7c8f2f23d27fa 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -193,17 +193,12 @@ namespace ts.Completions { cb: (context: ModuleSpecifierResolutionContext) => TReturn, ): TReturn { const start = timestamp(); - const moduleResolution = getEmitModuleResolutionKind(program.getCompilerOptions()); // Under `--moduleResolution nodenext`, we have to resolve module specifiers up front, because // package.json exports can mean we *can't* resolve a module specifier (that doesn't include a // relative path into node_modules), and we want to filter those completions out entirely. - // Under `--moduleResolution minimal`, we want to reject relative module specifiers into - // node_modules, so need to exhaust any other possibilities for how those can be referenced. // Import statement completions always need specifier resolution because the module specifier is // part of their `insertText`, not the `codeActions` creating edits away from the cursor. - const needsFullResolution = isForImportStatementCompletion - || moduleResolutionRespectsExports(moduleResolution) - || moduleResolution === ModuleResolutionKind.Minimal; + const needsFullResolution = isForImportStatementCompletion || moduleResolutionRespectsExports(getEmitModuleResolutionKind(program.getCompilerOptions())); let skippedAny = false; let ambientCount = 0; let resolvedCount = 0; diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index 239089c47991d..8a07910bb3ebf 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -377,11 +377,8 @@ namespace ts.Completions.StringCompletions { : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, getIncludeExtensionOption(), typeChecker); function getIncludeExtensionOption() { - const moduleResolution = getEmitModuleResolutionKind(compilerOptions); - if (moduleResolution === ModuleResolutionKind.Minimal) { - return shouldAllowImportingTsExtension(compilerOptions) - ? IncludeExtensionsOption.Include - : IncludeExtensionsOption.ModuleSpecifierCompletion; + if (shouldAllowImportingTsExtension(compilerOptions)) { + return IncludeExtensionsOption.Include; } const mode = isStringLiteralLike(node) ? getModeForUsageLocation(sourceFile, node) : undefined; return preferences.importModuleSpecifierEnding === "js" || mode === ModuleKind.ESNext @@ -525,10 +522,9 @@ namespace ts.Completions.StringCompletions { const directories = tryGetDirectories(host, baseDirectory); if (directories) { - const moduleResolution = getEmitModuleResolutionKind(host.getCompilationSettings()); for (const directory of directories) { const directoryName = getBaseFileName(normalizePath(directory)); - if (directoryName !== "@types" && !(directoryName === "node_modules" && moduleResolution === ModuleResolutionKind.Minimal)) { + if (directoryName !== "@types") { result.add(directoryResult(directoryName)); } } @@ -656,9 +652,7 @@ namespace ts.Completions.StringCompletions { result.add(nameAndKind(ambientName, ScriptElementKind.externalModuleName, /*extension*/ undefined)); } - if (moduleResolution !== ModuleResolutionKind.Minimal) { - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result); - } + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result); if (moduleResolutionUsesNodeModules(moduleResolution)) { // If looking for a global package name, don't just include everything in `node_modules` because that includes dependencies' own dependencies. diff --git a/src/services/utilities.ts b/src/services/utilities.ts index b021cd350d563..6f6044c9dd753 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1911,7 +1911,7 @@ namespace ts { } // TODO: this function is, at best, poorly named. Use sites are pretty suspicious. export function compilerOptionsIndicateEsModules(compilerOptions: CompilerOptions): boolean { - return !!compilerOptions.module || getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 || !!compilerOptions.noEmit || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Minimal; + return !!compilerOptions.module || getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 || !!compilerOptions.noEmit; } export function createModuleSpecifierResolutionHost(program: Program, host: LanguageServiceHost): ModuleSpecifierResolutionHost { From aad7fe7f7da5ff622d322f59f8d73de22650b66c Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 13 Oct 2022 16:43:34 -0700 Subject: [PATCH 16/41] Remove minimal tests --- .../reference/autoImportsMinimal1.baseline.md | 22 ---- .../reference/autoImportsMinimal2.baseline.md | 22 ---- .../reference/minimal_nodeModules.errors.txt | 26 ----- .../reference/minimal_nodeModules.js | 21 ---- .../reference/minimal_nodeModules.symbols | 16 --- .../reference/minimal_nodeModules.types | 16 --- ...mal_nodeModules_declarationEmit.errors.txt | 17 --- .../minimal_nodeModules_declarationEmit.js | 20 ---- ...inimal_nodeModules_declarationEmit.symbols | 21 ---- .../minimal_nodeModules_declarationEmit.types | 21 ---- .../reference/minimal_nonRelative.errors.txt | 18 --- .../reference/minimal_nonRelative.trace.json | 14 --- .../minimal_pathsAndBaseUrl.errors.txt | 39 ------- .../minimal_pathsAndBaseUrl.trace.json | 73 ------------ ...sextensions=false,noemit=false).errors.txt | 107 ------------------ ...portingtsextensions=false,noemit=false).js | 64 ----------- ...ngtsextensions=false,noemit=false).symbols | 44 ------- ...sextensions=false,noemit=false).trace.json | 68 ----------- ...tingtsextensions=false,noemit=false).types | 44 ------- ...tsextensions=false,noemit=true).errors.txt | 105 ----------------- ...ingtsextensions=false,noemit=true).symbols | 44 ------- ...tsextensions=false,noemit=true).trace.json | 68 ----------- ...rtingtsextensions=false,noemit=true).types | 44 ------- ...tsextensions=true,noemit=false).errors.txt | 94 --------------- ...mportingtsextensions=true,noemit=false).js | 64 ----------- ...ingtsextensions=true,noemit=false).symbols | 44 ------- ...tsextensions=true,noemit=false).trace.json | 68 ----------- ...rtingtsextensions=true,noemit=false).types | 44 ------- ...gtsextensions=true,noemit=true).errors.txt | 90 --------------- ...tingtsextensions=true,noemit=true).symbols | 44 ------- ...gtsextensions=true,noemit=true).trace.json | 68 ----------- ...ortingtsextensions=true,noemit=true).types | 44 ------- .../minimal_relative(noemit=false).errors.txt | 96 ---------------- .../minimal_relative(noemit=false).js | 59 ---------- .../minimal_relative(noemit=false).symbols | 39 ------- .../minimal_relative(noemit=false).trace.json | 57 ---------- .../minimal_relative(noemit=false).types | 39 ------- .../minimal_relative(noemit=true).errors.txt | 79 ------------- .../minimal_relative(noemit=true).symbols | 39 ------- .../minimal_relative(noemit=true).trace.json | 57 ---------- .../minimal_relative(noemit=true).types | 39 ------- .../moduleResolution/minimal_nodeModules.ts | 16 --- .../minimal_nodeModules_declarationEmit.ts | 14 --- .../moduleResolution/minimal_nonRelative.ts | 14 --- .../minimal_pathsAndBaseUrl.ts | 36 ------ .../moduleResolution/minimal_relative.ts | 54 --------- tests/cases/fourslash/autoImportsMinimal1.ts | 20 ---- tests/cases/fourslash/autoImportsMinimal2.ts | 22 ---- .../fourslash/pathCompletionsMinimal1.ts | 31 ----- .../fourslash/pathCompletionsMinimal2.ts | 33 ------ 50 files changed, 2238 deletions(-) delete mode 100644 tests/baselines/reference/autoImportsMinimal1.baseline.md delete mode 100644 tests/baselines/reference/autoImportsMinimal2.baseline.md delete mode 100644 tests/baselines/reference/minimal_nodeModules.errors.txt delete mode 100644 tests/baselines/reference/minimal_nodeModules.js delete mode 100644 tests/baselines/reference/minimal_nodeModules.symbols delete mode 100644 tests/baselines/reference/minimal_nodeModules.types delete mode 100644 tests/baselines/reference/minimal_nodeModules_declarationEmit.errors.txt delete mode 100644 tests/baselines/reference/minimal_nodeModules_declarationEmit.js delete mode 100644 tests/baselines/reference/minimal_nodeModules_declarationEmit.symbols delete mode 100644 tests/baselines/reference/minimal_nodeModules_declarationEmit.types delete mode 100644 tests/baselines/reference/minimal_nonRelative.errors.txt delete mode 100644 tests/baselines/reference/minimal_nonRelative.trace.json delete mode 100644 tests/baselines/reference/minimal_pathsAndBaseUrl.errors.txt delete mode 100644 tests/baselines/reference/minimal_pathsAndBaseUrl.trace.json delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).errors.txt delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).js delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).symbols delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).trace.json delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).types delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).errors.txt delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).symbols delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).trace.json delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).types delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).errors.txt delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).js delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).symbols delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).trace.json delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).types delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).errors.txt delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).symbols delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).trace.json delete mode 100644 tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).types delete mode 100644 tests/baselines/reference/minimal_relative(noemit=false).errors.txt delete mode 100644 tests/baselines/reference/minimal_relative(noemit=false).js delete mode 100644 tests/baselines/reference/minimal_relative(noemit=false).symbols delete mode 100644 tests/baselines/reference/minimal_relative(noemit=false).trace.json delete mode 100644 tests/baselines/reference/minimal_relative(noemit=false).types delete mode 100644 tests/baselines/reference/minimal_relative(noemit=true).errors.txt delete mode 100644 tests/baselines/reference/minimal_relative(noemit=true).symbols delete mode 100644 tests/baselines/reference/minimal_relative(noemit=true).trace.json delete mode 100644 tests/baselines/reference/minimal_relative(noemit=true).types delete mode 100644 tests/cases/conformance/moduleResolution/minimal_nodeModules.ts delete mode 100644 tests/cases/conformance/moduleResolution/minimal_nodeModules_declarationEmit.ts delete mode 100644 tests/cases/conformance/moduleResolution/minimal_nonRelative.ts delete mode 100644 tests/cases/conformance/moduleResolution/minimal_pathsAndBaseUrl.ts delete mode 100644 tests/cases/conformance/moduleResolution/minimal_relative.ts delete mode 100644 tests/cases/fourslash/autoImportsMinimal1.ts delete mode 100644 tests/cases/fourslash/autoImportsMinimal2.ts delete mode 100644 tests/cases/fourslash/pathCompletionsMinimal1.ts delete mode 100644 tests/cases/fourslash/pathCompletionsMinimal2.ts diff --git a/tests/baselines/reference/autoImportsMinimal1.baseline.md b/tests/baselines/reference/autoImportsMinimal1.baseline.md deleted file mode 100644 index c0a6fb0eeaaaa..0000000000000 --- a/tests/baselines/reference/autoImportsMinimal1.baseline.md +++ /dev/null @@ -1,22 +0,0 @@ -```ts -// @Filename: /main.ts -/*|*/ -``` - -## From completions - -- `Component` from `"./Component.js"` -- `fromLocal` from `"./local.js"` - -```ts -import { Component } from "./Component.js"; - -Component -``` - -```ts -import { fromLocal } from "./local.js"; - -fromLocal -``` - diff --git a/tests/baselines/reference/autoImportsMinimal2.baseline.md b/tests/baselines/reference/autoImportsMinimal2.baseline.md deleted file mode 100644 index 35b129182eab9..0000000000000 --- a/tests/baselines/reference/autoImportsMinimal2.baseline.md +++ /dev/null @@ -1,22 +0,0 @@ -```ts -// @Filename: /main.ts -/*|*/ -``` - -## From completions - -- `Component` from `"./Component.tsx"` -- `fromLocal` from `"./local.ts"` - -```ts -import { Component } from "./Component.tsx"; - -Component -``` - -```ts -import { fromLocal } from "./local.ts"; - -fromLocal -``` - diff --git a/tests/baselines/reference/minimal_nodeModules.errors.txt b/tests/baselines/reference/minimal_nodeModules.errors.txt deleted file mode 100644 index 91a4356bf0505..0000000000000 --- a/tests/baselines/reference/minimal_nodeModules.errors.txt +++ /dev/null @@ -1,26 +0,0 @@ -/main.ts(1,16): error TS2307: Cannot find module 'foo' or its corresponding type declarations. -/main.ts(2,16): error TS2847: Relative imports into 'node_modules' are not allowed. -/main.ts(3,21): error TS2847: Relative imports into 'node_modules' are not allowed. - - -==== /node_modules/foo/index.d.ts (0 errors) ==== - import {} from "./other.js"; - export {}; - -==== /node_modules/foo/other.d.ts (0 errors) ==== - export {}; - -==== /node_modules/@types/foo/index.d.ts (0 errors) ==== - export {}; - -==== /main.ts (3 errors) ==== - import {} from "foo"; - ~~~~~ -!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. - import {} from "./node_modules/foo/index.js"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2847: Relative imports into 'node_modules' are not allowed. - import type {} from "./node_modules/@types/foo/index.d.ts"; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2847: Relative imports into 'node_modules' are not allowed. - \ No newline at end of file diff --git a/tests/baselines/reference/minimal_nodeModules.js b/tests/baselines/reference/minimal_nodeModules.js deleted file mode 100644 index 25b341dfcd7e8..0000000000000 --- a/tests/baselines/reference/minimal_nodeModules.js +++ /dev/null @@ -1,21 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/minimal_nodeModules.ts] //// - -//// [index.d.ts] -import {} from "./other.js"; -export {}; - -//// [other.d.ts] -export {}; - -//// [index.d.ts] -export {}; - -//// [main.ts] -import {} from "foo"; -import {} from "./node_modules/foo/index.js"; -import type {} from "./node_modules/@types/foo/index.d.ts"; - - -//// [main.js] -"use strict"; -exports.__esModule = true; diff --git a/tests/baselines/reference/minimal_nodeModules.symbols b/tests/baselines/reference/minimal_nodeModules.symbols deleted file mode 100644 index 584f016b4b220..0000000000000 --- a/tests/baselines/reference/minimal_nodeModules.symbols +++ /dev/null @@ -1,16 +0,0 @@ -=== /node_modules/foo/index.d.ts === -import {} from "./other.js"; -No type information for this code.export {}; -No type information for this code. -No type information for this code.=== /node_modules/foo/other.d.ts === -export {}; -No type information for this code. -No type information for this code.=== /node_modules/@types/foo/index.d.ts === -export {}; -No type information for this code. -No type information for this code.=== /main.ts === -import {} from "foo"; -No type information for this code.import {} from "./node_modules/foo/index.js"; -No type information for this code.import type {} from "./node_modules/@types/foo/index.d.ts"; -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_nodeModules.types b/tests/baselines/reference/minimal_nodeModules.types deleted file mode 100644 index 584f016b4b220..0000000000000 --- a/tests/baselines/reference/minimal_nodeModules.types +++ /dev/null @@ -1,16 +0,0 @@ -=== /node_modules/foo/index.d.ts === -import {} from "./other.js"; -No type information for this code.export {}; -No type information for this code. -No type information for this code.=== /node_modules/foo/other.d.ts === -export {}; -No type information for this code. -No type information for this code.=== /node_modules/@types/foo/index.d.ts === -export {}; -No type information for this code. -No type information for this code.=== /main.ts === -import {} from "foo"; -No type information for this code.import {} from "./node_modules/foo/index.js"; -No type information for this code.import type {} from "./node_modules/@types/foo/index.d.ts"; -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_nodeModules_declarationEmit.errors.txt b/tests/baselines/reference/minimal_nodeModules_declarationEmit.errors.txt deleted file mode 100644 index d0ce84ea82c5c..0000000000000 --- a/tests/baselines/reference/minimal_nodeModules_declarationEmit.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -/main.ts(1,14): error TS2742: The inferred type of 'boom' cannot be named without a reference to './node_modules/foo/module.js'. This is likely not portable. A type annotation is necessary. - - -==== /node_modules/foo/module.d.ts (0 errors) ==== - export declare class SomeExportedClass { - private foo: any; - } - - declare global { - function returnsPrivateClassOhNo(): SomeExportedClass; - } - -==== /main.ts (1 errors) ==== - export const boom = returnsPrivateClassOhNo(); - ~~~~ -!!! error TS2742: The inferred type of 'boom' cannot be named without a reference to './node_modules/foo/module.js'. This is likely not portable. A type annotation is necessary. - \ No newline at end of file diff --git a/tests/baselines/reference/minimal_nodeModules_declarationEmit.js b/tests/baselines/reference/minimal_nodeModules_declarationEmit.js deleted file mode 100644 index b31f1936f6f13..0000000000000 --- a/tests/baselines/reference/minimal_nodeModules_declarationEmit.js +++ /dev/null @@ -1,20 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/minimal_nodeModules_declarationEmit.ts] //// - -//// [module.d.ts] -export declare class SomeExportedClass { - private foo: any; -} - -declare global { - function returnsPrivateClassOhNo(): SomeExportedClass; -} - -//// [main.ts] -export const boom = returnsPrivateClassOhNo(); - - -//// [main.js] -"use strict"; -exports.__esModule = true; -exports.boom = void 0; -exports.boom = returnsPrivateClassOhNo(); diff --git a/tests/baselines/reference/minimal_nodeModules_declarationEmit.symbols b/tests/baselines/reference/minimal_nodeModules_declarationEmit.symbols deleted file mode 100644 index 1930da5f26c77..0000000000000 --- a/tests/baselines/reference/minimal_nodeModules_declarationEmit.symbols +++ /dev/null @@ -1,21 +0,0 @@ -=== /node_modules/foo/module.d.ts === -export declare class SomeExportedClass { ->SomeExportedClass : Symbol(SomeExportedClass, Decl(module.d.ts, 0, 0)) - - private foo: any; ->foo : Symbol(SomeExportedClass.foo, Decl(module.d.ts, 0, 40)) -} - -declare global { ->global : Symbol(global, Decl(module.d.ts, 2, 1)) - - function returnsPrivateClassOhNo(): SomeExportedClass; ->returnsPrivateClassOhNo : Symbol(returnsPrivateClassOhNo, Decl(module.d.ts, 4, 16)) ->SomeExportedClass : Symbol(SomeExportedClass, Decl(module.d.ts, 0, 0)) -} - -=== /main.ts === -export const boom = returnsPrivateClassOhNo(); ->boom : Symbol(boom, Decl(main.ts, 0, 12)) ->returnsPrivateClassOhNo : Symbol(returnsPrivateClassOhNo, Decl(module.d.ts, 4, 16)) - diff --git a/tests/baselines/reference/minimal_nodeModules_declarationEmit.types b/tests/baselines/reference/minimal_nodeModules_declarationEmit.types deleted file mode 100644 index ab1b8fd4423c6..0000000000000 --- a/tests/baselines/reference/minimal_nodeModules_declarationEmit.types +++ /dev/null @@ -1,21 +0,0 @@ -=== /node_modules/foo/module.d.ts === -export declare class SomeExportedClass { ->SomeExportedClass : SomeExportedClass - - private foo: any; ->foo : any -} - -declare global { ->global : typeof global - - function returnsPrivateClassOhNo(): SomeExportedClass; ->returnsPrivateClassOhNo : () => SomeExportedClass -} - -=== /main.ts === -export const boom = returnsPrivateClassOhNo(); ->boom : import("/node_modules/foo/module").SomeExportedClass ->returnsPrivateClassOhNo() : import("/node_modules/foo/module").SomeExportedClass ->returnsPrivateClassOhNo : () => import("/node_modules/foo/module").SomeExportedClass - diff --git a/tests/baselines/reference/minimal_nonRelative.errors.txt b/tests/baselines/reference/minimal_nonRelative.errors.txt deleted file mode 100644 index 9229d86fe597c..0000000000000 --- a/tests/baselines/reference/minimal_nonRelative.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -/main.ts(1,16): error TS2307: Cannot find module 'foo' or its corresponding type declarations. -/main.ts(2,16): error TS2307: Cannot find module 'bar' or its corresponding type declarations. - - -==== /node_modules/@types/foo/index.d.ts (0 errors) ==== - export {}; - -==== /node_modules/bar/index.d.ts (0 errors) ==== - export {}; - -==== /main.ts (2 errors) ==== - import {} from "foo"; - ~~~~~ -!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. - import {} from "bar"; - ~~~~~ -!!! error TS2307: Cannot find module 'bar' or its corresponding type declarations. - \ No newline at end of file diff --git a/tests/baselines/reference/minimal_nonRelative.trace.json b/tests/baselines/reference/minimal_nonRelative.trace.json deleted file mode 100644 index 769cebfe4261f..0000000000000 --- a/tests/baselines/reference/minimal_nonRelative.trace.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - "======== Resolving module 'foo' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name 'foo' was not resolved. ========", - "======== Resolving module 'bar' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name 'bar' was not resolved. ========", - "======== Resolving type reference directive 'foo', containing file '__inferred type names__.ts', root directory '/node_modules/@types'. ========", - "Resolving with primary search path '/node_modules/@types'.", - "File '/node_modules/@types/foo/package.json' does not exist.", - "File '/node_modules/@types/foo/index.d.ts' exist - use it as a name resolution result.", - "Resolving real path for '/node_modules/@types/foo/index.d.ts', result '/node_modules/@types/foo/index.d.ts'.", - "======== Type reference directive 'foo' was successfully resolved to '/node_modules/@types/foo/index.d.ts', primary: true. ========" -] \ No newline at end of file diff --git a/tests/baselines/reference/minimal_pathsAndBaseUrl.errors.txt b/tests/baselines/reference/minimal_pathsAndBaseUrl.errors.txt deleted file mode 100644 index 31490691952d2..0000000000000 --- a/tests/baselines/reference/minimal_pathsAndBaseUrl.errors.txt +++ /dev/null @@ -1,39 +0,0 @@ -/main.ts(4,16): error TS2307: Cannot find module 'hello' or its corresponding type declarations. - - -==== /tsconfig.json (0 errors) ==== - { - "compilerOptions": { - "moduleResolution": "minimal", - "noEmit": true, - "allowImportingTsExtensions": true, - "baseUrl": ".", - "paths": { - "*": [ - "*", - "./vendor/*", - "./vendor/*/index.d.ts", - "./apps/*" - ] - } - } - } - -==== /vendor/foo/index.d.ts (0 errors) ==== - export {}; - -==== /apps/hello.ts (0 errors) ==== - export {}; - -==== /foo.ts (0 errors) ==== - export {}; - -==== /main.ts (1 errors) ==== - import {} from "foo"; - import {} from "foo/index.js"; - import {} from "hello.ts"; - import {} from "hello"; - ~~~~~~~ -!!! error TS2307: Cannot find module 'hello' or its corresponding type declarations. - import {} from "foo.js"; - \ No newline at end of file diff --git a/tests/baselines/reference/minimal_pathsAndBaseUrl.trace.json b/tests/baselines/reference/minimal_pathsAndBaseUrl.trace.json deleted file mode 100644 index 9d8aa1165d31a..0000000000000 --- a/tests/baselines/reference/minimal_pathsAndBaseUrl.trace.json +++ /dev/null @@ -1,73 +0,0 @@ -[ - "======== Resolving module 'foo' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo'.", - "'paths' option is specified, looking for a pattern to match module name 'foo'.", - "Module name 'foo', matched pattern '*'.", - "Trying substitution '*', candidate module location: 'foo'.", - "Trying substitution './vendor/*', candidate module location: './vendor/foo'.", - "Trying substitution './vendor/*/index.d.ts', candidate module location: './vendor/foo/index.d.ts'.", - "File '/vendor/foo/index.d.ts' exist - use it as a name resolution result.", - "======== Module name 'foo' was successfully resolved to '/vendor/foo/index.d.ts'. ========", - "======== Resolving module 'foo/index.js' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo/index.js'.", - "'paths' option is specified, looking for a pattern to match module name 'foo/index.js'.", - "Module name 'foo/index.js', matched pattern '*'.", - "Trying substitution '*', candidate module location: 'foo/index.js'.", - "File name '/foo/index.js' has a '.js' extension - stripping it.", - "Trying substitution './vendor/*', candidate module location: './vendor/foo/index.js'.", - "File name '/vendor/foo/index.js' has a '.js' extension - stripping it.", - "File '/vendor/foo/index.ts' does not exist.", - "File '/vendor/foo/index.tsx' does not exist.", - "File '/vendor/foo/index.d.ts' exist - use it as a name resolution result.", - "======== Module name 'foo/index.js' was successfully resolved to '/vendor/foo/index.d.ts'. ========", - "======== Resolving module 'hello.ts' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'hello.ts'.", - "'paths' option is specified, looking for a pattern to match module name 'hello.ts'.", - "Module name 'hello.ts', matched pattern '*'.", - "Trying substitution '*', candidate module location: 'hello.ts'.", - "File name '/hello.ts' has a '.ts' extension - stripping it.", - "File '/hello.ts' does not exist.", - "Trying substitution './vendor/*', candidate module location: './vendor/hello.ts'.", - "File name '/vendor/hello.ts' has a '.ts' extension - stripping it.", - "File '/vendor/hello.ts' does not exist.", - "Trying substitution './vendor/*/index.d.ts', candidate module location: './vendor/hello.ts/index.d.ts'.", - "File '/vendor/hello.ts/index.d.ts' does not exist.", - "File name '/vendor/hello.ts/index.d.ts' has a '.d.ts' extension - stripping it.", - "Trying substitution './apps/*', candidate module location: './apps/hello.ts'.", - "File name '/apps/hello.ts' has a '.ts' extension - stripping it.", - "File '/apps/hello.ts' exist - use it as a name resolution result.", - "======== Module name 'hello.ts' was successfully resolved to '/apps/hello.ts'. ========", - "======== Resolving module 'hello' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'hello'.", - "'paths' option is specified, looking for a pattern to match module name 'hello'.", - "Module name 'hello', matched pattern '*'.", - "Trying substitution '*', candidate module location: 'hello'.", - "Trying substitution './vendor/*', candidate module location: './vendor/hello'.", - "Trying substitution './vendor/*/index.d.ts', candidate module location: './vendor/hello/index.d.ts'.", - "File '/vendor/hello/index.d.ts' does not exist.", - "File name '/vendor/hello/index.d.ts' has a '.d.ts' extension - stripping it.", - "Trying substitution './apps/*', candidate module location: './apps/hello'.", - "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'hello'.", - "'paths' option is specified, looking for a pattern to match module name 'hello'.", - "Module name 'hello', matched pattern '*'.", - "Trying substitution '*', candidate module location: 'hello'.", - "Trying substitution './vendor/*', candidate module location: './vendor/hello'.", - "Trying substitution './vendor/*/index.d.ts', candidate module location: './vendor/hello/index.d.ts'.", - "File '/vendor/hello/index.d.ts' does not exist.", - "File name '/vendor/hello/index.d.ts' has a '.d.ts' extension - stripping it.", - "Trying substitution './apps/*', candidate module location: './apps/hello'.", - "======== Module name 'hello' was not resolved. ========", - "======== Resolving module 'foo.js' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo.js'.", - "'paths' option is specified, looking for a pattern to match module name 'foo.js'.", - "Module name 'foo.js', matched pattern '*'.", - "Trying substitution '*', candidate module location: 'foo.js'.", - "File name '/foo.js' has a '.js' extension - stripping it.", - "File '/foo.ts' exist - use it as a name resolution result.", - "======== Module name 'foo.js' was successfully resolved to '/foo.ts'. ========" -] \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).errors.txt b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).errors.txt deleted file mode 100644 index 5aa51b4e3c2f0..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).errors.txt +++ /dev/null @@ -1,107 +0,0 @@ -error TS5056: Cannot write file 'dist/c.js' because it would be overwritten by multiple input files. -error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. - The file is in the program because: - Root file specified for compilation -error TS6504: File '/project/b.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 -/project/main.ts(1,16): error TS2307: Cannot find module './a' or its corresponding type declarations. -/project/main.ts(3,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. -/project/main.ts(5,16): error TS2307: Cannot find module './b' or its corresponding type declarations. -/project/main.ts(7,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. -/project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? -/project/main.ts(11,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. -/project/main.ts(12,16): error TS5097: An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled. -/project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. -/project/main.ts(14,16): error TS2307: Cannot find module './d' or its corresponding type declarations. -/project/main.ts(15,16): error TS2307: Cannot find module './d/index' or its corresponding type declarations. -/project/main.ts(16,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. -/project/main.ts(18,16): error TS2307: Cannot find module './e' or its corresponding type declarations. -/project/types.d.ts(2,16): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. -/project/types.d.ts(3,21): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. - - -!!! error TS5056: Cannot write file 'dist/c.js' because it would be overwritten by multiple input files. -!!! error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. -!!! error TS6231: The file is in the program because: -!!! error TS6231: Root file specified for compilation -!!! error TS6504: File '/project/b.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 -==== /project/a.ts (0 errors) ==== - export {}; - -==== /project/b.ts (0 errors) ==== - export {}; - -==== /project/b.js (0 errors) ==== - export {}; - -==== /project/b.d.ts (0 errors) ==== - export {}; - -==== /project/c.ts (0 errors) ==== - export {}; - -==== /project/c.tsx (0 errors) ==== - export {}; - -==== /project/d/index.ts (0 errors) ==== - export {}; - -==== /project/e (0 errors) ==== - export {}; - -==== /project/main.ts (12 errors) ==== - import {} from "./a"; - ~~~~~ -!!! error TS2307: Cannot find module './a' or its corresponding type declarations. - import {} from "./a.js"; - import {} from "./a.ts"; - ~~~~~~~~ -!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. - - import {} from "./b"; - ~~~~~ -!!! error TS2307: Cannot find module './b' or its corresponding type declarations. - import {} from "./b.js"; - import {} from "./b.ts"; - ~~~~~~~~ -!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. - import {} from "./b.d.ts"; - ~~~~~~~~~~ -!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? - import type {} from "./b.d.ts"; - - import {} from "./c.ts"; - ~~~~~~~~ -!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. - import {} from "./c.tsx"; - ~~~~~~~~~ -!!! error TS5097: An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled. - ~~~~~~~~~ -!!! error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. - - import {} from "./d"; - ~~~~~ -!!! error TS2307: Cannot find module './d' or its corresponding type declarations. - import {} from "./d/index"; - ~~~~~~~~~~~ -!!! error TS2307: Cannot find module './d/index' or its corresponding type declarations. - import {} from "./d/index.ts"; - ~~~~~~~~~~~~~~ -!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. - - import {} from "./e"; - ~~~~~ -!!! error TS2307: Cannot find module './e' or its corresponding type declarations. - -==== /project/types.d.ts (2 errors) ==== - import {} from "./a.ts"; - import {} from "./a.d.ts"; - ~~~~~~~~~~ -!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. - import type {} from "./a.d.ts"; - ~~~~~~~~~~ -!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. - \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).js b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).js deleted file mode 100644 index 2eeeabf051a24..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).js +++ /dev/null @@ -1,64 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/minimal_relative.ts] //// - -//// [a.ts] -export {}; - -//// [b.ts] -export {}; - -//// [b.js] -export {}; - -//// [b.d.ts] -export {}; - -//// [c.ts] -export {}; - -//// [c.tsx] -export {}; - -//// [index.ts] -export {}; - -//// [e] -export {}; - -//// [main.ts] -import {} from "./a"; -import {} from "./a.js"; -import {} from "./a.ts"; - -import {} from "./b"; -import {} from "./b.js"; -import {} from "./b.ts"; -import {} from "./b.d.ts"; -import type {} from "./b.d.ts"; - -import {} from "./c.ts"; -import {} from "./c.tsx"; - -import {} from "./d"; -import {} from "./d/index"; -import {} from "./d/index.ts"; - -import {} from "./e"; - -//// [types.d.ts] -import {} from "./a.ts"; -import {} from "./a.d.ts"; -import type {} from "./a.d.ts"; - - -//// [a.js] -"use strict"; -exports.__esModule = true; -//// [b.js] -"use strict"; -exports.__esModule = true; -//// [index.js] -"use strict"; -exports.__esModule = true; -//// [main.js] -"use strict"; -exports.__esModule = true; diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).symbols b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).symbols deleted file mode 100644 index 8087e521944d1..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).symbols +++ /dev/null @@ -1,44 +0,0 @@ -=== /project/a.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.d.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.tsx === -export {}; -No type information for this code. -No type information for this code.=== /project/d/index.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/main.ts === -import {} from "./a"; -No type information for this code.import {} from "./a.js"; -No type information for this code.import {} from "./a.ts"; -No type information for this code. -No type information for this code.import {} from "./b"; -No type information for this code.import {} from "./b.js"; -No type information for this code.import {} from "./b.ts"; -No type information for this code.import {} from "./b.d.ts"; -No type information for this code.import type {} from "./b.d.ts"; -No type information for this code. -No type information for this code.import {} from "./c.ts"; -No type information for this code.import {} from "./c.tsx"; -No type information for this code. -No type information for this code.import {} from "./d"; -No type information for this code.import {} from "./d/index"; -No type information for this code.import {} from "./d/index.ts"; -No type information for this code. -No type information for this code.import {} from "./e"; -No type information for this code. -No type information for this code.=== /project/types.d.ts === -import {} from "./a.ts"; -No type information for this code.import {} from "./a.d.ts"; -No type information for this code.import type {} from "./a.d.ts"; -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).trace.json b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).trace.json deleted file mode 100644 index 40a02fe86a714..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).trace.json +++ /dev/null @@ -1,68 +0,0 @@ -[ - "======== Resolving module './a' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './a' was not resolved. ========", - "======== Resolving module './a.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/a.js' has a '.js' extension - stripping it.", - "File '/project/a.ts' exist - use it as a name resolution result.", - "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", - "======== Resolving module './a.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/a.ts' has a '.ts' extension - stripping it.", - "File '/project/a.ts' exist - use it as a name resolution result.", - "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", - "======== Resolving module './b' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './b' was not resolved. ========", - "======== Resolving module './b.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.js' has a '.js' extension - stripping it.", - "File '/project/b.ts' exist - use it as a name resolution result.", - "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", - "======== Resolving module './b.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.ts' has a '.ts' extension - stripping it.", - "File '/project/b.ts' exist - use it as a name resolution result.", - "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", - "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/b.d.ts' exist - use it as a name resolution result.", - "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", - "======== Resolving module './c.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/c.ts' has a '.ts' extension - stripping it.", - "File '/project/c.ts' exist - use it as a name resolution result.", - "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", - "======== Resolving module './c.tsx' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", - "File '/project/c.tsx' exist - use it as a name resolution result.", - "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", - "======== Resolving module './d' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './d' was not resolved. ========", - "======== Resolving module './d/index' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './d/index' was not resolved. ========", - "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", - "File '/project/d/index.ts' exist - use it as a name resolution result.", - "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", - "======== Resolving module './e' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './e' was not resolved. ========", - "======== Resolving module './a.ts' from '/project/types.d.ts'. ========", - "Resolution for module './a.ts' was found in cache from location '/project'.", - "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", - "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/a.d.ts' does not exist.", - "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/a.js' does not exist.", - "File '/project/a.jsx' does not exist.", - "======== Module name './a.d.ts' was not resolved. ========" -] \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).types b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).types deleted file mode 100644 index 8087e521944d1..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=false).types +++ /dev/null @@ -1,44 +0,0 @@ -=== /project/a.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.d.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.tsx === -export {}; -No type information for this code. -No type information for this code.=== /project/d/index.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/main.ts === -import {} from "./a"; -No type information for this code.import {} from "./a.js"; -No type information for this code.import {} from "./a.ts"; -No type information for this code. -No type information for this code.import {} from "./b"; -No type information for this code.import {} from "./b.js"; -No type information for this code.import {} from "./b.ts"; -No type information for this code.import {} from "./b.d.ts"; -No type information for this code.import type {} from "./b.d.ts"; -No type information for this code. -No type information for this code.import {} from "./c.ts"; -No type information for this code.import {} from "./c.tsx"; -No type information for this code. -No type information for this code.import {} from "./d"; -No type information for this code.import {} from "./d/index"; -No type information for this code.import {} from "./d/index.ts"; -No type information for this code. -No type information for this code.import {} from "./e"; -No type information for this code. -No type information for this code.=== /project/types.d.ts === -import {} from "./a.ts"; -No type information for this code.import {} from "./a.d.ts"; -No type information for this code.import type {} from "./a.d.ts"; -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).errors.txt b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).errors.txt deleted file mode 100644 index d7335e31c3223..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).errors.txt +++ /dev/null @@ -1,105 +0,0 @@ -error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. - The file is in the program because: - Root file specified for compilation -error TS6504: File '/project/b.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 -/project/main.ts(1,16): error TS2307: Cannot find module './a' or its corresponding type declarations. -/project/main.ts(3,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. -/project/main.ts(5,16): error TS2307: Cannot find module './b' or its corresponding type declarations. -/project/main.ts(7,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. -/project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? -/project/main.ts(11,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. -/project/main.ts(12,16): error TS5097: An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled. -/project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. -/project/main.ts(14,16): error TS2307: Cannot find module './d' or its corresponding type declarations. -/project/main.ts(15,16): error TS2307: Cannot find module './d/index' or its corresponding type declarations. -/project/main.ts(16,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. -/project/main.ts(18,16): error TS2307: Cannot find module './e' or its corresponding type declarations. -/project/types.d.ts(2,16): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. -/project/types.d.ts(3,21): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. - - -!!! error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. -!!! error TS6231: The file is in the program because: -!!! error TS6231: Root file specified for compilation -!!! error TS6504: File '/project/b.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 -==== /project/a.ts (0 errors) ==== - export {}; - -==== /project/b.ts (0 errors) ==== - export {}; - -==== /project/b.js (0 errors) ==== - export {}; - -==== /project/b.d.ts (0 errors) ==== - export {}; - -==== /project/c.ts (0 errors) ==== - export {}; - -==== /project/c.tsx (0 errors) ==== - export {}; - -==== /project/d/index.ts (0 errors) ==== - export {}; - -==== /project/e (0 errors) ==== - export {}; - -==== /project/main.ts (12 errors) ==== - import {} from "./a"; - ~~~~~ -!!! error TS2307: Cannot find module './a' or its corresponding type declarations. - import {} from "./a.js"; - import {} from "./a.ts"; - ~~~~~~~~ -!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. - - import {} from "./b"; - ~~~~~ -!!! error TS2307: Cannot find module './b' or its corresponding type declarations. - import {} from "./b.js"; - import {} from "./b.ts"; - ~~~~~~~~ -!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. - import {} from "./b.d.ts"; - ~~~~~~~~~~ -!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? - import type {} from "./b.d.ts"; - - import {} from "./c.ts"; - ~~~~~~~~ -!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. - import {} from "./c.tsx"; - ~~~~~~~~~ -!!! error TS5097: An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled. - ~~~~~~~~~ -!!! error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. - - import {} from "./d"; - ~~~~~ -!!! error TS2307: Cannot find module './d' or its corresponding type declarations. - import {} from "./d/index"; - ~~~~~~~~~~~ -!!! error TS2307: Cannot find module './d/index' or its corresponding type declarations. - import {} from "./d/index.ts"; - ~~~~~~~~~~~~~~ -!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. - - import {} from "./e"; - ~~~~~ -!!! error TS2307: Cannot find module './e' or its corresponding type declarations. - -==== /project/types.d.ts (2 errors) ==== - import {} from "./a.ts"; - import {} from "./a.d.ts"; - ~~~~~~~~~~ -!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. - import type {} from "./a.d.ts"; - ~~~~~~~~~~ -!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. - \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).symbols b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).symbols deleted file mode 100644 index 8087e521944d1..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).symbols +++ /dev/null @@ -1,44 +0,0 @@ -=== /project/a.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.d.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.tsx === -export {}; -No type information for this code. -No type information for this code.=== /project/d/index.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/main.ts === -import {} from "./a"; -No type information for this code.import {} from "./a.js"; -No type information for this code.import {} from "./a.ts"; -No type information for this code. -No type information for this code.import {} from "./b"; -No type information for this code.import {} from "./b.js"; -No type information for this code.import {} from "./b.ts"; -No type information for this code.import {} from "./b.d.ts"; -No type information for this code.import type {} from "./b.d.ts"; -No type information for this code. -No type information for this code.import {} from "./c.ts"; -No type information for this code.import {} from "./c.tsx"; -No type information for this code. -No type information for this code.import {} from "./d"; -No type information for this code.import {} from "./d/index"; -No type information for this code.import {} from "./d/index.ts"; -No type information for this code. -No type information for this code.import {} from "./e"; -No type information for this code. -No type information for this code.=== /project/types.d.ts === -import {} from "./a.ts"; -No type information for this code.import {} from "./a.d.ts"; -No type information for this code.import type {} from "./a.d.ts"; -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).trace.json b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).trace.json deleted file mode 100644 index 40a02fe86a714..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).trace.json +++ /dev/null @@ -1,68 +0,0 @@ -[ - "======== Resolving module './a' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './a' was not resolved. ========", - "======== Resolving module './a.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/a.js' has a '.js' extension - stripping it.", - "File '/project/a.ts' exist - use it as a name resolution result.", - "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", - "======== Resolving module './a.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/a.ts' has a '.ts' extension - stripping it.", - "File '/project/a.ts' exist - use it as a name resolution result.", - "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", - "======== Resolving module './b' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './b' was not resolved. ========", - "======== Resolving module './b.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.js' has a '.js' extension - stripping it.", - "File '/project/b.ts' exist - use it as a name resolution result.", - "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", - "======== Resolving module './b.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.ts' has a '.ts' extension - stripping it.", - "File '/project/b.ts' exist - use it as a name resolution result.", - "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", - "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/b.d.ts' exist - use it as a name resolution result.", - "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", - "======== Resolving module './c.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/c.ts' has a '.ts' extension - stripping it.", - "File '/project/c.ts' exist - use it as a name resolution result.", - "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", - "======== Resolving module './c.tsx' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", - "File '/project/c.tsx' exist - use it as a name resolution result.", - "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", - "======== Resolving module './d' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './d' was not resolved. ========", - "======== Resolving module './d/index' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './d/index' was not resolved. ========", - "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", - "File '/project/d/index.ts' exist - use it as a name resolution result.", - "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", - "======== Resolving module './e' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './e' was not resolved. ========", - "======== Resolving module './a.ts' from '/project/types.d.ts'. ========", - "Resolution for module './a.ts' was found in cache from location '/project'.", - "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", - "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/a.d.ts' does not exist.", - "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/a.js' does not exist.", - "File '/project/a.jsx' does not exist.", - "======== Module name './a.d.ts' was not resolved. ========" -] \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).types b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).types deleted file mode 100644 index 8087e521944d1..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=false,noemit=true).types +++ /dev/null @@ -1,44 +0,0 @@ -=== /project/a.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.d.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.tsx === -export {}; -No type information for this code. -No type information for this code.=== /project/d/index.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/main.ts === -import {} from "./a"; -No type information for this code.import {} from "./a.js"; -No type information for this code.import {} from "./a.ts"; -No type information for this code. -No type information for this code.import {} from "./b"; -No type information for this code.import {} from "./b.js"; -No type information for this code.import {} from "./b.ts"; -No type information for this code.import {} from "./b.d.ts"; -No type information for this code.import type {} from "./b.d.ts"; -No type information for this code. -No type information for this code.import {} from "./c.ts"; -No type information for this code.import {} from "./c.tsx"; -No type information for this code. -No type information for this code.import {} from "./d"; -No type information for this code.import {} from "./d/index"; -No type information for this code.import {} from "./d/index.ts"; -No type information for this code. -No type information for this code.import {} from "./e"; -No type information for this code. -No type information for this code.=== /project/types.d.ts === -import {} from "./a.ts"; -No type information for this code.import {} from "./a.d.ts"; -No type information for this code.import type {} from "./a.d.ts"; -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).errors.txt b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).errors.txt deleted file mode 100644 index f995ec83d1e1f..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).errors.txt +++ /dev/null @@ -1,94 +0,0 @@ -error TS5056: Cannot write file 'dist/c.js' because it would be overwritten by multiple input files. -error TS5096: Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'minimal' and either 'noEmit' or 'emitDeclarationOnly' is set. -error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. - The file is in the program because: - Root file specified for compilation -error TS6504: File '/project/b.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 -/project/main.ts(1,16): error TS2307: Cannot find module './a' or its corresponding type declarations. -/project/main.ts(5,16): error TS2307: Cannot find module './b' or its corresponding type declarations. -/project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? -/project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. -/project/main.ts(14,16): error TS2307: Cannot find module './d' or its corresponding type declarations. -/project/main.ts(15,16): error TS2307: Cannot find module './d/index' or its corresponding type declarations. -/project/main.ts(18,16): error TS2307: Cannot find module './e' or its corresponding type declarations. -/project/types.d.ts(2,16): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. -/project/types.d.ts(3,21): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. - - -!!! error TS5056: Cannot write file 'dist/c.js' because it would be overwritten by multiple input files. -!!! error TS5096: Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'minimal' and either 'noEmit' or 'emitDeclarationOnly' is set. -!!! error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. -!!! error TS6231: The file is in the program because: -!!! error TS6231: Root file specified for compilation -!!! error TS6504: File '/project/b.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 -==== /project/a.ts (0 errors) ==== - export {}; - -==== /project/b.ts (0 errors) ==== - export {}; - -==== /project/b.js (0 errors) ==== - export {}; - -==== /project/b.d.ts (0 errors) ==== - export {}; - -==== /project/c.ts (0 errors) ==== - export {}; - -==== /project/c.tsx (0 errors) ==== - export {}; - -==== /project/d/index.ts (0 errors) ==== - export {}; - -==== /project/e (0 errors) ==== - export {}; - -==== /project/main.ts (7 errors) ==== - import {} from "./a"; - ~~~~~ -!!! error TS2307: Cannot find module './a' or its corresponding type declarations. - import {} from "./a.js"; - import {} from "./a.ts"; - - import {} from "./b"; - ~~~~~ -!!! error TS2307: Cannot find module './b' or its corresponding type declarations. - import {} from "./b.js"; - import {} from "./b.ts"; - import {} from "./b.d.ts"; - ~~~~~~~~~~ -!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? - import type {} from "./b.d.ts"; - - import {} from "./c.ts"; - import {} from "./c.tsx"; - ~~~~~~~~~ -!!! error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. - - import {} from "./d"; - ~~~~~ -!!! error TS2307: Cannot find module './d' or its corresponding type declarations. - import {} from "./d/index"; - ~~~~~~~~~~~ -!!! error TS2307: Cannot find module './d/index' or its corresponding type declarations. - import {} from "./d/index.ts"; - - import {} from "./e"; - ~~~~~ -!!! error TS2307: Cannot find module './e' or its corresponding type declarations. - -==== /project/types.d.ts (2 errors) ==== - import {} from "./a.ts"; - import {} from "./a.d.ts"; - ~~~~~~~~~~ -!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. - import type {} from "./a.d.ts"; - ~~~~~~~~~~ -!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. - \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).js b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).js deleted file mode 100644 index 2eeeabf051a24..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).js +++ /dev/null @@ -1,64 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/minimal_relative.ts] //// - -//// [a.ts] -export {}; - -//// [b.ts] -export {}; - -//// [b.js] -export {}; - -//// [b.d.ts] -export {}; - -//// [c.ts] -export {}; - -//// [c.tsx] -export {}; - -//// [index.ts] -export {}; - -//// [e] -export {}; - -//// [main.ts] -import {} from "./a"; -import {} from "./a.js"; -import {} from "./a.ts"; - -import {} from "./b"; -import {} from "./b.js"; -import {} from "./b.ts"; -import {} from "./b.d.ts"; -import type {} from "./b.d.ts"; - -import {} from "./c.ts"; -import {} from "./c.tsx"; - -import {} from "./d"; -import {} from "./d/index"; -import {} from "./d/index.ts"; - -import {} from "./e"; - -//// [types.d.ts] -import {} from "./a.ts"; -import {} from "./a.d.ts"; -import type {} from "./a.d.ts"; - - -//// [a.js] -"use strict"; -exports.__esModule = true; -//// [b.js] -"use strict"; -exports.__esModule = true; -//// [index.js] -"use strict"; -exports.__esModule = true; -//// [main.js] -"use strict"; -exports.__esModule = true; diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).symbols b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).symbols deleted file mode 100644 index 8087e521944d1..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).symbols +++ /dev/null @@ -1,44 +0,0 @@ -=== /project/a.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.d.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.tsx === -export {}; -No type information for this code. -No type information for this code.=== /project/d/index.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/main.ts === -import {} from "./a"; -No type information for this code.import {} from "./a.js"; -No type information for this code.import {} from "./a.ts"; -No type information for this code. -No type information for this code.import {} from "./b"; -No type information for this code.import {} from "./b.js"; -No type information for this code.import {} from "./b.ts"; -No type information for this code.import {} from "./b.d.ts"; -No type information for this code.import type {} from "./b.d.ts"; -No type information for this code. -No type information for this code.import {} from "./c.ts"; -No type information for this code.import {} from "./c.tsx"; -No type information for this code. -No type information for this code.import {} from "./d"; -No type information for this code.import {} from "./d/index"; -No type information for this code.import {} from "./d/index.ts"; -No type information for this code. -No type information for this code.import {} from "./e"; -No type information for this code. -No type information for this code.=== /project/types.d.ts === -import {} from "./a.ts"; -No type information for this code.import {} from "./a.d.ts"; -No type information for this code.import type {} from "./a.d.ts"; -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).trace.json b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).trace.json deleted file mode 100644 index 40a02fe86a714..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).trace.json +++ /dev/null @@ -1,68 +0,0 @@ -[ - "======== Resolving module './a' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './a' was not resolved. ========", - "======== Resolving module './a.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/a.js' has a '.js' extension - stripping it.", - "File '/project/a.ts' exist - use it as a name resolution result.", - "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", - "======== Resolving module './a.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/a.ts' has a '.ts' extension - stripping it.", - "File '/project/a.ts' exist - use it as a name resolution result.", - "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", - "======== Resolving module './b' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './b' was not resolved. ========", - "======== Resolving module './b.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.js' has a '.js' extension - stripping it.", - "File '/project/b.ts' exist - use it as a name resolution result.", - "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", - "======== Resolving module './b.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.ts' has a '.ts' extension - stripping it.", - "File '/project/b.ts' exist - use it as a name resolution result.", - "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", - "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/b.d.ts' exist - use it as a name resolution result.", - "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", - "======== Resolving module './c.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/c.ts' has a '.ts' extension - stripping it.", - "File '/project/c.ts' exist - use it as a name resolution result.", - "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", - "======== Resolving module './c.tsx' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", - "File '/project/c.tsx' exist - use it as a name resolution result.", - "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", - "======== Resolving module './d' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './d' was not resolved. ========", - "======== Resolving module './d/index' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './d/index' was not resolved. ========", - "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", - "File '/project/d/index.ts' exist - use it as a name resolution result.", - "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", - "======== Resolving module './e' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './e' was not resolved. ========", - "======== Resolving module './a.ts' from '/project/types.d.ts'. ========", - "Resolution for module './a.ts' was found in cache from location '/project'.", - "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", - "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/a.d.ts' does not exist.", - "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/a.js' does not exist.", - "File '/project/a.jsx' does not exist.", - "======== Module name './a.d.ts' was not resolved. ========" -] \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).types b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).types deleted file mode 100644 index 8087e521944d1..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=false).types +++ /dev/null @@ -1,44 +0,0 @@ -=== /project/a.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.d.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.tsx === -export {}; -No type information for this code. -No type information for this code.=== /project/d/index.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/main.ts === -import {} from "./a"; -No type information for this code.import {} from "./a.js"; -No type information for this code.import {} from "./a.ts"; -No type information for this code. -No type information for this code.import {} from "./b"; -No type information for this code.import {} from "./b.js"; -No type information for this code.import {} from "./b.ts"; -No type information for this code.import {} from "./b.d.ts"; -No type information for this code.import type {} from "./b.d.ts"; -No type information for this code. -No type information for this code.import {} from "./c.ts"; -No type information for this code.import {} from "./c.tsx"; -No type information for this code. -No type information for this code.import {} from "./d"; -No type information for this code.import {} from "./d/index"; -No type information for this code.import {} from "./d/index.ts"; -No type information for this code. -No type information for this code.import {} from "./e"; -No type information for this code. -No type information for this code.=== /project/types.d.ts === -import {} from "./a.ts"; -No type information for this code.import {} from "./a.d.ts"; -No type information for this code.import type {} from "./a.d.ts"; -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).errors.txt b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).errors.txt deleted file mode 100644 index 96f418edbce5b..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).errors.txt +++ /dev/null @@ -1,90 +0,0 @@ -error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. - The file is in the program because: - Root file specified for compilation -error TS6504: File '/project/b.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 -/project/main.ts(1,16): error TS2307: Cannot find module './a' or its corresponding type declarations. -/project/main.ts(5,16): error TS2307: Cannot find module './b' or its corresponding type declarations. -/project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? -/project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. -/project/main.ts(14,16): error TS2307: Cannot find module './d' or its corresponding type declarations. -/project/main.ts(15,16): error TS2307: Cannot find module './d/index' or its corresponding type declarations. -/project/main.ts(18,16): error TS2307: Cannot find module './e' or its corresponding type declarations. -/project/types.d.ts(2,16): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. -/project/types.d.ts(3,21): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. - - -!!! error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. -!!! error TS6231: The file is in the program because: -!!! error TS6231: Root file specified for compilation -!!! error TS6504: File '/project/b.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 -==== /project/a.ts (0 errors) ==== - export {}; - -==== /project/b.ts (0 errors) ==== - export {}; - -==== /project/b.js (0 errors) ==== - export {}; - -==== /project/b.d.ts (0 errors) ==== - export {}; - -==== /project/c.ts (0 errors) ==== - export {}; - -==== /project/c.tsx (0 errors) ==== - export {}; - -==== /project/d/index.ts (0 errors) ==== - export {}; - -==== /project/e (0 errors) ==== - export {}; - -==== /project/main.ts (7 errors) ==== - import {} from "./a"; - ~~~~~ -!!! error TS2307: Cannot find module './a' or its corresponding type declarations. - import {} from "./a.js"; - import {} from "./a.ts"; - - import {} from "./b"; - ~~~~~ -!!! error TS2307: Cannot find module './b' or its corresponding type declarations. - import {} from "./b.js"; - import {} from "./b.ts"; - import {} from "./b.d.ts"; - ~~~~~~~~~~ -!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? - import type {} from "./b.d.ts"; - - import {} from "./c.ts"; - import {} from "./c.tsx"; - ~~~~~~~~~ -!!! error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. - - import {} from "./d"; - ~~~~~ -!!! error TS2307: Cannot find module './d' or its corresponding type declarations. - import {} from "./d/index"; - ~~~~~~~~~~~ -!!! error TS2307: Cannot find module './d/index' or its corresponding type declarations. - import {} from "./d/index.ts"; - - import {} from "./e"; - ~~~~~ -!!! error TS2307: Cannot find module './e' or its corresponding type declarations. - -==== /project/types.d.ts (2 errors) ==== - import {} from "./a.ts"; - import {} from "./a.d.ts"; - ~~~~~~~~~~ -!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. - import type {} from "./a.d.ts"; - ~~~~~~~~~~ -!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a.js' instead. - \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).symbols b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).symbols deleted file mode 100644 index 8087e521944d1..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).symbols +++ /dev/null @@ -1,44 +0,0 @@ -=== /project/a.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.d.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.tsx === -export {}; -No type information for this code. -No type information for this code.=== /project/d/index.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/main.ts === -import {} from "./a"; -No type information for this code.import {} from "./a.js"; -No type information for this code.import {} from "./a.ts"; -No type information for this code. -No type information for this code.import {} from "./b"; -No type information for this code.import {} from "./b.js"; -No type information for this code.import {} from "./b.ts"; -No type information for this code.import {} from "./b.d.ts"; -No type information for this code.import type {} from "./b.d.ts"; -No type information for this code. -No type information for this code.import {} from "./c.ts"; -No type information for this code.import {} from "./c.tsx"; -No type information for this code. -No type information for this code.import {} from "./d"; -No type information for this code.import {} from "./d/index"; -No type information for this code.import {} from "./d/index.ts"; -No type information for this code. -No type information for this code.import {} from "./e"; -No type information for this code. -No type information for this code.=== /project/types.d.ts === -import {} from "./a.ts"; -No type information for this code.import {} from "./a.d.ts"; -No type information for this code.import type {} from "./a.d.ts"; -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).trace.json b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).trace.json deleted file mode 100644 index 40a02fe86a714..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).trace.json +++ /dev/null @@ -1,68 +0,0 @@ -[ - "======== Resolving module './a' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './a' was not resolved. ========", - "======== Resolving module './a.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/a.js' has a '.js' extension - stripping it.", - "File '/project/a.ts' exist - use it as a name resolution result.", - "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", - "======== Resolving module './a.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/a.ts' has a '.ts' extension - stripping it.", - "File '/project/a.ts' exist - use it as a name resolution result.", - "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", - "======== Resolving module './b' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './b' was not resolved. ========", - "======== Resolving module './b.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.js' has a '.js' extension - stripping it.", - "File '/project/b.ts' exist - use it as a name resolution result.", - "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", - "======== Resolving module './b.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.ts' has a '.ts' extension - stripping it.", - "File '/project/b.ts' exist - use it as a name resolution result.", - "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", - "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/b.d.ts' exist - use it as a name resolution result.", - "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", - "======== Resolving module './c.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/c.ts' has a '.ts' extension - stripping it.", - "File '/project/c.ts' exist - use it as a name resolution result.", - "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", - "======== Resolving module './c.tsx' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", - "File '/project/c.tsx' exist - use it as a name resolution result.", - "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", - "======== Resolving module './d' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './d' was not resolved. ========", - "======== Resolving module './d/index' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './d/index' was not resolved. ========", - "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", - "File '/project/d/index.ts' exist - use it as a name resolution result.", - "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", - "======== Resolving module './e' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './e' was not resolved. ========", - "======== Resolving module './a.ts' from '/project/types.d.ts'. ========", - "Resolution for module './a.ts' was found in cache from location '/project'.", - "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", - "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/a.d.ts' does not exist.", - "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/a.js' does not exist.", - "File '/project/a.jsx' does not exist.", - "======== Module name './a.d.ts' was not resolved. ========" -] \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).types b/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).types deleted file mode 100644 index 8087e521944d1..0000000000000 --- a/tests/baselines/reference/minimal_relative(allowimportingtsextensions=true,noemit=true).types +++ /dev/null @@ -1,44 +0,0 @@ -=== /project/a.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.d.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.tsx === -export {}; -No type information for this code. -No type information for this code.=== /project/d/index.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/main.ts === -import {} from "./a"; -No type information for this code.import {} from "./a.js"; -No type information for this code.import {} from "./a.ts"; -No type information for this code. -No type information for this code.import {} from "./b"; -No type information for this code.import {} from "./b.js"; -No type information for this code.import {} from "./b.ts"; -No type information for this code.import {} from "./b.d.ts"; -No type information for this code.import type {} from "./b.d.ts"; -No type information for this code. -No type information for this code.import {} from "./c.ts"; -No type information for this code.import {} from "./c.tsx"; -No type information for this code. -No type information for this code.import {} from "./d"; -No type information for this code.import {} from "./d/index"; -No type information for this code.import {} from "./d/index.ts"; -No type information for this code. -No type information for this code.import {} from "./e"; -No type information for this code. -No type information for this code.=== /project/types.d.ts === -import {} from "./a.ts"; -No type information for this code.import {} from "./a.d.ts"; -No type information for this code.import type {} from "./a.d.ts"; -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(noemit=false).errors.txt b/tests/baselines/reference/minimal_relative(noemit=false).errors.txt deleted file mode 100644 index 04640dbdd2934..0000000000000 --- a/tests/baselines/reference/minimal_relative(noemit=false).errors.txt +++ /dev/null @@ -1,96 +0,0 @@ -error TS5056: Cannot write file 'dist/c.js' because it would be overwritten by multiple input files. -error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. - The file is in the program because: - Root file specified for compilation -error TS6504: File '/project/b.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 -/project/main.ts(1,16): error TS2307: Cannot find module './a' or its corresponding type declarations. -/project/main.ts(3,16): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './a.js' instead. -/project/main.ts(5,16): error TS2307: Cannot find module './b' or its corresponding type declarations. -/project/main.ts(7,16): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './b.js' instead. -/project/main.ts(8,16): error TS2845: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? -/project/main.ts(11,16): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './c.js' instead. -/project/main.ts(12,16): error TS2691: An import path cannot end with a '.tsx' extension. Consider importing './c.js' instead. -/project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. -/project/main.ts(14,16): error TS2307: Cannot find module './d' or its corresponding type declarations. -/project/main.ts(15,16): error TS2307: Cannot find module './d/index' or its corresponding type declarations. -/project/main.ts(16,16): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './d/index.js' instead. -/project/main.ts(18,16): error TS2307: Cannot find module './e' or its corresponding type declarations. - - -!!! error TS5056: Cannot write file 'dist/c.js' because it would be overwritten by multiple input files. -!!! error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. -!!! error TS6231: The file is in the program because: -!!! error TS6231: Root file specified for compilation -!!! error TS6504: File '/project/b.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 -==== /project/a.ts (0 errors) ==== - export {}; - -==== /project/b.ts (0 errors) ==== - export {}; - -==== /project/b.js (0 errors) ==== - export {}; - -==== /project/b.d.ts (0 errors) ==== - export {}; - -==== /project/c.ts (0 errors) ==== - export {}; - -==== /project/c.tsx (0 errors) ==== - export {}; - -==== /project/d/index.ts (0 errors) ==== - export {}; - -==== /project/e (0 errors) ==== - export {}; - -==== /project/main.ts (12 errors) ==== - import {} from "./a"; - ~~~~~ -!!! error TS2307: Cannot find module './a' or its corresponding type declarations. - import {} from "./a.js"; - import {} from "./a.ts"; - ~~~~~~~~ -!!! error TS2691: An import path cannot end with a '.ts' extension. Consider importing './a.js' instead. - - import {} from "./b"; - ~~~~~ -!!! error TS2307: Cannot find module './b' or its corresponding type declarations. - import {} from "./b.js"; - import {} from "./b.ts"; - ~~~~~~~~ -!!! error TS2691: An import path cannot end with a '.ts' extension. Consider importing './b.js' instead. - import {} from "./b.d.ts"; - ~~~~~~~~~~ -!!! error TS2845: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? - import type {} from "./b.d.ts"; - - import {} from "./c.ts"; - ~~~~~~~~ -!!! error TS2691: An import path cannot end with a '.ts' extension. Consider importing './c.js' instead. - import {} from "./c.tsx"; - ~~~~~~~~~ -!!! error TS2691: An import path cannot end with a '.tsx' extension. Consider importing './c.js' instead. - ~~~~~~~~~ -!!! error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. - - import {} from "./d"; - ~~~~~ -!!! error TS2307: Cannot find module './d' or its corresponding type declarations. - import {} from "./d/index"; - ~~~~~~~~~~~ -!!! error TS2307: Cannot find module './d/index' or its corresponding type declarations. - import {} from "./d/index.ts"; - ~~~~~~~~~~~~~~ -!!! error TS2691: An import path cannot end with a '.ts' extension. Consider importing './d/index.js' instead. - - import {} from "./e"; - ~~~~~ -!!! error TS2307: Cannot find module './e' or its corresponding type declarations. - \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(noemit=false).js b/tests/baselines/reference/minimal_relative(noemit=false).js deleted file mode 100644 index 4044dbad4adb8..0000000000000 --- a/tests/baselines/reference/minimal_relative(noemit=false).js +++ /dev/null @@ -1,59 +0,0 @@ -//// [tests/cases/conformance/moduleResolution/minimal_relative.ts] //// - -//// [a.ts] -export {}; - -//// [b.ts] -export {}; - -//// [b.js] -export {}; - -//// [b.d.ts] -export {}; - -//// [c.ts] -export {}; - -//// [c.tsx] -export {}; - -//// [index.ts] -export {}; - -//// [e] -export {}; - -//// [main.ts] -import {} from "./a"; -import {} from "./a.js"; -import {} from "./a.ts"; - -import {} from "./b"; -import {} from "./b.js"; -import {} from "./b.ts"; -import {} from "./b.d.ts"; -import type {} from "./b.d.ts"; - -import {} from "./c.ts"; -import {} from "./c.tsx"; - -import {} from "./d"; -import {} from "./d/index"; -import {} from "./d/index.ts"; - -import {} from "./e"; - - -//// [a.js] -"use strict"; -exports.__esModule = true; -//// [b.js] -"use strict"; -exports.__esModule = true; -//// [index.js] -"use strict"; -exports.__esModule = true; -//// [main.js] -"use strict"; -exports.__esModule = true; diff --git a/tests/baselines/reference/minimal_relative(noemit=false).symbols b/tests/baselines/reference/minimal_relative(noemit=false).symbols deleted file mode 100644 index 13a097c71c1b7..0000000000000 --- a/tests/baselines/reference/minimal_relative(noemit=false).symbols +++ /dev/null @@ -1,39 +0,0 @@ -=== /project/a.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.d.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.tsx === -export {}; -No type information for this code. -No type information for this code.=== /project/d/index.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/main.ts === -import {} from "./a"; -No type information for this code.import {} from "./a.js"; -No type information for this code.import {} from "./a.ts"; -No type information for this code. -No type information for this code.import {} from "./b"; -No type information for this code.import {} from "./b.js"; -No type information for this code.import {} from "./b.ts"; -No type information for this code.import {} from "./b.d.ts"; -No type information for this code.import type {} from "./b.d.ts"; -No type information for this code. -No type information for this code.import {} from "./c.ts"; -No type information for this code.import {} from "./c.tsx"; -No type information for this code. -No type information for this code.import {} from "./d"; -No type information for this code.import {} from "./d/index"; -No type information for this code.import {} from "./d/index.ts"; -No type information for this code. -No type information for this code.import {} from "./e"; -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(noemit=false).trace.json b/tests/baselines/reference/minimal_relative(noemit=false).trace.json deleted file mode 100644 index 33784890cf65f..0000000000000 --- a/tests/baselines/reference/minimal_relative(noemit=false).trace.json +++ /dev/null @@ -1,57 +0,0 @@ -[ - "======== Resolving module './a' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './a' was not resolved. ========", - "======== Resolving module './a.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/a.js' has a '.js' extension - stripping it.", - "File '/project/a.ts' exist - use it as a name resolution result.", - "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", - "======== Resolving module './a.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/a.ts' has a '.ts' extension - stripping it.", - "File '/project/a.ts' exist - use it as a name resolution result.", - "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", - "======== Resolving module './b' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './b' was not resolved. ========", - "======== Resolving module './b.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.js' has a '.js' extension - stripping it.", - "File '/project/b.ts' exist - use it as a name resolution result.", - "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", - "======== Resolving module './b.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.ts' has a '.ts' extension - stripping it.", - "File '/project/b.ts' exist - use it as a name resolution result.", - "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", - "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/b.d.ts' exist - use it as a name resolution result.", - "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", - "======== Resolving module './c.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/c.ts' has a '.ts' extension - stripping it.", - "File '/project/c.ts' exist - use it as a name resolution result.", - "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", - "======== Resolving module './c.tsx' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", - "File '/project/c.tsx' exist - use it as a name resolution result.", - "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", - "======== Resolving module './d' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './d' was not resolved. ========", - "======== Resolving module './d/index' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './d/index' was not resolved. ========", - "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", - "File '/project/d/index.ts' exist - use it as a name resolution result.", - "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", - "======== Resolving module './e' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './e' was not resolved. ========" -] \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(noemit=false).types b/tests/baselines/reference/minimal_relative(noemit=false).types deleted file mode 100644 index 13a097c71c1b7..0000000000000 --- a/tests/baselines/reference/minimal_relative(noemit=false).types +++ /dev/null @@ -1,39 +0,0 @@ -=== /project/a.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.d.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.tsx === -export {}; -No type information for this code. -No type information for this code.=== /project/d/index.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/main.ts === -import {} from "./a"; -No type information for this code.import {} from "./a.js"; -No type information for this code.import {} from "./a.ts"; -No type information for this code. -No type information for this code.import {} from "./b"; -No type information for this code.import {} from "./b.js"; -No type information for this code.import {} from "./b.ts"; -No type information for this code.import {} from "./b.d.ts"; -No type information for this code.import type {} from "./b.d.ts"; -No type information for this code. -No type information for this code.import {} from "./c.ts"; -No type information for this code.import {} from "./c.tsx"; -No type information for this code. -No type information for this code.import {} from "./d"; -No type information for this code.import {} from "./d/index"; -No type information for this code.import {} from "./d/index.ts"; -No type information for this code. -No type information for this code.import {} from "./e"; -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(noemit=true).errors.txt b/tests/baselines/reference/minimal_relative(noemit=true).errors.txt deleted file mode 100644 index b5584db1abe5f..0000000000000 --- a/tests/baselines/reference/minimal_relative(noemit=true).errors.txt +++ /dev/null @@ -1,79 +0,0 @@ -error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. - The file is in the program because: - Root file specified for compilation -error TS6504: File '/project/b.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 -/project/main.ts(1,16): error TS2307: Cannot find module './a' or its corresponding type declarations. -/project/main.ts(5,16): error TS2307: Cannot find module './b' or its corresponding type declarations. -/project/main.ts(8,16): error TS2845: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? -/project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. -/project/main.ts(14,16): error TS2307: Cannot find module './d' or its corresponding type declarations. -/project/main.ts(15,16): error TS2307: Cannot find module './d/index' or its corresponding type declarations. -/project/main.ts(18,16): error TS2307: Cannot find module './e' or its corresponding type declarations. - - -!!! error TS6231: Could not resolve the path '/project/e' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. -!!! error TS6231: The file is in the program because: -!!! error TS6231: Root file specified for compilation -!!! error TS6504: File '/project/b.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 -==== /project/a.ts (0 errors) ==== - export {}; - -==== /project/b.ts (0 errors) ==== - export {}; - -==== /project/b.js (0 errors) ==== - export {}; - -==== /project/b.d.ts (0 errors) ==== - export {}; - -==== /project/c.ts (0 errors) ==== - export {}; - -==== /project/c.tsx (0 errors) ==== - export {}; - -==== /project/d/index.ts (0 errors) ==== - export {}; - -==== /project/e (0 errors) ==== - export {}; - -==== /project/main.ts (7 errors) ==== - import {} from "./a"; - ~~~~~ -!!! error TS2307: Cannot find module './a' or its corresponding type declarations. - import {} from "./a.js"; - import {} from "./a.ts"; - - import {} from "./b"; - ~~~~~ -!!! error TS2307: Cannot find module './b' or its corresponding type declarations. - import {} from "./b.js"; - import {} from "./b.ts"; - import {} from "./b.d.ts"; - ~~~~~~~~~~ -!!! error TS2845: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b.js' instead? - import type {} from "./b.d.ts"; - - import {} from "./c.ts"; - import {} from "./c.tsx"; - ~~~~~~~~~ -!!! error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. - - import {} from "./d"; - ~~~~~ -!!! error TS2307: Cannot find module './d' or its corresponding type declarations. - import {} from "./d/index"; - ~~~~~~~~~~~ -!!! error TS2307: Cannot find module './d/index' or its corresponding type declarations. - import {} from "./d/index.ts"; - - import {} from "./e"; - ~~~~~ -!!! error TS2307: Cannot find module './e' or its corresponding type declarations. - \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(noemit=true).symbols b/tests/baselines/reference/minimal_relative(noemit=true).symbols deleted file mode 100644 index 13a097c71c1b7..0000000000000 --- a/tests/baselines/reference/minimal_relative(noemit=true).symbols +++ /dev/null @@ -1,39 +0,0 @@ -=== /project/a.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.d.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.tsx === -export {}; -No type information for this code. -No type information for this code.=== /project/d/index.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/main.ts === -import {} from "./a"; -No type information for this code.import {} from "./a.js"; -No type information for this code.import {} from "./a.ts"; -No type information for this code. -No type information for this code.import {} from "./b"; -No type information for this code.import {} from "./b.js"; -No type information for this code.import {} from "./b.ts"; -No type information for this code.import {} from "./b.d.ts"; -No type information for this code.import type {} from "./b.d.ts"; -No type information for this code. -No type information for this code.import {} from "./c.ts"; -No type information for this code.import {} from "./c.tsx"; -No type information for this code. -No type information for this code.import {} from "./d"; -No type information for this code.import {} from "./d/index"; -No type information for this code.import {} from "./d/index.ts"; -No type information for this code. -No type information for this code.import {} from "./e"; -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(noemit=true).trace.json b/tests/baselines/reference/minimal_relative(noemit=true).trace.json deleted file mode 100644 index 33784890cf65f..0000000000000 --- a/tests/baselines/reference/minimal_relative(noemit=true).trace.json +++ /dev/null @@ -1,57 +0,0 @@ -[ - "======== Resolving module './a' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './a' was not resolved. ========", - "======== Resolving module './a.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/a.js' has a '.js' extension - stripping it.", - "File '/project/a.ts' exist - use it as a name resolution result.", - "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", - "======== Resolving module './a.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/a.ts' has a '.ts' extension - stripping it.", - "File '/project/a.ts' exist - use it as a name resolution result.", - "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", - "======== Resolving module './b' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './b' was not resolved. ========", - "======== Resolving module './b.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.js' has a '.js' extension - stripping it.", - "File '/project/b.ts' exist - use it as a name resolution result.", - "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", - "======== Resolving module './b.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.ts' has a '.ts' extension - stripping it.", - "File '/project/b.ts' exist - use it as a name resolution result.", - "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", - "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/b.d.ts' exist - use it as a name resolution result.", - "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", - "======== Resolving module './c.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/c.ts' has a '.ts' extension - stripping it.", - "File '/project/c.ts' exist - use it as a name resolution result.", - "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", - "======== Resolving module './c.tsx' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", - "File '/project/c.tsx' exist - use it as a name resolution result.", - "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", - "======== Resolving module './d' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './d' was not resolved. ========", - "======== Resolving module './d/index' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './d/index' was not resolved. ========", - "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", - "File '/project/d/index.ts' exist - use it as a name resolution result.", - "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", - "======== Resolving module './e' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Minimal'.", - "======== Module name './e' was not resolved. ========" -] \ No newline at end of file diff --git a/tests/baselines/reference/minimal_relative(noemit=true).types b/tests/baselines/reference/minimal_relative(noemit=true).types deleted file mode 100644 index 13a097c71c1b7..0000000000000 --- a/tests/baselines/reference/minimal_relative(noemit=true).types +++ /dev/null @@ -1,39 +0,0 @@ -=== /project/a.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/b.d.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/c.tsx === -export {}; -No type information for this code. -No type information for this code.=== /project/d/index.ts === -export {}; -No type information for this code. -No type information for this code.=== /project/main.ts === -import {} from "./a"; -No type information for this code.import {} from "./a.js"; -No type information for this code.import {} from "./a.ts"; -No type information for this code. -No type information for this code.import {} from "./b"; -No type information for this code.import {} from "./b.js"; -No type information for this code.import {} from "./b.ts"; -No type information for this code.import {} from "./b.d.ts"; -No type information for this code.import type {} from "./b.d.ts"; -No type information for this code. -No type information for this code.import {} from "./c.ts"; -No type information for this code.import {} from "./c.tsx"; -No type information for this code. -No type information for this code.import {} from "./d"; -No type information for this code.import {} from "./d/index"; -No type information for this code.import {} from "./d/index.ts"; -No type information for this code. -No type information for this code.import {} from "./e"; -No type information for this code. -No type information for this code. \ No newline at end of file diff --git a/tests/cases/conformance/moduleResolution/minimal_nodeModules.ts b/tests/cases/conformance/moduleResolution/minimal_nodeModules.ts deleted file mode 100644 index 1ddb7f9153345..0000000000000 --- a/tests/cases/conformance/moduleResolution/minimal_nodeModules.ts +++ /dev/null @@ -1,16 +0,0 @@ -// @moduleResolution: minimal - -// @Filename: /node_modules/foo/index.d.ts -import {} from "./other.js"; -export {}; - -// @Filename: /node_modules/foo/other.d.ts -export {}; - -// @Filename: /node_modules/@types/foo/index.d.ts -export {}; - -// @Filename: /main.ts -import {} from "foo"; -import {} from "./node_modules/foo/index.js"; -import type {} from "./node_modules/@types/foo/index.d.ts"; diff --git a/tests/cases/conformance/moduleResolution/minimal_nodeModules_declarationEmit.ts b/tests/cases/conformance/moduleResolution/minimal_nodeModules_declarationEmit.ts deleted file mode 100644 index b621aeab6431f..0000000000000 --- a/tests/cases/conformance/moduleResolution/minimal_nodeModules_declarationEmit.ts +++ /dev/null @@ -1,14 +0,0 @@ -// @moduleResolution: minimal -// @declaration: true - -// @Filename: /node_modules/foo/module.d.ts -export declare class SomeExportedClass { - private foo: any; -} - -declare global { - function returnsPrivateClassOhNo(): SomeExportedClass; -} - -// @Filename: /main.ts -export const boom = returnsPrivateClassOhNo(); diff --git a/tests/cases/conformance/moduleResolution/minimal_nonRelative.ts b/tests/cases/conformance/moduleResolution/minimal_nonRelative.ts deleted file mode 100644 index e055574fc2739..0000000000000 --- a/tests/cases/conformance/moduleResolution/minimal_nonRelative.ts +++ /dev/null @@ -1,14 +0,0 @@ -// @moduleResolution: minimal -// @noEmit: true -// @traceResolution: true -// @noTypesAndSymbols: true - -// @Filename: /node_modules/@types/foo/index.d.ts -export {}; - -// @Filename: /node_modules/bar/index.d.ts -export {}; - -// @Filename: /main.ts -import {} from "foo"; -import {} from "bar"; diff --git a/tests/cases/conformance/moduleResolution/minimal_pathsAndBaseUrl.ts b/tests/cases/conformance/moduleResolution/minimal_pathsAndBaseUrl.ts deleted file mode 100644 index 74ae8ffcde21e..0000000000000 --- a/tests/cases/conformance/moduleResolution/minimal_pathsAndBaseUrl.ts +++ /dev/null @@ -1,36 +0,0 @@ -// @traceResolution: true -// @noTypesAndSymbols: true - -// @Filename: /tsconfig.json -{ - "compilerOptions": { - "moduleResolution": "minimal", - "noEmit": true, - "allowImportingTsExtensions": true, - "baseUrl": ".", - "paths": { - "*": [ - "*", - "./vendor/*", - "./vendor/*/index.d.ts", - "./apps/*" - ] - } - } -} - -// @Filename: /vendor/foo/index.d.ts -export {}; - -// @Filename: /apps/hello.ts -export {}; - -// @Filename: /foo.ts -export {}; - -// @Filename: /main.ts -import {} from "foo"; -import {} from "foo/index.js"; -import {} from "hello.ts"; -import {} from "hello"; -import {} from "foo.js"; diff --git a/tests/cases/conformance/moduleResolution/minimal_relative.ts b/tests/cases/conformance/moduleResolution/minimal_relative.ts deleted file mode 100644 index 21eb4828223f5..0000000000000 --- a/tests/cases/conformance/moduleResolution/minimal_relative.ts +++ /dev/null @@ -1,54 +0,0 @@ -// @moduleResolution: minimal -// @outDir: dist -// @noEmit: true,false -// @allowImportingTsExtensions: true,false -// @traceResolution: true - -// @Filename: /project/a.ts -export {}; - -// @Filename: /project/b.ts -export {}; - -// @Filename: /project/b.js -export {}; - -// @Filename: /project/b.d.ts -export {}; - -// @Filename: /project/c.ts -export {}; - -// @Filename: /project/c.tsx -export {}; - -// @Filename: /project/d/index.ts -export {}; - -// @Filename: /project/e -export {}; - -// @Filename: /project/main.ts -import {} from "./a"; -import {} from "./a.js"; -import {} from "./a.ts"; - -import {} from "./b"; -import {} from "./b.js"; -import {} from "./b.ts"; -import {} from "./b.d.ts"; -import type {} from "./b.d.ts"; - -import {} from "./c.ts"; -import {} from "./c.tsx"; - -import {} from "./d"; -import {} from "./d/index"; -import {} from "./d/index.ts"; - -import {} from "./e"; - -// @Filename: /project/types.d.ts -import {} from "./a.ts"; -import {} from "./a.d.ts"; -import type {} from "./a.d.ts"; diff --git a/tests/cases/fourslash/autoImportsMinimal1.ts b/tests/cases/fourslash/autoImportsMinimal1.ts deleted file mode 100644 index 1796a03b00f28..0000000000000 --- a/tests/cases/fourslash/autoImportsMinimal1.ts +++ /dev/null @@ -1,20 +0,0 @@ -/// - -// @moduleResolution: minimal - -// @Filename: /node_modules/@types/foo/index.d.ts -//// export const fromAtTypesFoo: number; - -// @Filename: /node_modules/bar/index.d.ts -//// export const fromBar: number; - -// @Filename: /local.ts -//// export const fromLocal: number; - -// @Filename: /Component.tsx -//// export function Component() { return null; } - -// @Filename: /main.ts -//// /**/ - -verify.baselineAutoImports(""); diff --git a/tests/cases/fourslash/autoImportsMinimal2.ts b/tests/cases/fourslash/autoImportsMinimal2.ts deleted file mode 100644 index c98a84aa859be..0000000000000 --- a/tests/cases/fourslash/autoImportsMinimal2.ts +++ /dev/null @@ -1,22 +0,0 @@ -/// - -// @moduleResolution: minimal -// @allowImportingTsExtensions: true -// @noEmit: true - -// @Filename: /node_modules/@types/foo/index.d.ts -//// export const fromAtTypesFoo: number; - -// @Filename: /node_modules/bar/index.d.ts -//// export const fromBar: number; - -// @Filename: /local.ts -//// export const fromLocal: number; - -// @Filename: /Component.tsx -//// export function Component() { return null; } - -// @Filename: /main.ts -//// /**/ - -verify.baselineAutoImports(""); diff --git a/tests/cases/fourslash/pathCompletionsMinimal1.ts b/tests/cases/fourslash/pathCompletionsMinimal1.ts deleted file mode 100644 index a3843b535f648..0000000000000 --- a/tests/cases/fourslash/pathCompletionsMinimal1.ts +++ /dev/null @@ -1,31 +0,0 @@ -/// - -// @moduleResolution: minimal - -// @Filename: /project/node_modules/@types/foo/index.d.ts -//// export const fromAtTypesFoo: number; - -// @Filename: /project/node_modules/bar/index.d.ts -//// export const fromBar: number; - -// @Filename: /project/local.ts -//// export const fromLocal: number; - -// @Filename: /project/Component.tsx -//// export function Component() { return null; } - -// @Filename: /project/main.ts -//// import {} from "/**/"; - -verify.completions({ - isNewIdentifierLocation: true, - marker: "", - exact: [] -}); - -edit.insert("./"); - -verify.completions({ - isNewIdentifierLocation: true, - exact: ["Component.js", "local.js"], -}); diff --git a/tests/cases/fourslash/pathCompletionsMinimal2.ts b/tests/cases/fourslash/pathCompletionsMinimal2.ts deleted file mode 100644 index e9a27356b02b3..0000000000000 --- a/tests/cases/fourslash/pathCompletionsMinimal2.ts +++ /dev/null @@ -1,33 +0,0 @@ -/// - -// @moduleResolution: minimal -// @allowImportingTsExtensions: true -// @noEmit: true - -// @Filename: /project/node_modules/@types/foo/index.d.ts -//// export const fromAtTypesFoo: number; - -// @Filename: /project/node_modules/bar/index.d.ts -//// export const fromBar: number; - -// @Filename: /project/local.ts -//// export const fromLocal: number; - -// @Filename: /project/Component.tsx -//// export function Component() { return null; } - -// @Filename: /project/main.ts -//// import {} from "/**/"; - -verify.completions({ - isNewIdentifierLocation: true, - marker: "", - exact: [] -}); - -edit.insert("./"); - -verify.completions({ - isNewIdentifierLocation: true, - exact: ["Component.tsx", "local.ts"], -}); From 7fd3e72c4d5b87bcc716fecd6cc585a3453df3cd Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 13 Oct 2022 16:50:00 -0700 Subject: [PATCH 17/41] Update unit tests --- src/testRunner/unittests/config/commandLineParsing.ts | 2 +- tests/baselines/reference/api/tsserverlibrary.d.ts | 6 ++---- tests/baselines/reference/api/typescript.d.ts | 6 ++---- .../tsConfig/Default initialized TSConfig/tsconfig.json | 1 - .../tsConfig/Initialized TSConfig with --help/tsconfig.json | 1 - .../Initialized TSConfig with --watch/tsconfig.json | 1 - .../tsconfig.json | 1 - .../tsconfig.json | 1 - .../tsconfig.json | 1 - .../Initialized TSConfig with files options/tsconfig.json | 1 - .../tsconfig.json | 1 - .../tsconfig.json | 1 - .../tsconfig.json | 1 - .../tsconfig.json | 1 - .../declarationDir-is-specified.js | 1 - .../when-outDir-and-declarationDir-is-specified.js | 1 - .../when-outDir-is-specified.js | 1 - .../with-outFile.js | 1 - ...tDir-or-outFile-is-specified-with-declaration-enabled.js | 1 - .../without-outDir-or-outFile-is-specified.js | 1 - 20 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index 07ecbb7393328..e2b48977106b6 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -237,7 +237,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext', 'minimal'.", + messageText: "Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index a976eb443e2b1..56dfcfe9f2202 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2941,8 +2941,7 @@ declare namespace ts { Classic = 1, NodeJs = 2, Node16 = 3, - NodeNext = 99, - Minimal = 100 + NodeNext = 99 } export enum ModuleDetectionKind { /** @@ -5060,8 +5059,7 @@ declare namespace ts { export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations; export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - export function minimalModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - export function shouldResolveTsExtension(compilerOptions: CompilerOptions): boolean; + export function moduleResolutionSupportsResolvingTsExtensions(_compilerOptions: CompilerOptions): boolean; export function shouldAllowImportingTsExtension(compilerOptions: CompilerOptions, fromFileName?: string): boolean | "" | undefined; export {}; } diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 94e3cced1c674..076d6b9e8b40c 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2941,8 +2941,7 @@ declare namespace ts { Classic = 1, NodeJs = 2, Node16 = 3, - NodeNext = 99, - Minimal = 100 + NodeNext = 99 } export enum ModuleDetectionKind { /** @@ -5060,8 +5059,7 @@ declare namespace ts { export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations; export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - export function minimalModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations; - export function shouldResolveTsExtension(compilerOptions: CompilerOptions): boolean; + export function moduleResolutionSupportsResolvingTsExtensions(_compilerOptions: CompilerOptions): boolean; export function shouldAllowImportingTsExtension(compilerOptions: CompilerOptions, fromFileName?: string): boolean | "" | undefined; export {}; } diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index 5cad175ba34fa..75dcaeac2e2b9 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -35,7 +35,6 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with --help/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with --help/tsconfig.json index 5cad175ba34fa..75dcaeac2e2b9 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with --help/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with --help/tsconfig.json @@ -35,7 +35,6 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with --watch/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with --watch/tsconfig.json index 5cad175ba34fa..75dcaeac2e2b9 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with --watch/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with --watch/tsconfig.json @@ -35,7 +35,6 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json index e1b9e67e7b66d..ce36f2a0fcfd7 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json @@ -35,7 +35,6 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index cc29170683efb..a4be57dd3410e 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -35,7 +35,6 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index 0b6e055e0a2cd..faa350ae98575 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -35,7 +35,6 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index 01830a8f79b49..09587994ffbcd 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -35,7 +35,6 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 6798430ea05ee..abb2dfd47088b 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -35,7 +35,6 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index 5cad175ba34fa..75dcaeac2e2b9 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -35,7 +35,6 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index 6bae69884ebdb..04aa9196bfc65 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -35,7 +35,6 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index c6de1fdcc3575..4eb9bb8aa4b84 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -35,7 +35,6 @@ "types": ["jquery","mocha"], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/declarationDir-is-specified.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/declarationDir-is-specified.js index 782dc8bc57911..2cf43a8189e28 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/declarationDir-is-specified.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/declarationDir-is-specified.js @@ -56,7 +56,6 @@ interface Array { length: number; [n: number]: T; } // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-and-declarationDir-is-specified.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-and-declarationDir-is-specified.js index 54e482fe2570b..0bdc2d356c5e3 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-and-declarationDir-is-specified.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-and-declarationDir-is-specified.js @@ -56,7 +56,6 @@ interface Array { length: number; [n: number]: T; } // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-is-specified.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-is-specified.js index 5b88985795b6e..673a8e6669886 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-is-specified.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-is-specified.js @@ -56,7 +56,6 @@ interface Array { length: number; [n: number]: T; } // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/with-outFile.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/with-outFile.js index 482495d68b2c7..83e6548b002fb 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/with-outFile.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/with-outFile.js @@ -56,7 +56,6 @@ interface Array { length: number; [n: number]: T; } // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified-with-declaration-enabled.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified-with-declaration-enabled.js index a80a8e8c3c89e..c87baf238012c 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified-with-declaration-enabled.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified-with-declaration-enabled.js @@ -56,7 +56,6 @@ interface Array { length: number; [n: number]: T; } // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified.js b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified.js index b1b8e8a3eaedf..82310b617cd3d 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified.js @@ -56,7 +56,6 @@ interface Array { length: number; [n: number]: T; } // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ From 86dd5da43dd6da046a97bffa16faf0babaad4499 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 20 Oct 2022 10:04:25 -0700 Subject: [PATCH 18/41] Add options --- src/compiler/commandLineParser.ts | 33 +++++++++++++----- src/compiler/diagnosticMessages.json | 16 +++++++-- src/compiler/moduleNameResolver.ts | 51 +++++++++++++++++++++++----- src/compiler/types.ts | 5 +++ src/compiler/utilities.ts | 26 ++++++++++++++ 5 files changed, 113 insertions(+), 18 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 240c6ec346ff4..88ae140de05cc 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -841,6 +841,7 @@ namespace ts { classic: ModuleResolutionKind.Classic, node16: ModuleResolutionKind.Node16, nodenext: ModuleResolutionKind.NodeNext, + hybrid: ModuleResolutionKind.Hybrid, })), affectsModuleResolution: true, paramType: Diagnostics.STRATEGY, @@ -957,14 +958,30 @@ namespace ts { category: Diagnostics.Modules, description: Diagnostics.List_of_file_name_suffixes_to_search_when_resolving_a_module, }, - // { - // name: "allowImportingTsExtensions", - // type: "boolean", - // affectsModuleResolution: true, - // category: Diagnostics.Modules, - // description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_minimal_and_either_noEmit_or_emitDeclarationOnly_to_be_set, - // defaultValueDescription: false, - // }, + { + name: "allowImportingTsExtensions", + type: "boolean", + affectsModuleResolution: true, + category: Diagnostics.Modules, + description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_hybrid_and_either_noEmit_or_emitDeclarationOnly_to_be_set, + defaultValueDescription: false, + }, + { + name: "resolvePackageJsonExports", + type: "boolean", + affectsModuleResolution: true, + category: Diagnostics.Modules, + description: Diagnostics.Use_the_package_json_exports_field_when_resolving_package_imports, + defaultValueDescription: Diagnostics.true_when_moduleResolution_is_node16_nodenext_or_hybrid_otherwise_false, + }, + { + name: "resolvePackageJsonImports", + type: "boolean", + affectsModuleResolution: true, + category: Diagnostics.Modules, + description: Diagnostics.Use_the_package_json_imports_field_when_resolving_imports, + defaultValueDescription: Diagnostics.true_when_moduleResolution_is_node16_nodenext_or_hybrid_otherwise_false, + }, // Source Maps { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 077f66b163950..82b15b75f8bb6 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4225,7 +4225,7 @@ "category": "Error", "code": 5095 }, - "Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'minimal' and either 'noEmit' or 'emitDeclarationOnly' is set.": { + "Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'hybrid' and either 'noEmit' or 'emitDeclarationOnly' is set.": { "category": "Error", "code": 5096 }, @@ -5438,10 +5438,22 @@ "category": "Message", "code": 6406 }, - "Allow imports to include TypeScript file extensions. Requires '--moduleResolution minimal' and either '--noEmit' or '--emitDeclarationOnly' to be set.": { + "Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set.": { "category": "Message", "code": 6407 }, + "Use the package.json 'exports' field when resolving package imports.": { + "category": "Message", + "code": 6408 + }, + "Use the package.json 'imports' field when resolving imports.": { + "category": "Message", + "code": 6409 + }, + "`true` when 'moduleResolution' is 'node16', 'nodenext', or 'hybrid'; otherwise `false`.": { + "category": "Message", + "code": 6410 + }, "The expected type comes from property '{0}' which is declared here on type '{1}'": { "category": "Message", diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 36f6125455d6c..31b57152be587 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -365,7 +365,7 @@ namespace ts { const failedLookupLocations: string[] = []; const affectingLocations: string[] = []; - let features = getDefaultNodeResolutionFeatures(options); + let features = getNodeResolutionFeatures(options); // Unlike `import` statements, whose mode-calculating APIs are all guaranteed to return `undefined` if we're in an un-mode-ed module resolution // setting, type references will return their target mode regardless of options because of how the parser works, so we guard against the mode being // set in a non-modal module resolution setting here. Do note that our behavior is not particularly well defined when these mode-overriding imports @@ -480,10 +480,36 @@ namespace ts { } } - function getDefaultNodeResolutionFeatures(options: CompilerOptions) { - return getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node16 ? NodeResolutionFeatures.Node16Default : - getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeNext ? NodeResolutionFeatures.NodeNextDefault : - NodeResolutionFeatures.None; + function getNodeResolutionFeatures(options: CompilerOptions) { + let features = NodeResolutionFeatures.None; + switch (getEmitModuleResolutionKind(options)) { + case ModuleResolutionKind.Node16: + features = NodeResolutionFeatures.Node16Default; + break; + case ModuleResolutionKind.NodeNext: + features = NodeResolutionFeatures.NodeNextDefault; + break; + case ModuleResolutionKind.Hybrid: + features = NodeResolutionFeatures.HybridDefault; + break; + } + if (options.resolvePackageJsonExports) { + features |= NodeResolutionFeatures.Exports; + } + else if (options.resolvePackageJsonExports === false) { + features &= ~NodeResolutionFeatures.Exports; + } + if (options.resolvePackageJsonImports) { + features |= NodeResolutionFeatures.Imports; + } + else if (options.resolvePackageJsonImports === false) { + features &= ~NodeResolutionFeatures.Imports; + } + return features; + } + + function getConditions(options: CompilerOptions, esmMode: boolean | undefined) { + const conditions = esmMode ? ["node", "import", "types"] : ["node", "require", "types"]; } /** @@ -1038,6 +1064,9 @@ namespace ts { case ModuleResolutionKind.Classic: result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; + case ModuleResolutionKind.Hybrid: + result = hybridModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); + break; default: return Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`); } @@ -1293,6 +1322,8 @@ namespace ts { NodeNextDefault = AllFeatures, + HybridDefault = Imports | SelfName | Exports | ExportsPatternTrailers, + EsmMode = 1 << 5, } @@ -1346,6 +1377,10 @@ namespace ts { return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, initialDir, { moduleResolution: ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, jsOnlyExtensions, /*redirectedReferences*/ undefined); } + export function hybridModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations { + + } + export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; /* @internal */ export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, lookupConfig?: boolean): ResolvedModuleWithFailedLookupLocations; // eslint-disable-line @typescript-eslint/unified-signatures export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, lookupConfig?: boolean): ResolvedModuleWithFailedLookupLocations { @@ -1732,7 +1767,7 @@ namespace ts { let entrypoints: string[] | undefined; const extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript; - const features = getDefaultNodeResolutionFeatures(options); + const features = getNodeResolutionFeatures(options); const requireState = getTemporaryModuleResolutionState(cache?.getPackageJsonInfoCache(), host, options); requireState.conditions = ["node", "require", "types"]; requireState.requestContainingDirectory = packageJsonInfo.packageDirectory; @@ -2691,8 +2726,8 @@ namespace ts { } } - export function moduleResolutionSupportsResolvingTsExtensions(_compilerOptions: CompilerOptions) { - return false; + export function moduleResolutionSupportsResolvingTsExtensions(compilerOptions: CompilerOptions) { + return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Hybrid; } // Program errors validate that `noEmit` or `emitDeclarationOnly` is also set, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5d98a5ca76c47..b7ebf46c4c5e1 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -6494,6 +6494,8 @@ namespace ts { // In turn, we offer both a `NodeNext` moving resolution target, and a `Node16` version-anchored resolution target Node16 = 3, NodeNext = 99, // Not simply `Node16` so that compiled code linked against TS can use the `Next` value reliably (same as with `ModuleKind`) + + Hybrid = 100, } export enum ModuleDetectionKind { @@ -6570,6 +6572,7 @@ namespace ts { /* @internal */ configFilePath?: string; /** configFile is set as non enumerable property so as to avoid checking of json source files */ /* @internal */ readonly configFile?: TsConfigSourceFile; + customConditions?: string[]; declaration?: boolean; declarationMap?: boolean; emitDeclarationOnly?: boolean; @@ -6652,6 +6655,8 @@ namespace ts { incremental?: boolean; tsBuildInfoFile?: string; removeComments?: boolean; + resolvePackageJsonExports?: boolean; + resolvePackageJsonImports?: boolean; rootDir?: string; rootDirs?: string[]; skipLibCheck?: boolean; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 3641fef177d47..5dcfe061bcc59 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -6448,6 +6448,32 @@ namespace ts { moduleKind === ModuleKind.System; } + export function getResolvePackageJsonExports(compilerOptions: CompilerOptions) { + if (compilerOptions.resolvePackageJsonExports !== undefined) { + return compilerOptions.resolvePackageJsonExports; + } + switch (getEmitModuleResolutionKind(compilerOptions)) { + case ModuleResolutionKind.Node16: + case ModuleResolutionKind.NodeNext: + case ModuleResolutionKind.Hybrid: + return true; + } + return false; + } + + export function getResolvePackageJsonImports(compilerOptions: CompilerOptions) { + if (compilerOptions.resolvePackageJsonImports !== undefined) { + return compilerOptions.resolvePackageJsonImports; + } + switch (getEmitModuleResolutionKind(compilerOptions)) { + case ModuleResolutionKind.Node16: + case ModuleResolutionKind.NodeNext: + case ModuleResolutionKind.Hybrid: + return true; + } + return false; + } + export function getEmitDeclarations(compilerOptions: CompilerOptions): boolean { return !!(compilerOptions.declaration || compilerOptions.composite); } From 8846f31a2b7686cbe8f13e3a148d33f263fd9cb5 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 21 Oct 2022 15:16:44 -0700 Subject: [PATCH 19/41] Add customConditions option --- src/compiler/checker.ts | 2 +- src/compiler/commandLineParser.ts | 11 ++++++++++ src/compiler/diagnosticMessages.json | 10 +++++++++- src/compiler/moduleNameResolver.ts | 30 +++++++++++++++++----------- src/compiler/program.ts | 17 +++++++++++++--- src/compiler/utilities.ts | 30 +++++++++++++++++++++++----- src/services/completions.ts | 2 +- src/services/stringCompletions.ts | 2 +- src/services/utilities.ts | 4 ---- 9 files changed, 80 insertions(+), 28 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dc4ecdbab9c15..cee39c59e572e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3808,7 +3808,7 @@ namespace ts { if (tsExtension) { errorOnTSExtensionImport(tsExtension); } - else if (!compilerOptions.resolveJsonModule && + else if (!getResolveJsonModule(compilerOptions) && fileExtensionIs(moduleReference, Extension.Json) && moduleResolutionKind !== ModuleResolutionKind.Classic && hasJsonModuleEmitEnabled(compilerOptions)) { diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 88ae140de05cc..d360e005aa5fc 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -982,6 +982,17 @@ namespace ts { description: Diagnostics.Use_the_package_json_imports_field_when_resolving_imports, defaultValueDescription: Diagnostics.true_when_moduleResolution_is_node16_nodenext_or_hybrid_otherwise_false, }, + { + name: "customConditions", + type: "list", + element: { + name: "condition", + type: "string", + }, + affectsModuleResolution: true, + category: Diagnostics.Modules, + description: Diagnostics.Conditions_to_set_in_addition_to_the_resolver_specific_defaults_when_resolving_imports, + }, // Source Maps { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 82b15b75f8bb6..4e66f092b3699 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4233,6 +4233,10 @@ "category": "Error", "code": 5097 }, + "Option '{0}' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'.": { + "category": "Error", + "code": 5098 + }, "Generates a sourcemap for each corresponding '.d.ts' file.": { "category": "Message", @@ -5450,10 +5454,14 @@ "category": "Message", "code": 6409 }, - "`true` when 'moduleResolution' is 'node16', 'nodenext', or 'hybrid'; otherwise `false`.": { + "Conditions to set in addition to the resolver-specific defaults when resolving imports.": { "category": "Message", "code": 6410 }, + "`true` when 'moduleResolution' is 'node16', 'nodenext', or 'hybrid'; otherwise `false`.": { + "category": "Message", + "code": 6411 + }, "The expected type comes from property '{0}' which is declared here on type '{1}'": { "category": "Message", diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 31b57152be587..d0089b5500f07 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -509,7 +509,13 @@ namespace ts { } function getConditions(options: CompilerOptions, esmMode: boolean | undefined) { - const conditions = esmMode ? ["node", "import", "types"] : ["node", "require", "types"]; + // conditions are only used by the node16/nodenext/hybrid resolvers - there's no priority order in the list, + // it's essentially a set (priority is determined by object insertion order in the object we look at). + const conditions = esmMode ? ["node", "import"] : ["node", "require"]; + if (!options.noDtsResolution) { + conditions.push("types"); + } + return concatenate(conditions, options.customConditions); } /** @@ -1367,7 +1373,7 @@ namespace ts { // es module file or cjs-like input file, use a variant of the legacy cjs resolver that supports the selected modern features const esmMode = resolutionMode === ModuleKind.ESNext ? NodeResolutionFeatures.EsmMode : 0; let extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions; - if (compilerOptions.resolveJsonModule) { + if (getResolveJsonModule(compilerOptions)) { extensions = [...extensions, Extensions.Json]; } return nodeModuleNameResolverWorker(features | esmMode, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference); @@ -1378,7 +1384,12 @@ namespace ts { } export function hybridModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations { - + const containingDirectory = getDirectoryPath(containingFile); + let extensions = compilerOptions.noDtsResolution ? [Extensions.TsOnly, Extensions.JavaScript] : tsExtensions; + if (getResolveJsonModule(compilerOptions)) { + extensions = [...extensions, Extensions.Json]; + } + return nodeModuleNameResolverWorker(NodeResolutionFeatures.HybridDefault, moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference); } export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; @@ -1391,10 +1402,10 @@ namespace ts { else if (compilerOptions.noDtsResolution) { extensions = [Extensions.TsOnly]; if (compilerOptions.allowJs) extensions.push(Extensions.JavaScript); - if (compilerOptions.resolveJsonModule) extensions.push(Extensions.Json); + if (getResolveJsonModule(compilerOptions)) extensions.push(Extensions.Json); } else { - extensions = compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions; + extensions = getResolveJsonModule(compilerOptions) ? tsPlusJsonExtensions : tsExtensions; } return nodeModuleNameResolverWorker(NodeResolutionFeatures.None, moduleName, getDirectoryPath(containingFile), compilerOptions, host, cache, extensions, redirectedReference); } @@ -1404,12 +1415,7 @@ namespace ts { const failedLookupLocations: string[] = []; const affectingLocations: string[] = []; - // conditions are only used by the node16/nodenext resolver - there's no priority order in the list, - //it's essentially a set (priority is determined by object insertion order in the object we look at). - const conditions = features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"]; - if (compilerOptions.noDtsResolution) { - conditions.pop(); - } + const conditions = getConditions(compilerOptions, !!(features & NodeResolutionFeatures.EsmMode)); const diagnostics: Diagnostic[] = []; const state: ModuleResolutionState = { @@ -1617,7 +1623,7 @@ namespace ts { // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" if (hasJSFileExtension(candidate) || - (state.compilerOptions.resolveJsonModule && fileExtensionIs(candidate, Extension.Json)) || + (getResolveJsonModule(state.compilerOptions) && fileExtensionIs(candidate, Extension.Json)) || (moduleResolutionSupportsResolvingTsExtensions(state.compilerOptions) && fileExtensionIsOneOf(candidate, supportedTSExtensionsFlat)) ) { const extensionless = removeFileExtension(candidate); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index e92a130ec19a9..43dfbe80695ce 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -3602,7 +3602,7 @@ namespace ts { } } - if (options.resolveJsonModule) { + if (getResolveJsonModule(options)) { if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeNext) { @@ -3697,7 +3697,18 @@ namespace ts { } if (options.allowImportingTsExtensions && !(moduleResolutionSupportsResolvingTsExtensions(options) && (options.noEmit || options.emitDeclarationOnly))) { - createOptionValueDiagnostic("allowImportingTsExtensions", Diagnostics.Option_allowImportingTsExtensions_can_only_be_used_when_moduleResolution_is_set_to_minimal_and_either_noEmit_or_emitDeclarationOnly_is_set); + createOptionValueDiagnostic("allowImportingTsExtensions", Diagnostics.Option_allowImportingTsExtensions_can_only_be_used_when_moduleResolution_is_set_to_hybrid_and_either_noEmit_or_emitDeclarationOnly_is_set); + } + + const moduleResolution = getEmitModuleResolutionKind(options); + if (options.resolvePackageJsonExports && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) { + createOptionValueDiagnostic("resolvePackageJsonExports", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_hybrid, "resolvePackageJsonExports"); + } + if (options.resolvePackageJsonImports && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) { + createOptionValueDiagnostic("resolvePackageJsonImports", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_hybrid, "resolvePackageJsonExports"); + } + if (options.customConditions && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) { + createOptionValueDiagnostic("customConditions", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_hybrid, "customConditions"); } // If the emit is enabled make sure that every output file is unique and not overwriting any of the input files @@ -4394,7 +4405,7 @@ namespace ts { return getAllowJSCompilerOption(options) || !getStrictOptionValue(options, "noImplicitAny") ? undefined : Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type; } function needResolveJsonModule() { - return options.resolveJsonModule ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used; + return getResolveJsonModule(options) ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used; } } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 5dcfe061bcc59..82ba813f0b92c 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -6448,11 +6448,20 @@ namespace ts { moduleKind === ModuleKind.System; } + export function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution: ModuleResolutionKind): boolean { + return moduleResolution >= ModuleResolutionKind.Node16 && moduleResolution <= ModuleResolutionKind.NodeNext + || moduleResolution === ModuleResolutionKind.Hybrid; + } + export function getResolvePackageJsonExports(compilerOptions: CompilerOptions) { + const moduleResolution = getEmitModuleResolutionKind(compilerOptions); + if (!moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) { + return false; + } if (compilerOptions.resolvePackageJsonExports !== undefined) { return compilerOptions.resolvePackageJsonExports; } - switch (getEmitModuleResolutionKind(compilerOptions)) { + switch (moduleResolution) { case ModuleResolutionKind.Node16: case ModuleResolutionKind.NodeNext: case ModuleResolutionKind.Hybrid: @@ -6462,10 +6471,14 @@ namespace ts { } export function getResolvePackageJsonImports(compilerOptions: CompilerOptions) { - if (compilerOptions.resolvePackageJsonImports !== undefined) { - return compilerOptions.resolvePackageJsonImports; + const moduleResolution = getEmitModuleResolutionKind(compilerOptions); + if (!moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) { + return false; } - switch (getEmitModuleResolutionKind(compilerOptions)) { + if (compilerOptions.resolvePackageJsonExports !== undefined) { + return compilerOptions.resolvePackageJsonExports; + } + switch (moduleResolution) { case ModuleResolutionKind.Node16: case ModuleResolutionKind.NodeNext: case ModuleResolutionKind.Hybrid: @@ -6474,6 +6487,13 @@ namespace ts { return false; } + export function getResolveJsonModule(compilerOptions: CompilerOptions) { + if (compilerOptions.resolveJsonModule !== undefined) { + return compilerOptions.resolveJsonModule; + } + return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Hybrid; + } + export function getEmitDeclarations(compilerOptions: CompilerOptions): boolean { return !!(compilerOptions.declaration || compilerOptions.composite); } @@ -7055,7 +7075,7 @@ namespace ts { export function getSupportedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly Extension[][]): readonly Extension[][]; export function getSupportedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[][]): readonly string[][]; export function getSupportedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[][]): readonly string[][] { - if (!options || !options.resolveJsonModule) return supportedExtensions; + if (!options || !getResolveJsonModule(options)) return supportedExtensions; if (supportedExtensions === allSupportedExtensions) return allSupportedExtensionsWithJson; if (supportedExtensions === supportedTSExtensions) return supportedTSExtensionsWithJson; return [...supportedExtensions, [Extension.Json]]; diff --git a/src/services/completions.ts b/src/services/completions.ts index 0462274d18dd6..639acdfabaf7b 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -198,7 +198,7 @@ namespace ts.Completions { // relative path into node_modules), and we want to filter those completions out entirely. // Import statement completions always need specifier resolution because the module specifier is // part of their `insertText`, not the `codeActions` creating edits away from the cursor. - const needsFullResolution = isForImportStatementCompletion || moduleResolutionRespectsExports(getEmitModuleResolutionKind(program.getCompilerOptions())); + const needsFullResolution = isForImportStatementCompletion || moduleResolutionSupportsPackageJsonExportsAndImports(getEmitModuleResolutionKind(program.getCompilerOptions())); let skippedAny = false; let ambientCount = 0; let resolvedCount = 0; diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index 8a07910bb3ebf..a9ff0027db686 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -674,7 +674,7 @@ namespace ts.Completions.StringCompletions { getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*moduleSpecifierIsRelative*/ false, /*exclude*/ undefined, result); } }; - if (fragmentDirectory && moduleResolutionRespectsExports(moduleResolution)) { + if (fragmentDirectory && getResolvePackageJsonExports(compilerOptions)) { const nodeModulesDirectoryLookup = ancestorLookup; ancestorLookup = ancestor => { const components = getPathComponents(fragment); diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 9943d04307fb5..a71764120e724 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1943,10 +1943,6 @@ namespace ts { }; } - export function moduleResolutionRespectsExports(moduleResolution: ModuleResolutionKind): boolean { - return moduleResolution >= ModuleResolutionKind.Node16 && moduleResolution <= ModuleResolutionKind.NodeNext; - } - export function moduleResolutionUsesNodeModules(moduleResolution: ModuleResolutionKind): boolean { return moduleResolution === ModuleResolutionKind.NodeJs || moduleResolution >= ModuleResolutionKind.Node16 && moduleResolution <= ModuleResolutionKind.NodeNext; } From 9bc0f07fd2585253d04531ed81f5b1d0991cce08 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 24 Oct 2022 15:06:02 -0700 Subject: [PATCH 20/41] Add first tests --- src/compiler/moduleNameResolver.ts | 32 +++++--- src/compiler/utilities.ts | 11 +-- .../reference/hybridRelative1.errors.txt | 41 ++++++++++ tests/baselines/reference/hybridRelative1.js | 47 +++++++++++ .../reference/hybridRelative1.symbols | 47 +++++++++++ .../reference/hybridRelative1.trace.json | 80 +++++++++++++++++++ .../baselines/reference/hybridRelative1.types | 49 ++++++++++++ .../hybrid/hybridRelative1.ts | 33 ++++++++ 8 files changed, 322 insertions(+), 18 deletions(-) create mode 100644 tests/baselines/reference/hybridRelative1.errors.txt create mode 100644 tests/baselines/reference/hybridRelative1.js create mode 100644 tests/baselines/reference/hybridRelative1.symbols create mode 100644 tests/baselines/reference/hybridRelative1.trace.json create mode 100644 tests/baselines/reference/hybridRelative1.types create mode 100644 tests/cases/conformance/moduleResolution/hybrid/hybridRelative1.ts diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index d0089b5500f07..ac8f7c240873c 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -376,7 +376,7 @@ namespace ts { if (resolutionMode === ModuleKind.ESNext && (getEmitModuleResolutionKind(options) === ModuleResolutionKind.Node16 || getEmitModuleResolutionKind(options) === ModuleResolutionKind.NodeNext)) { features |= NodeResolutionFeatures.EsmMode; } - const conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : []; + const conditions = features & NodeResolutionFeatures.Exports ? getConditions(options, !!(features & NodeResolutionFeatures.EsmMode)) : []; const diagnostics: Diagnostic[] = []; const moduleResolutionState: ModuleResolutionState = { compilerOptions: options, @@ -508,10 +508,12 @@ namespace ts { return features; } - function getConditions(options: CompilerOptions, esmMode: boolean | undefined) { + function getConditions(options: CompilerOptions, esmMode?: boolean) { // conditions are only used by the node16/nodenext/hybrid resolvers - there's no priority order in the list, // it's essentially a set (priority is determined by object insertion order in the object we look at). - const conditions = esmMode ? ["node", "import"] : ["node", "require"]; + const conditions = esmMode || getEmitModuleResolutionKind(options) === ModuleResolutionKind.Hybrid + ? ["node", "import"] + : ["node", "require"]; if (!options.noDtsResolution) { conditions.push("types"); } @@ -1546,7 +1548,7 @@ namespace ts { } } // esm mode relative imports shouldn't do any directory lookups (either inside `package.json` - // files or implicit `index.js`es). This is a notable depature from cjs norms, where `./foo/pkg` + // files or implicit `index.js`es). This is a notable departure from cjs norms, where `./foo/pkg` // could have been redirected by `./foo/pkg/package.json` to an arbitrary location! if (!(state.features & NodeResolutionFeatures.EsmMode)) { return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson); @@ -1774,25 +1776,29 @@ namespace ts { let entrypoints: string[] | undefined; const extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript; const features = getNodeResolutionFeatures(options); - const requireState = getTemporaryModuleResolutionState(cache?.getPackageJsonInfoCache(), host, options); - requireState.conditions = ["node", "require", "types"]; - requireState.requestContainingDirectory = packageJsonInfo.packageDirectory; - const requireResolution = loadNodeModuleFromDirectoryWorker( + const loadPackageJsonMainState = getTemporaryModuleResolutionState(cache?.getPackageJsonInfoCache(), host, options); + loadPackageJsonMainState.conditions = getConditions(options); + loadPackageJsonMainState.requestContainingDirectory = packageJsonInfo.packageDirectory; + const mainResolution = loadNodeModuleFromDirectoryWorker( extensions, packageJsonInfo.packageDirectory, /*onlyRecordFailures*/ false, - requireState, + loadPackageJsonMainState, packageJsonInfo.contents.packageJsonContent, packageJsonInfo.contents.versionPaths); - entrypoints = append(entrypoints, requireResolution?.path); + entrypoints = append(entrypoints, mainResolution?.path); if (features & NodeResolutionFeatures.Exports && packageJsonInfo.contents.packageJsonContent.exports) { - for (const conditions of [["node", "import", "types"], ["node", "require", "types"]]) { - const exportState = { ...requireState, failedLookupLocations: [], conditions }; + const conditionSets = deduplicate( + [getConditions(options, /*esmMode*/ true), getConditions(options, /*esmMode*/ false)], + arrayIsEqualTo + ); + for (const conditions of conditionSets) { + const loadPackageJsonExportsState = { ...loadPackageJsonMainState, failedLookupLocations: [], conditions }; const exportResolutions = loadEntrypointsFromExportMap( packageJsonInfo, packageJsonInfo.contents.packageJsonContent.exports, - exportState, + loadPackageJsonExportsState, extensions); if (exportResolutions) { for (const resolution of exportResolutions) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 82ba813f0b92c..592b9790a2306 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -6441,11 +6441,12 @@ namespace ts { } export function getAllowSyntheticDefaultImports(compilerOptions: CompilerOptions) { - const moduleKind = getEmitModuleKind(compilerOptions); - return compilerOptions.allowSyntheticDefaultImports !== undefined - ? compilerOptions.allowSyntheticDefaultImports - : getESModuleInterop(compilerOptions) || - moduleKind === ModuleKind.System; + if (compilerOptions.allowSyntheticDefaultImports !== undefined) { + return compilerOptions.allowSyntheticDefaultImports; + } + return getESModuleInterop(compilerOptions) + || getEmitModuleKind(compilerOptions) === ModuleKind.System + || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Hybrid; } export function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution: ModuleResolutionKind): boolean { diff --git a/tests/baselines/reference/hybridRelative1.errors.txt b/tests/baselines/reference/hybridRelative1.errors.txt new file mode 100644 index 0000000000000..2381787fbc254 --- /dev/null +++ b/tests/baselines/reference/hybridRelative1.errors.txt @@ -0,0 +1,41 @@ +error TS5070: Option '--resolveJsonModule' cannot be specified without 'node' module resolution strategy. +/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. + + +!!! error TS5070: Option '--resolveJsonModule' cannot be specified without 'node' module resolution strategy. +==== /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/hybridRelative1.js b/tests/baselines/reference/hybridRelative1.js new file mode 100644 index 0000000000000..3c009b0588bcd --- /dev/null +++ b/tests/baselines/reference/hybridRelative1.js @@ -0,0 +1,47 @@ +//// [tests/cases/conformance/moduleResolution/hybrid/hybridRelative1.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] +"use strict"; +exports.__esModule = true; +exports.x = void 0; +exports.x = 0; +//// [index.js] +"use strict"; +exports.__esModule = true; +exports.y = void 0; +exports.y = 0; +//// [main.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/hybridRelative1.symbols b/tests/baselines/reference/hybridRelative1.symbols new file mode 100644 index 0000000000000..4bbdf732a77c6 --- /dev/null +++ b/tests/baselines/reference/hybridRelative1.symbols @@ -0,0 +1,47 @@ +=== /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/hybridRelative1.trace.json b/tests/baselines/reference/hybridRelative1.trace.json new file mode 100644 index 0000000000000..75cb1a973184e --- /dev/null +++ b/tests/baselines/reference/hybridRelative1.trace.json @@ -0,0 +1,80 @@ +[ + "======== Resolving module './dir' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/dir', target file type 'TypeScript'.", + "File '/dir.ts' does not exist.", + "File '/dir.tsx' does not exist.", + "File '/dir.d.ts' does not exist.", + "File '/dir/package.json' does not exist.", + "File '/dir/index.ts' exist - 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: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/dir/index', target file type 'TypeScript'.", + "File '/dir/index.ts' exist - 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: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/dir/index.js', target file type 'TypeScript'.", + "File '/dir/index.js.ts' does not exist.", + "File '/dir/index.js.tsx' does not exist.", + "File '/dir/index.js.d.ts' does not exist.", + "File name '/dir/index.js' has a '.js' extension - stripping it.", + "File '/dir/index.ts' exist - 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: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/dir/index.ts', target file type 'TypeScript'.", + "File '/dir/index.ts.ts' does not exist.", + "File '/dir/index.ts.tsx' does not exist.", + "File '/dir/index.ts.d.ts' does not exist.", + "File name '/dir/index.ts' has a '.ts' extension - stripping it.", + "File '/dir/index.ts' exist - 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: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/redirect', target file type 'TypeScript'.", + "File '/redirect.ts' does not exist.", + "File '/redirect.tsx' does not exist.", + "File '/redirect.d.ts' 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 type 'TypeScript'.", + "File '/foo.ts' does not exist.", + "File '/foo.tsx' does not exist.", + "File '/foo.d.ts' does not exist.", + "File '/foo/index.ts' exist - 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: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/redirect/index', target file type 'TypeScript'.", + "File '/redirect/index.ts' does not exist.", + "File '/redirect/index.tsx' does not exist.", + "File '/redirect/index.d.ts' does not exist.", + "Directory '/redirect/index' does not exist, skipping all lookups in it.", + "Loading module as file / folder, candidate module location '/redirect/index', target file type 'JavaScript'.", + "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.", + "Loading module as file / folder, candidate module location '/redirect/index', target file type 'Json'.", + "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: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/types/esm', target file type 'TypeScript'.", + "File '/types/esm.ts' does not exist.", + "File '/types/esm.tsx' does not exist.", + "File '/types/esm.d.ts' exist - 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: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/types/cjs', target file type 'TypeScript'.", + "File '/types/cjs.ts' does not exist.", + "File '/types/cjs.tsx' does not exist.", + "File '/types/cjs.d.ts' exist - use it as a name resolution result.", + "======== Module name './types/cjs' was successfully resolved to '/types/cjs.d.ts'. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/hybridRelative1.types b/tests/baselines/reference/hybridRelative1.types new file mode 100644 index 0000000000000..7e1e3e5e865c7 --- /dev/null +++ b/tests/baselines/reference/hybridRelative1.types @@ -0,0 +1,49 @@ +=== /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/cases/conformance/moduleResolution/hybrid/hybridRelative1.ts b/tests/cases/conformance/moduleResolution/hybrid/hybridRelative1.ts new file mode 100644 index 0000000000000..b560bf5462709 --- /dev/null +++ b/tests/cases/conformance/moduleResolution/hybrid/hybridRelative1.ts @@ -0,0 +1,33 @@ +// @moduleResolution: hybrid +// @traceResolution: true + +// @Filename: /dir/index.ts +export const x = 0; + +// @Filename: /redirect/package.json +{ "main": "../foo" } + +// @Filename: /foo/index.ts +export const y = 0; + +// @Filename: /types/esm.d.ts +declare const _: string; +export default _; + +// @Filename: /types/cjs.d.ts +declare const _: string; +export = _; + +// @Filename: /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"; From 4545afbe8f932b29e33cf0eb4bb714335b410e96 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 24 Oct 2022 16:17:20 -0700 Subject: [PATCH 21/41] CJS constructs are not allowed --- src/compiler/checker.ts | 6 +++ src/compiler/diagnosticMessages.json | 8 ++++ src/compiler/program.ts | 3 +- .../hybridSyntaxRestrictions.errors.txt | 24 ++++++++++++ .../reference/hybridSyntaxRestrictions.js | 25 ++++++++++++ .../hybridSyntaxRestrictions.symbols | 17 +++++++++ .../reference/hybridSyntaxRestrictions.types | 19 ++++++++++ .../hybrid/hybridNodeModules1.ts | 38 +++++++++++++++++++ .../hybrid/hybridSyntaxRestrictions.ts | 20 ++++++++++ 9 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/hybridSyntaxRestrictions.errors.txt create mode 100644 tests/baselines/reference/hybridSyntaxRestrictions.js create mode 100644 tests/baselines/reference/hybridSyntaxRestrictions.symbols create mode 100644 tests/baselines/reference/hybridSyntaxRestrictions.types create mode 100644 tests/cases/conformance/moduleResolution/hybrid/hybridNodeModules1.ts create mode 100644 tests/cases/conformance/moduleResolution/hybrid/hybridSyntaxRestrictions.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cee39c59e572e..5733785412542 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -41733,6 +41733,9 @@ namespace ts { // 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); } + else if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Hybrid) { + grammarErrorOnNode(node, Diagnostics.Import_assignment_is_not_allowed_when_moduleResolution_is_set_to_hybrid_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); + } } } } @@ -41955,6 +41958,9 @@ namespace ts { // system modules does not support export assignment grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } + else if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Hybrid) { + grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_moduleResolution_is_set_to_hybrid_Consider_using_export_default_or_another_module_format_instead); + } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4e66f092b3699..082433b1b094b 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4237,6 +4237,14 @@ "category": "Error", "code": 5098 }, + "Import assignment is not allowed when 'moduleResolution' is set to 'hybrid'. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead.": { + "category": "Error", + "code": 5099 + }, + "Export assignment cannot be used when 'moduleResolution' is set to 'hybrid'. Consider using 'export default' or another module format instead.": { + "category": "Error", + "code": 5100 + }, "Generates a sourcemap for each corresponding '.d.ts' file.": { "category": "Message", diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 43dfbe80695ce..e25dcc2708ee2 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -3605,7 +3605,8 @@ namespace ts { if (getResolveJsonModule(options)) { if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Node16 && - getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeNext) { + getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeNext && + getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Hybrid) { createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); } // Any emit other than common js, amd, es2015 or esnext is error diff --git a/tests/baselines/reference/hybridSyntaxRestrictions.errors.txt b/tests/baselines/reference/hybridSyntaxRestrictions.errors.txt new file mode 100644 index 0000000000000..0a3970e0fc647 --- /dev/null +++ b/tests/baselines/reference/hybridSyntaxRestrictions.errors.txt @@ -0,0 +1,24 @@ +/main.ts(2,1): error TS5099: Import assignment is not allowed when 'moduleResolution' is set to 'hybrid'. 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 TS5100: Export assignment cannot be used when 'moduleResolution' is set to 'hybrid'. Consider using 'export default' or another module format instead. + + +==== /main.ts (2 errors) ==== + import {} from "./a"; + import _ = require("./a"); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS5099: Import assignment is not allowed when 'moduleResolution' is set to 'hybrid'. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. + export = {}; // Error + ~~~~~~~~~~~~ +!!! error TS5100: Export assignment cannot be used when 'moduleResolution' is set to 'hybrid'. Consider using 'export default' or another module format instead. + export {}; + +==== /node_modules/@types/node/index.d.ts (0 errors) ==== + declare var require: (...args: any[]) => any; + +==== /a.ts (0 errors) ==== + export {}; + +==== /mainJs.js (0 errors) ==== + import {} from "./a"; + const _ = require("./a"); // No resolution + \ No newline at end of file diff --git a/tests/baselines/reference/hybridSyntaxRestrictions.js b/tests/baselines/reference/hybridSyntaxRestrictions.js new file mode 100644 index 0000000000000..7776065ee35f2 --- /dev/null +++ b/tests/baselines/reference/hybridSyntaxRestrictions.js @@ -0,0 +1,25 @@ +//// [tests/cases/conformance/moduleResolution/hybrid/hybridSyntaxRestrictions.ts] //// + +//// [index.d.ts] +declare var require: (...args: any[]) => any; + +//// [a.ts] +export {}; + +//// [mainJs.js] +import {} from "./a"; +const _ = require("./a"); // No resolution + +//// [main.ts] +import {} from "./a"; +import _ = require("./a"); // Error +export = {}; // Error +export {}; + + +//// [a.js] +"use strict"; +exports.__esModule = true; +//// [main.js] +"use strict"; +module.exports = {}; diff --git a/tests/baselines/reference/hybridSyntaxRestrictions.symbols b/tests/baselines/reference/hybridSyntaxRestrictions.symbols new file mode 100644 index 0000000000000..d92eb6ffe04b4 --- /dev/null +++ b/tests/baselines/reference/hybridSyntaxRestrictions.symbols @@ -0,0 +1,17 @@ +=== /main.ts === +import {} from "./a"; +import _ = require("./a"); // Error +>_ : Symbol(_, Decl(main.ts, 0, 21)) + +export = {}; // Error +export {}; + +=== /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)) + +=== /a.ts === +export {}; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/hybridSyntaxRestrictions.types b/tests/baselines/reference/hybridSyntaxRestrictions.types new file mode 100644 index 0000000000000..16066a8493dcc --- /dev/null +++ b/tests/baselines/reference/hybridSyntaxRestrictions.types @@ -0,0 +1,19 @@ +=== /main.ts === +import {} from "./a"; +import _ = require("./a"); // Error +>_ : typeof _ + +export = {}; // Error +>{} : {} + +export {}; + +=== /node_modules/@types/node/index.d.ts === +declare var require: (...args: any[]) => any; +>require : (...args: any[]) => any +>args : any[] + +=== /a.ts === +export {}; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/cases/conformance/moduleResolution/hybrid/hybridNodeModules1.ts b/tests/cases/conformance/moduleResolution/hybrid/hybridNodeModules1.ts new file mode 100644 index 0000000000000..c1f35a255db6c --- /dev/null +++ b/tests/cases/conformance/moduleResolution/hybrid/hybridNodeModules1.ts @@ -0,0 +1,38 @@ +// @moduleResolution: hybrid +// @traceResolution: true + +// @Filename: /node_modules/dual/package.json +{ + "name": "dual", + "version": "1.0.0", + "type": "module", + "main": "index.cjs", + "types": "index.d.cts", + "exports": { + ".": { + "import": "./index.js", + "require": "./index.cjs" + } + } +} + +// @Filename: /node_modules/dual/index.js +export const esm = 0; + +// @Filename: /node_modules/dual/index.d.ts +export const esm: number; + +// @Filename: /node_modules/dual/index.cjs +exports.cjs = 0; + +// @Filename: /node_modules/dual/index.d.cts +export const cjs: number; + +// @Filename: /main.ts +import { esm, cjs } from "dual"; + +// @Filename: /main.mts +import { esm, cjs } from "dual"; + +// @Filename: /main.cts +import { esm, cjs } from "dual"; diff --git a/tests/cases/conformance/moduleResolution/hybrid/hybridSyntaxRestrictions.ts b/tests/cases/conformance/moduleResolution/hybrid/hybridSyntaxRestrictions.ts new file mode 100644 index 0000000000000..123c0c6348402 --- /dev/null +++ b/tests/cases/conformance/moduleResolution/hybrid/hybridSyntaxRestrictions.ts @@ -0,0 +1,20 @@ +// @moduleResolution: hybrid +// @checkJs: true +// @allowJs: true +// @outDir: out + +// @Filename: /node_modules/@types/node/index.d.ts +declare var require: (...args: any[]) => any; + +// @Filename: /a.ts +export {}; + +// @Filename: /mainJs.js +import {} from "./a"; +const _ = require("./a"); // No resolution + +// @Filename: /main.ts +import {} from "./a"; +import _ = require("./a"); // Error +export = {}; // Error +export {}; From e82e61da9440cbf85ea9b39c1f26f323df18a005 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 24 Oct 2022 16:43:58 -0700 Subject: [PATCH 22/41] Add another test --- tests/baselines/reference/hybridImportESM.js | 26 +++++++++++++++++++ .../reference/hybridImportESM.symbols | 12 +++++++++ .../baselines/reference/hybridImportESM.types | 13 ++++++++++ .../hybrid/hybridImportESM.ts | 13 ++++++++++ 4 files changed, 64 insertions(+) create mode 100644 tests/baselines/reference/hybridImportESM.js create mode 100644 tests/baselines/reference/hybridImportESM.symbols create mode 100644 tests/baselines/reference/hybridImportESM.types create mode 100644 tests/cases/conformance/moduleResolution/hybrid/hybridImportESM.ts diff --git a/tests/baselines/reference/hybridImportESM.js b/tests/baselines/reference/hybridImportESM.js new file mode 100644 index 0000000000000..266e72301eaa5 --- /dev/null +++ b/tests/baselines/reference/hybridImportESM.js @@ -0,0 +1,26 @@ +//// [tests/cases/conformance/moduleResolution/hybrid/hybridImportESM.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] +"use strict"; +exports.__esModule = true; +exports.esm = void 0; +exports.esm = 0; +//// [not-actually-cjs.cjs] +"use strict"; +exports.__esModule = true; +//// [still-not-cjs.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/hybridImportESM.symbols b/tests/baselines/reference/hybridImportESM.symbols new file mode 100644 index 0000000000000..de03eed56fdc2 --- /dev/null +++ b/tests/baselines/reference/hybridImportESM.symbols @@ -0,0 +1,12 @@ +=== /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/hybridImportESM.types b/tests/baselines/reference/hybridImportESM.types new file mode 100644 index 0000000000000..3ffcb432c7bff --- /dev/null +++ b/tests/baselines/reference/hybridImportESM.types @@ -0,0 +1,13 @@ +=== /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/cases/conformance/moduleResolution/hybrid/hybridImportESM.ts b/tests/cases/conformance/moduleResolution/hybrid/hybridImportESM.ts new file mode 100644 index 0000000000000..fcd14153c4c16 --- /dev/null +++ b/tests/cases/conformance/moduleResolution/hybrid/hybridImportESM.ts @@ -0,0 +1,13 @@ +// @moduleResolution: hybrid + +// @Filename: /esm.mts +export const esm = 0; + +// @Filename: /not-actually-cjs.cts +import { esm } from "./esm.mjs"; + +// @Filename: /package.json +{ "type": "commonjs" } + +// @Filename: /still-not-cjs.ts +import { esm } from "./esm.mjs"; From 038783d679f80a4606bdb23ec70d2daa1a5897f9 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Tue, 25 Oct 2022 16:12:13 -0700 Subject: [PATCH 23/41] Fix extension adding/replacing priority --- src/compiler/moduleNameResolver.ts | 10 +- .../reference/api/tsserverlibrary.d.ts | 9 +- tests/baselines/reference/api/typescript.d.ts | 9 +- ...rse empty options of --moduleResolution.js | 2 +- .../tsconfig.json | 4 + .../tsconfig.json | 4 + .../tsconfig.json | 4 + .../tsconfig.json | 4 + .../tsconfig.json | 4 + .../tsconfig.json | 4 + .../tsconfig.json | 4 + .../tsconfig.json | 4 + .../tsconfig.json | 4 + .../tsconfig.json | 4 + .../tsconfig.json | 4 + .../allowImportingTsExtensions/tsconfig.json | 5 + .../customConditions/tsconfig.json | 5 + .../resolvePackageJsonExports/tsconfig.json | 5 + .../resolvePackageJsonImports/tsconfig.json | 5 + ...Priority(moduleresolution=classic).symbols | 12 + ...ngPriority(moduleresolution=classic).types | 12 + ...gPriority(moduleresolution=hybrid).symbols | 12 + ...ingPriority(moduleresolution=hybrid).types | 12 + ...ingPriority(moduleresolution=node).symbols | 12 + ...adingPriority(moduleresolution=node).types | 12 + ...gPriority(moduleresolution=node16).symbols | 12 + ...ingPriority(moduleresolution=node16).types | 12 + ...riority(moduleresolution=nodenext).symbols | 12 + ...gPriority(moduleresolution=nodenext).types | 12 + ...sextensions=false,noemit=false).errors.txt | 84 +++ ...portingtsextensions=false,noemit=false).js | 66 ++ ...ngtsextensions=false,noemit=false).symbols | 58 ++ ...sextensions=false,noemit=false).trace.json | 101 +++ ...tingtsextensions=false,noemit=false).types | 58 ++ ...tsextensions=false,noemit=true).errors.txt | 80 ++ ...ingtsextensions=false,noemit=true).symbols | 58 ++ ...tsextensions=false,noemit=true).trace.json | 101 +++ ...rtingtsextensions=false,noemit=true).types | 58 ++ ...tsextensions=true,noemit=false).errors.txt | 71 ++ ...mportingtsextensions=true,noemit=false).js | 66 ++ ...ingtsextensions=true,noemit=false).symbols | 58 ++ ...tsextensions=true,noemit=false).trace.json | 101 +++ ...rtingtsextensions=true,noemit=false).types | 58 ++ ...gtsextensions=true,noemit=true).errors.txt | 65 ++ ...tingtsextensions=true,noemit=true).symbols | 58 ++ ...gtsextensions=true,noemit=true).trace.json | 101 +++ ...ortingtsextensions=true,noemit=true).types | 58 ++ .../reference/hybridNodeModules1.errors.txt | 59 ++ .../baselines/reference/hybridNodeModules1.js | 48 ++ .../reference/hybridNodeModules1.symbols | 23 + .../reference/hybridNodeModules1.trace.json | 22 + .../reference/hybridNodeModules1.types | 23 + .../reference/hybridRelative1.errors.txt | 2 - .../reference/hybridRelative1.trace.json | 6 - .../hybridSyntaxRestrictions.symbols | 4 +- .../reference/hybridSyntaxRestrictions.types | 4 +- .../moduleResolutionWithExtensions.trace.json | 6 - ...utionWithExtensions_unexpected2.trace.json | 6 +- ...olutionWithExtensions_withPaths.trace.json | 6 - ...es_one_externalModule_withPaths.trace.json | 3 - ...lutionWithSuffixes_one_jsModule.trace.json | 8 +- ...tionWithSuffixes_one_jsonModule.trace.json | 6 +- ...ageRoot_mainFieldInSubDirectory.trace.json | 3 - .../reference/packageJsonMain.trace.json | 6 +- ...eResolution_withExtensionInName.trace.json | 6 +- ...ithExtension_MapedToNodeModules.trace.json | 14 +- .../requireOfJsonFile_PathMapping.trace.json | 10 +- ...project-correctly-with-preserveSymlinks.js | 3 - ...-file-from-referenced-project-correctly.js | 3 - ...for-changes-to-package-json-main-fields.js | 18 - ...t-correctly-with-cts-and-mts-extensions.js | 15 - ...age-with-indirect-link-moduleCaseChange.js | 3 - ...er-symlinked-package-with-indirect-link.js | 3 - ...en-package-json-with-type-module-exists.js | 20 +- .../package-json-file-is-edited.js | 30 +- ...for-changes-to-package-json-main-fields.js | 15 - ...en-package-json-with-type-module-exists.js | 592 +++++++-------- .../package-json-file-is-edited.js | 710 ++++++++---------- .../extensionLoadingPriority.ts | 13 + .../hybrid/hybridImportTsExtensions.ts | 60 ++ 80 files changed, 2364 insertions(+), 900 deletions(-) create mode 100644 tests/baselines/reference/config/showConfig/Shows tsconfig for single option/allowImportingTsExtensions/tsconfig.json create mode 100644 tests/baselines/reference/config/showConfig/Shows tsconfig for single option/customConditions/tsconfig.json create mode 100644 tests/baselines/reference/config/showConfig/Shows tsconfig for single option/resolvePackageJsonExports/tsconfig.json create mode 100644 tests/baselines/reference/config/showConfig/Shows tsconfig for single option/resolvePackageJsonImports/tsconfig.json create mode 100644 tests/baselines/reference/extensionLoadingPriority(moduleresolution=classic).symbols create mode 100644 tests/baselines/reference/extensionLoadingPriority(moduleresolution=classic).types create mode 100644 tests/baselines/reference/extensionLoadingPriority(moduleresolution=hybrid).symbols create mode 100644 tests/baselines/reference/extensionLoadingPriority(moduleresolution=hybrid).types create mode 100644 tests/baselines/reference/extensionLoadingPriority(moduleresolution=node).symbols create mode 100644 tests/baselines/reference/extensionLoadingPriority(moduleresolution=node).types create mode 100644 tests/baselines/reference/extensionLoadingPriority(moduleresolution=node16).symbols create mode 100644 tests/baselines/reference/extensionLoadingPriority(moduleresolution=node16).types create mode 100644 tests/baselines/reference/extensionLoadingPriority(moduleresolution=nodenext).symbols create mode 100644 tests/baselines/reference/extensionLoadingPriority(moduleresolution=nodenext).types create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).js create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).symbols create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).types create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).symbols create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).types create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).js create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).symbols create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).types create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).symbols create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json create mode 100644 tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).types create mode 100644 tests/baselines/reference/hybridNodeModules1.errors.txt create mode 100644 tests/baselines/reference/hybridNodeModules1.js create mode 100644 tests/baselines/reference/hybridNodeModules1.symbols create mode 100644 tests/baselines/reference/hybridNodeModules1.trace.json create mode 100644 tests/baselines/reference/hybridNodeModules1.types create mode 100644 tests/cases/conformance/moduleResolution/extensionLoadingPriority.ts create mode 100644 tests/cases/conformance/moduleResolution/hybrid/hybridImportTsExtensions.ts diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index ac8f7c240873c..727ad7509dce2 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1609,7 +1609,13 @@ namespace ts { return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state); } - // esm mode resolutions don't include automatic extension lookup (without additional flags, at least) + // ./foo.js -> ./foo.ts + const resolvedByReplacingExtension = loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state); + if (resolvedByReplacingExtension) { + return resolvedByReplacingExtension; + } + + // ./foo -> ./foo.ts if (!(state.features & NodeResolutionFeatures.EsmMode)) { // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" const resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, "", onlyRecordFailures, state); @@ -1617,8 +1623,6 @@ namespace ts { return resolvedByAddingExtension; } } - - return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state); } function loadModuleFromFileNoImplicitExtensions(extensions: Extensions, candidate: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined { diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 5e9cde7f7bd51..a4506bc8200ce 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2944,7 +2944,8 @@ declare namespace ts { Classic = 1, NodeJs = 2, Node16 = 3, - NodeNext = 99 + NodeNext = 99, + Hybrid = 100 } export enum ModuleDetectionKind { /** @@ -3005,6 +3006,7 @@ declare namespace ts { baseUrl?: string; charset?: string; checkJs?: boolean; + customConditions?: string[]; declaration?: boolean; declarationMap?: boolean; emitDeclarationOnly?: boolean; @@ -3069,6 +3071,8 @@ declare namespace ts { incremental?: boolean; tsBuildInfoFile?: string; removeComments?: boolean; + resolvePackageJsonExports?: boolean; + resolvePackageJsonImports?: boolean; rootDir?: string; rootDirs?: string[]; skipLibCheck?: boolean; @@ -5064,9 +5068,10 @@ declare namespace ts { export function createTypeReferenceDirectiveResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions, packageJsonInfoCache?: PackageJsonInfoCache): TypeReferenceDirectiveResolutionCache; export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache, mode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined; export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations; + export function hybridModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - export function moduleResolutionSupportsResolvingTsExtensions(_compilerOptions: CompilerOptions): boolean; + export function moduleResolutionSupportsResolvingTsExtensions(compilerOptions: CompilerOptions): boolean; export function shouldAllowImportingTsExtension(compilerOptions: CompilerOptions, fromFileName?: string): boolean | "" | undefined; export {}; } diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index c96746b914b44..c2aab049d05b1 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2944,7 +2944,8 @@ declare namespace ts { Classic = 1, NodeJs = 2, Node16 = 3, - NodeNext = 99 + NodeNext = 99, + Hybrid = 100 } export enum ModuleDetectionKind { /** @@ -3005,6 +3006,7 @@ declare namespace ts { baseUrl?: string; charset?: string; checkJs?: boolean; + customConditions?: string[]; declaration?: boolean; declarationMap?: boolean; emitDeclarationOnly?: boolean; @@ -3069,6 +3071,8 @@ declare namespace ts { incremental?: boolean; tsBuildInfoFile?: string; removeComments?: boolean; + resolvePackageJsonExports?: boolean; + resolvePackageJsonImports?: boolean; rootDir?: string; rootDirs?: string[]; skipLibCheck?: boolean; @@ -5064,9 +5068,10 @@ declare namespace ts { export function createTypeReferenceDirectiveResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions, packageJsonInfoCache?: PackageJsonInfoCache): TypeReferenceDirectiveResolutionCache; export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache, mode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations | undefined; export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ModuleKind.CommonJS | ModuleKind.ESNext): ResolvedModuleWithFailedLookupLocations; + export function hybridModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - export function moduleResolutionSupportsResolvingTsExtensions(_compilerOptions: CompilerOptions): boolean; + export function moduleResolutionSupportsResolvingTsExtensions(compilerOptions: CompilerOptions): boolean; export function shouldAllowImportingTsExtension(compilerOptions: CompilerOptions, fromFileName?: string): boolean | "" | undefined; export {}; } diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse empty options of --moduleResolution.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse empty options of --moduleResolution.js index fb361238364f5..2bcff8882d32d 100644 --- a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse empty options of --moduleResolution.js +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse empty options of --moduleResolution.js @@ -7,4 +7,4 @@ FileNames:: 0.ts Errors:: error TS6044: Compiler option 'moduleResolution' expects an argument. -error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext'. +error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext', 'hybrid'. diff --git a/tests/baselines/reference/config/initTSConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Default initialized TSConfig/tsconfig.json index 19844ec8065fc..6c441a8d09dc3 100644 --- a/tests/baselines/reference/config/initTSConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Default initialized TSConfig/tsconfig.json @@ -35,6 +35,10 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --help/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --help/tsconfig.json index 19844ec8065fc..6c441a8d09dc3 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --help/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --help/tsconfig.json @@ -35,6 +35,10 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --watch/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --watch/tsconfig.json index 19844ec8065fc..6c441a8d09dc3 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --watch/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --watch/tsconfig.json @@ -35,6 +35,10 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with advanced options/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with advanced options/tsconfig.json index 6e28e016bd11d..51189f709b334 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with advanced options/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with advanced options/tsconfig.json @@ -35,6 +35,10 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index d73dbd191a220..73cfaeb1e2781 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -35,6 +35,10 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index c4c554e65dffb..0ea88943dc980 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -35,6 +35,10 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with files options/tsconfig.json index 2368ed9c35291..9977c19ffc059 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with files options/tsconfig.json @@ -35,6 +35,10 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 195f29bcb8708..8564d1f1c2aa8 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -35,6 +35,10 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index 19844ec8065fc..6c441a8d09dc3 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -35,6 +35,10 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index fe6fd06aa610a..2b4eafb70befb 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -35,6 +35,10 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options/tsconfig.json index 12daecbe8ed51..4a2a162913e21 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -35,6 +35,10 @@ "types": ["jquery","mocha"], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ // "resolveJsonModule": true, /* Enable importing .json files. */ // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ diff --git a/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/allowImportingTsExtensions/tsconfig.json b/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/allowImportingTsExtensions/tsconfig.json new file mode 100644 index 0000000000000..88c95f9eb8307 --- /dev/null +++ b/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/allowImportingTsExtensions/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "allowImportingTsExtensions": true + } +} diff --git a/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/customConditions/tsconfig.json b/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/customConditions/tsconfig.json new file mode 100644 index 0000000000000..e121ee76bc105 --- /dev/null +++ b/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/customConditions/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "customConditions": [] + } +} diff --git a/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/resolvePackageJsonExports/tsconfig.json b/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/resolvePackageJsonExports/tsconfig.json new file mode 100644 index 0000000000000..4dc0efaa783ba --- /dev/null +++ b/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/resolvePackageJsonExports/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "resolvePackageJsonExports": true + } +} diff --git a/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/resolvePackageJsonImports/tsconfig.json b/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/resolvePackageJsonImports/tsconfig.json new file mode 100644 index 0000000000000..a9e8a0f9e1faa --- /dev/null +++ b/tests/baselines/reference/config/showConfig/Shows tsconfig for single option/resolvePackageJsonImports/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "resolvePackageJsonImports": true + } +} diff --git a/tests/baselines/reference/extensionLoadingPriority(moduleresolution=classic).symbols b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=classic).symbols new file mode 100644 index 0000000000000..1851abea3894c --- /dev/null +++ b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=classic).symbols @@ -0,0 +1,12 @@ +=== /project/a.js === + +export default "a.js"; + +=== /project/a.js.js === + +export default "a.js.js"; + +=== /project/b.ts === +import a from "./a.js"; +>a : Symbol(a, Decl(b.ts, 0, 6)) + diff --git a/tests/baselines/reference/extensionLoadingPriority(moduleresolution=classic).types b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=classic).types new file mode 100644 index 0000000000000..b442294d98f6a --- /dev/null +++ b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=classic).types @@ -0,0 +1,12 @@ +=== /project/a.js === + +export default "a.js"; + +=== /project/a.js.js === + +export default "a.js.js"; + +=== /project/b.ts === +import a from "./a.js"; +>a : "a.js" + diff --git a/tests/baselines/reference/extensionLoadingPriority(moduleresolution=hybrid).symbols b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=hybrid).symbols new file mode 100644 index 0000000000000..1851abea3894c --- /dev/null +++ b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=hybrid).symbols @@ -0,0 +1,12 @@ +=== /project/a.js === + +export default "a.js"; + +=== /project/a.js.js === + +export default "a.js.js"; + +=== /project/b.ts === +import a from "./a.js"; +>a : Symbol(a, Decl(b.ts, 0, 6)) + diff --git a/tests/baselines/reference/extensionLoadingPriority(moduleresolution=hybrid).types b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=hybrid).types new file mode 100644 index 0000000000000..b442294d98f6a --- /dev/null +++ b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=hybrid).types @@ -0,0 +1,12 @@ +=== /project/a.js === + +export default "a.js"; + +=== /project/a.js.js === + +export default "a.js.js"; + +=== /project/b.ts === +import a from "./a.js"; +>a : "a.js" + diff --git a/tests/baselines/reference/extensionLoadingPriority(moduleresolution=node).symbols b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=node).symbols new file mode 100644 index 0000000000000..1851abea3894c --- /dev/null +++ b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=node).symbols @@ -0,0 +1,12 @@ +=== /project/a.js === + +export default "a.js"; + +=== /project/a.js.js === + +export default "a.js.js"; + +=== /project/b.ts === +import a from "./a.js"; +>a : Symbol(a, Decl(b.ts, 0, 6)) + diff --git a/tests/baselines/reference/extensionLoadingPriority(moduleresolution=node).types b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=node).types new file mode 100644 index 0000000000000..b442294d98f6a --- /dev/null +++ b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=node).types @@ -0,0 +1,12 @@ +=== /project/a.js === + +export default "a.js"; + +=== /project/a.js.js === + +export default "a.js.js"; + +=== /project/b.ts === +import a from "./a.js"; +>a : "a.js" + diff --git a/tests/baselines/reference/extensionLoadingPriority(moduleresolution=node16).symbols b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=node16).symbols new file mode 100644 index 0000000000000..1851abea3894c --- /dev/null +++ b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=node16).symbols @@ -0,0 +1,12 @@ +=== /project/a.js === + +export default "a.js"; + +=== /project/a.js.js === + +export default "a.js.js"; + +=== /project/b.ts === +import a from "./a.js"; +>a : Symbol(a, Decl(b.ts, 0, 6)) + diff --git a/tests/baselines/reference/extensionLoadingPriority(moduleresolution=node16).types b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=node16).types new file mode 100644 index 0000000000000..b442294d98f6a --- /dev/null +++ b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=node16).types @@ -0,0 +1,12 @@ +=== /project/a.js === + +export default "a.js"; + +=== /project/a.js.js === + +export default "a.js.js"; + +=== /project/b.ts === +import a from "./a.js"; +>a : "a.js" + diff --git a/tests/baselines/reference/extensionLoadingPriority(moduleresolution=nodenext).symbols b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=nodenext).symbols new file mode 100644 index 0000000000000..1851abea3894c --- /dev/null +++ b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=nodenext).symbols @@ -0,0 +1,12 @@ +=== /project/a.js === + +export default "a.js"; + +=== /project/a.js.js === + +export default "a.js.js"; + +=== /project/b.ts === +import a from "./a.js"; +>a : Symbol(a, Decl(b.ts, 0, 6)) + diff --git a/tests/baselines/reference/extensionLoadingPriority(moduleresolution=nodenext).types b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=nodenext).types new file mode 100644 index 0000000000000..b442294d98f6a --- /dev/null +++ b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=nodenext).types @@ -0,0 +1,12 @@ +=== /project/a.js === + +export default "a.js"; + +=== /project/a.js.js === + +export default "a.js.js"; + +=== /project/b.ts === +import a from "./a.js"; +>a : "a.js" + diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt new file mode 100644 index 0000000000000..b88b3f78bb7a3 --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt @@ -0,0 +1,84 @@ +error TS5056: Cannot write file 'out/b.js' because it would be overwritten by multiple input files. +error TS5056: Cannot write file 'out/c.js' because it would be overwritten by multiple input files. +/project/main.ts(3,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(7,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? +/project/main.ts(11,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(12,16): error TS5097: An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. +/project/main.ts(16,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/project/types.d.ts(2,16): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. +/project/types.d.ts(3,21): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. + + +!!! error TS5056: Cannot write file 'out/b.js' because it would be overwritten by multiple input files. +!!! error TS5056: Cannot write file 'out/c.js' because it would be overwritten by multiple input files. +==== /project/a.ts (0 errors) ==== + export {}; + +==== /project/b.ts (0 errors) ==== + export {}; + +==== /project/b.js (0 errors) ==== + export {}; + +==== /project/b.d.ts (0 errors) ==== + export {}; + +==== /project/c.ts (0 errors) ==== + export {}; + +==== /project/c.tsx (0 errors) ==== + export {}; + +==== /project/d/index.ts (0 errors) ==== + export {}; + +==== /project/e (0 errors) ==== + WOMP WOMP BINARY DATA + +==== /project/e.ts (0 errors) ==== + export {}; + +==== /project/main.ts (7 errors) ==== + import {} from "./a"; + import {} from "./a.js"; + import {} from "./a.ts"; + ~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + + import {} from "./b"; + import {} from "./b.js"; + import {} from "./b.ts"; + ~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + import {} from "./b.d.ts"; + ~~~~~~~~~~ +!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? + import type {} from "./b.d.ts"; + + import {} from "./c.ts"; + ~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + import {} from "./c.tsx"; + ~~~~~~~~~ +!!! error TS5097: An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled. + ~~~~~~~~~ +!!! error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. + + import {} from "./d"; + import {} from "./d/index"; + import {} from "./d/index.ts"; + ~~~~~~~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + + import {} from "./e"; + +==== /project/types.d.ts (2 errors) ==== + import {} from "./a.ts"; + import {} from "./a.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. + import type {} from "./a.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. \ No newline at end of file diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).js b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).js new file mode 100644 index 0000000000000..f946ec9557b55 --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).js @@ -0,0 +1,66 @@ +//// [tests/cases/conformance/moduleResolution/hybrid/hybridImportTsExtensions.ts] //// + +//// [a.ts] +export {}; + +//// [b.ts] +export {}; + +//// [b.js] +export {}; + +//// [b.d.ts] +export {}; + +//// [c.ts] +export {}; + +//// [c.tsx] +export {}; + +//// [index.ts] +export {}; + +//// [e] +WOMP WOMP BINARY DATA + +//// [e.ts] +export {}; + +//// [main.ts] +import {} from "./a"; +import {} from "./a.js"; +import {} from "./a.ts"; + +import {} from "./b"; +import {} from "./b.js"; +import {} from "./b.ts"; +import {} from "./b.d.ts"; +import type {} from "./b.d.ts"; + +import {} from "./c.ts"; +import {} from "./c.tsx"; + +import {} from "./d"; +import {} from "./d/index"; +import {} from "./d/index.ts"; + +import {} from "./e"; + +//// [types.d.ts] +import {} from "./a.ts"; +import {} from "./a.d.ts"; +import type {} from "./a.d.ts"; + +//// [a.js] +"use strict"; +exports.__esModule = true; +//// [index.js] +"use strict"; +exports.__esModule = true; +//// [e.js] +"use strict"; +exports.__esModule = true; +//// [main.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).symbols b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).symbols new file mode 100644 index 0000000000000..bcf03f8d9917e --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).symbols @@ -0,0 +1,58 @@ +=== /project/a.ts === + +export {}; + +=== /project/b.ts === + +export {}; + +=== /project/b.js === + +export {}; + +=== /project/b.d.ts === + +export {}; + +=== /project/c.ts === + +export {}; + +=== /project/c.tsx === + +export {}; + +=== /project/d/index.ts === + +export {}; + +=== /project/e.ts === + +export {}; + +=== /project/main.ts === + +import {} from "./a"; +import {} from "./a.js"; +import {} from "./a.ts"; + +import {} from "./b"; +import {} from "./b.js"; +import {} from "./b.ts"; +import {} from "./b.d.ts"; +import type {} from "./b.d.ts"; + +import {} from "./c.ts"; +import {} from "./c.tsx"; + +import {} from "./d"; +import {} from "./d/index"; +import {} from "./d/index.ts"; + +import {} from "./e"; + +=== /project/types.d.ts === + +import {} from "./a.ts"; +import {} from "./a.d.ts"; +import type {} from "./a.d.ts"; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json new file mode 100644 index 0000000000000..1c0a228b1841f --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json @@ -0,0 +1,101 @@ +[ + "======== Resolving module './a' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/a', target file type 'TypeScript'.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/a.js', target file type 'TypeScript'.", + "File name '/project/a.js' has a '.js' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/a.ts', target file type 'TypeScript'.", + "File name '/project/a.ts' has a '.ts' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './b' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/b', target file type 'TypeScript'.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/b.js', target file type 'TypeScript'.", + "File name '/project/b.js' has a '.js' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/b.ts', target file type 'TypeScript'.", + "File name '/project/b.ts' has a '.ts' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/b.d.ts', target file type 'TypeScript'.", + "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/b.d.ts' exist - use it as a name resolution result.", + "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", + "======== Resolving module './c.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/c.ts', target file type 'TypeScript'.", + "File name '/project/c.ts' has a '.ts' extension - stripping it.", + "File '/project/c.ts' exist - use it as a name resolution result.", + "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", + "======== Resolving module './c.tsx' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/c.tsx', target file type 'TypeScript'.", + "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", + "File '/project/c.tsx' exist - use it as a name resolution result.", + "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", + "======== Resolving module './d' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/d', target file type 'TypeScript'.", + "File '/project/d.ts' does not exist.", + "File '/project/d.tsx' does not exist.", + "File '/project/d.d.ts' does not exist.", + "File '/project/d/package.json' does not exist.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './d/index' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/d/index', target file type 'TypeScript'.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d/index' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/d/index.ts', target file type 'TypeScript'.", + "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './e' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/e', target file type 'TypeScript'.", + "File '/project/e.ts' exist - use it as a name resolution result.", + "======== Module name './e' was successfully resolved to '/project/e.ts'. ========", + "======== Resolving module './a.ts' from '/project/types.d.ts'. ========", + "Resolution for module './a.ts' was found in cache from location '/project'.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/a.d.ts', target file type 'TypeScript'.", + "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/a.d.ts' does not exist.", + "File '/project/a.d.ts.ts' does not exist.", + "File '/project/a.d.ts.tsx' does not exist.", + "File '/project/a.d.ts.d.ts' does not exist.", + "Directory '/project/a.d.ts' does not exist, skipping all lookups in it.", + "Loading module as file / folder, candidate module location '/project/a.d.ts', target file type 'JavaScript'.", + "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/a.js' does not exist.", + "File '/project/a.jsx' does not exist.", + "File '/project/a.d.ts.js' does not exist.", + "File '/project/a.d.ts.jsx' does not exist.", + "Directory '/project/a.d.ts' does not exist, skipping all lookups in it.", + "Loading module as file / folder, candidate module location '/project/a.d.ts', target file type 'Json'.", + "Directory '/project/a.d.ts' does not exist, skipping all lookups in it.", + "======== Module name './a.d.ts' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).types b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).types new file mode 100644 index 0000000000000..bcf03f8d9917e --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).types @@ -0,0 +1,58 @@ +=== /project/a.ts === + +export {}; + +=== /project/b.ts === + +export {}; + +=== /project/b.js === + +export {}; + +=== /project/b.d.ts === + +export {}; + +=== /project/c.ts === + +export {}; + +=== /project/c.tsx === + +export {}; + +=== /project/d/index.ts === + +export {}; + +=== /project/e.ts === + +export {}; + +=== /project/main.ts === + +import {} from "./a"; +import {} from "./a.js"; +import {} from "./a.ts"; + +import {} from "./b"; +import {} from "./b.js"; +import {} from "./b.ts"; +import {} from "./b.d.ts"; +import type {} from "./b.d.ts"; + +import {} from "./c.ts"; +import {} from "./c.tsx"; + +import {} from "./d"; +import {} from "./d/index"; +import {} from "./d/index.ts"; + +import {} from "./e"; + +=== /project/types.d.ts === + +import {} from "./a.ts"; +import {} from "./a.d.ts"; +import type {} from "./a.d.ts"; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt new file mode 100644 index 0000000000000..cc93517215702 --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt @@ -0,0 +1,80 @@ +/project/main.ts(3,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(7,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? +/project/main.ts(11,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(12,16): error TS5097: An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled. +/project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. +/project/main.ts(16,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. +/project/types.d.ts(2,16): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. +/project/types.d.ts(3,21): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. + + +==== /project/a.ts (0 errors) ==== + export {}; + +==== /project/b.ts (0 errors) ==== + export {}; + +==== /project/b.js (0 errors) ==== + export {}; + +==== /project/b.d.ts (0 errors) ==== + export {}; + +==== /project/c.ts (0 errors) ==== + export {}; + +==== /project/c.tsx (0 errors) ==== + export {}; + +==== /project/d/index.ts (0 errors) ==== + export {}; + +==== /project/e (0 errors) ==== + WOMP WOMP BINARY DATA + +==== /project/e.ts (0 errors) ==== + export {}; + +==== /project/main.ts (7 errors) ==== + import {} from "./a"; + import {} from "./a.js"; + import {} from "./a.ts"; + ~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + + import {} from "./b"; + import {} from "./b.js"; + import {} from "./b.ts"; + ~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + import {} from "./b.d.ts"; + ~~~~~~~~~~ +!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? + import type {} from "./b.d.ts"; + + import {} from "./c.ts"; + ~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + import {} from "./c.tsx"; + ~~~~~~~~~ +!!! error TS5097: An import path can only end with a '.tsx' extension when 'allowImportingTsExtensions' is enabled. + ~~~~~~~~~ +!!! error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. + + import {} from "./d"; + import {} from "./d/index"; + import {} from "./d/index.ts"; + ~~~~~~~~~~~~~~ +!!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + + import {} from "./e"; + +==== /project/types.d.ts (2 errors) ==== + import {} from "./a.ts"; + import {} from "./a.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. + import type {} from "./a.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. \ No newline at end of file diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).symbols b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).symbols new file mode 100644 index 0000000000000..bcf03f8d9917e --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).symbols @@ -0,0 +1,58 @@ +=== /project/a.ts === + +export {}; + +=== /project/b.ts === + +export {}; + +=== /project/b.js === + +export {}; + +=== /project/b.d.ts === + +export {}; + +=== /project/c.ts === + +export {}; + +=== /project/c.tsx === + +export {}; + +=== /project/d/index.ts === + +export {}; + +=== /project/e.ts === + +export {}; + +=== /project/main.ts === + +import {} from "./a"; +import {} from "./a.js"; +import {} from "./a.ts"; + +import {} from "./b"; +import {} from "./b.js"; +import {} from "./b.ts"; +import {} from "./b.d.ts"; +import type {} from "./b.d.ts"; + +import {} from "./c.ts"; +import {} from "./c.tsx"; + +import {} from "./d"; +import {} from "./d/index"; +import {} from "./d/index.ts"; + +import {} from "./e"; + +=== /project/types.d.ts === + +import {} from "./a.ts"; +import {} from "./a.d.ts"; +import type {} from "./a.d.ts"; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json new file mode 100644 index 0000000000000..1c0a228b1841f --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json @@ -0,0 +1,101 @@ +[ + "======== Resolving module './a' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/a', target file type 'TypeScript'.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/a.js', target file type 'TypeScript'.", + "File name '/project/a.js' has a '.js' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/a.ts', target file type 'TypeScript'.", + "File name '/project/a.ts' has a '.ts' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './b' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/b', target file type 'TypeScript'.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/b.js', target file type 'TypeScript'.", + "File name '/project/b.js' has a '.js' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/b.ts', target file type 'TypeScript'.", + "File name '/project/b.ts' has a '.ts' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/b.d.ts', target file type 'TypeScript'.", + "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/b.d.ts' exist - use it as a name resolution result.", + "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", + "======== Resolving module './c.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/c.ts', target file type 'TypeScript'.", + "File name '/project/c.ts' has a '.ts' extension - stripping it.", + "File '/project/c.ts' exist - use it as a name resolution result.", + "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", + "======== Resolving module './c.tsx' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/c.tsx', target file type 'TypeScript'.", + "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", + "File '/project/c.tsx' exist - use it as a name resolution result.", + "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", + "======== Resolving module './d' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/d', target file type 'TypeScript'.", + "File '/project/d.ts' does not exist.", + "File '/project/d.tsx' does not exist.", + "File '/project/d.d.ts' does not exist.", + "File '/project/d/package.json' does not exist.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './d/index' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/d/index', target file type 'TypeScript'.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d/index' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/d/index.ts', target file type 'TypeScript'.", + "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './e' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/e', target file type 'TypeScript'.", + "File '/project/e.ts' exist - use it as a name resolution result.", + "======== Module name './e' was successfully resolved to '/project/e.ts'. ========", + "======== Resolving module './a.ts' from '/project/types.d.ts'. ========", + "Resolution for module './a.ts' was found in cache from location '/project'.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/a.d.ts', target file type 'TypeScript'.", + "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/a.d.ts' does not exist.", + "File '/project/a.d.ts.ts' does not exist.", + "File '/project/a.d.ts.tsx' does not exist.", + "File '/project/a.d.ts.d.ts' does not exist.", + "Directory '/project/a.d.ts' does not exist, skipping all lookups in it.", + "Loading module as file / folder, candidate module location '/project/a.d.ts', target file type 'JavaScript'.", + "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/a.js' does not exist.", + "File '/project/a.jsx' does not exist.", + "File '/project/a.d.ts.js' does not exist.", + "File '/project/a.d.ts.jsx' does not exist.", + "Directory '/project/a.d.ts' does not exist, skipping all lookups in it.", + "Loading module as file / folder, candidate module location '/project/a.d.ts', target file type 'Json'.", + "Directory '/project/a.d.ts' does not exist, skipping all lookups in it.", + "======== Module name './a.d.ts' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).types b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).types new file mode 100644 index 0000000000000..bcf03f8d9917e --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).types @@ -0,0 +1,58 @@ +=== /project/a.ts === + +export {}; + +=== /project/b.ts === + +export {}; + +=== /project/b.js === + +export {}; + +=== /project/b.d.ts === + +export {}; + +=== /project/c.ts === + +export {}; + +=== /project/c.tsx === + +export {}; + +=== /project/d/index.ts === + +export {}; + +=== /project/e.ts === + +export {}; + +=== /project/main.ts === + +import {} from "./a"; +import {} from "./a.js"; +import {} from "./a.ts"; + +import {} from "./b"; +import {} from "./b.js"; +import {} from "./b.ts"; +import {} from "./b.d.ts"; +import type {} from "./b.d.ts"; + +import {} from "./c.ts"; +import {} from "./c.tsx"; + +import {} from "./d"; +import {} from "./d/index"; +import {} from "./d/index.ts"; + +import {} from "./e"; + +=== /project/types.d.ts === + +import {} from "./a.ts"; +import {} from "./a.d.ts"; +import type {} from "./a.d.ts"; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt new file mode 100644 index 0000000000000..1e93929f4b534 --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt @@ -0,0 +1,71 @@ +error TS5056: Cannot write file 'out/b.js' because it would be overwritten by multiple input files. +error TS5056: Cannot write file 'out/c.js' because it would be overwritten by multiple input files. +error TS5096: Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'hybrid' and either 'noEmit' or 'emitDeclarationOnly' is set. +/project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? +/project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. +/project/types.d.ts(2,16): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. +/project/types.d.ts(3,21): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. + + +!!! error TS5056: Cannot write file 'out/b.js' because it would be overwritten by multiple input files. +!!! error TS5056: Cannot write file 'out/c.js' because it would be overwritten by multiple input files. +!!! error TS5096: Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'hybrid' and either 'noEmit' or 'emitDeclarationOnly' is set. +==== /project/a.ts (0 errors) ==== + export {}; + +==== /project/b.ts (0 errors) ==== + export {}; + +==== /project/b.js (0 errors) ==== + export {}; + +==== /project/b.d.ts (0 errors) ==== + export {}; + +==== /project/c.ts (0 errors) ==== + export {}; + +==== /project/c.tsx (0 errors) ==== + export {}; + +==== /project/d/index.ts (0 errors) ==== + export {}; + +==== /project/e (0 errors) ==== + WOMP WOMP BINARY DATA + +==== /project/e.ts (0 errors) ==== + export {}; + +==== /project/main.ts (2 errors) ==== + import {} from "./a"; + import {} from "./a.js"; + import {} from "./a.ts"; + + import {} from "./b"; + import {} from "./b.js"; + import {} from "./b.ts"; + import {} from "./b.d.ts"; + ~~~~~~~~~~ +!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? + import type {} from "./b.d.ts"; + + import {} from "./c.ts"; + import {} from "./c.tsx"; + ~~~~~~~~~ +!!! error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. + + import {} from "./d"; + import {} from "./d/index"; + import {} from "./d/index.ts"; + + import {} from "./e"; + +==== /project/types.d.ts (2 errors) ==== + import {} from "./a.ts"; + import {} from "./a.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. + import type {} from "./a.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. \ No newline at end of file diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).js b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).js new file mode 100644 index 0000000000000..f946ec9557b55 --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).js @@ -0,0 +1,66 @@ +//// [tests/cases/conformance/moduleResolution/hybrid/hybridImportTsExtensions.ts] //// + +//// [a.ts] +export {}; + +//// [b.ts] +export {}; + +//// [b.js] +export {}; + +//// [b.d.ts] +export {}; + +//// [c.ts] +export {}; + +//// [c.tsx] +export {}; + +//// [index.ts] +export {}; + +//// [e] +WOMP WOMP BINARY DATA + +//// [e.ts] +export {}; + +//// [main.ts] +import {} from "./a"; +import {} from "./a.js"; +import {} from "./a.ts"; + +import {} from "./b"; +import {} from "./b.js"; +import {} from "./b.ts"; +import {} from "./b.d.ts"; +import type {} from "./b.d.ts"; + +import {} from "./c.ts"; +import {} from "./c.tsx"; + +import {} from "./d"; +import {} from "./d/index"; +import {} from "./d/index.ts"; + +import {} from "./e"; + +//// [types.d.ts] +import {} from "./a.ts"; +import {} from "./a.d.ts"; +import type {} from "./a.d.ts"; + +//// [a.js] +"use strict"; +exports.__esModule = true; +//// [index.js] +"use strict"; +exports.__esModule = true; +//// [e.js] +"use strict"; +exports.__esModule = true; +//// [main.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).symbols b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).symbols new file mode 100644 index 0000000000000..bcf03f8d9917e --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).symbols @@ -0,0 +1,58 @@ +=== /project/a.ts === + +export {}; + +=== /project/b.ts === + +export {}; + +=== /project/b.js === + +export {}; + +=== /project/b.d.ts === + +export {}; + +=== /project/c.ts === + +export {}; + +=== /project/c.tsx === + +export {}; + +=== /project/d/index.ts === + +export {}; + +=== /project/e.ts === + +export {}; + +=== /project/main.ts === + +import {} from "./a"; +import {} from "./a.js"; +import {} from "./a.ts"; + +import {} from "./b"; +import {} from "./b.js"; +import {} from "./b.ts"; +import {} from "./b.d.ts"; +import type {} from "./b.d.ts"; + +import {} from "./c.ts"; +import {} from "./c.tsx"; + +import {} from "./d"; +import {} from "./d/index"; +import {} from "./d/index.ts"; + +import {} from "./e"; + +=== /project/types.d.ts === + +import {} from "./a.ts"; +import {} from "./a.d.ts"; +import type {} from "./a.d.ts"; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json new file mode 100644 index 0000000000000..1c0a228b1841f --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json @@ -0,0 +1,101 @@ +[ + "======== Resolving module './a' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/a', target file type 'TypeScript'.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/a.js', target file type 'TypeScript'.", + "File name '/project/a.js' has a '.js' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/a.ts', target file type 'TypeScript'.", + "File name '/project/a.ts' has a '.ts' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './b' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/b', target file type 'TypeScript'.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/b.js', target file type 'TypeScript'.", + "File name '/project/b.js' has a '.js' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/b.ts', target file type 'TypeScript'.", + "File name '/project/b.ts' has a '.ts' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/b.d.ts', target file type 'TypeScript'.", + "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/b.d.ts' exist - use it as a name resolution result.", + "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", + "======== Resolving module './c.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/c.ts', target file type 'TypeScript'.", + "File name '/project/c.ts' has a '.ts' extension - stripping it.", + "File '/project/c.ts' exist - use it as a name resolution result.", + "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", + "======== Resolving module './c.tsx' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/c.tsx', target file type 'TypeScript'.", + "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", + "File '/project/c.tsx' exist - use it as a name resolution result.", + "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", + "======== Resolving module './d' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/d', target file type 'TypeScript'.", + "File '/project/d.ts' does not exist.", + "File '/project/d.tsx' does not exist.", + "File '/project/d.d.ts' does not exist.", + "File '/project/d/package.json' does not exist.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './d/index' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/d/index', target file type 'TypeScript'.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d/index' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/d/index.ts', target file type 'TypeScript'.", + "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './e' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/e', target file type 'TypeScript'.", + "File '/project/e.ts' exist - use it as a name resolution result.", + "======== Module name './e' was successfully resolved to '/project/e.ts'. ========", + "======== Resolving module './a.ts' from '/project/types.d.ts'. ========", + "Resolution for module './a.ts' was found in cache from location '/project'.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/a.d.ts', target file type 'TypeScript'.", + "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/a.d.ts' does not exist.", + "File '/project/a.d.ts.ts' does not exist.", + "File '/project/a.d.ts.tsx' does not exist.", + "File '/project/a.d.ts.d.ts' does not exist.", + "Directory '/project/a.d.ts' does not exist, skipping all lookups in it.", + "Loading module as file / folder, candidate module location '/project/a.d.ts', target file type 'JavaScript'.", + "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/a.js' does not exist.", + "File '/project/a.jsx' does not exist.", + "File '/project/a.d.ts.js' does not exist.", + "File '/project/a.d.ts.jsx' does not exist.", + "Directory '/project/a.d.ts' does not exist, skipping all lookups in it.", + "Loading module as file / folder, candidate module location '/project/a.d.ts', target file type 'Json'.", + "Directory '/project/a.d.ts' does not exist, skipping all lookups in it.", + "======== Module name './a.d.ts' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).types b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).types new file mode 100644 index 0000000000000..bcf03f8d9917e --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).types @@ -0,0 +1,58 @@ +=== /project/a.ts === + +export {}; + +=== /project/b.ts === + +export {}; + +=== /project/b.js === + +export {}; + +=== /project/b.d.ts === + +export {}; + +=== /project/c.ts === + +export {}; + +=== /project/c.tsx === + +export {}; + +=== /project/d/index.ts === + +export {}; + +=== /project/e.ts === + +export {}; + +=== /project/main.ts === + +import {} from "./a"; +import {} from "./a.js"; +import {} from "./a.ts"; + +import {} from "./b"; +import {} from "./b.js"; +import {} from "./b.ts"; +import {} from "./b.d.ts"; +import type {} from "./b.d.ts"; + +import {} from "./c.ts"; +import {} from "./c.tsx"; + +import {} from "./d"; +import {} from "./d/index"; +import {} from "./d/index.ts"; + +import {} from "./e"; + +=== /project/types.d.ts === + +import {} from "./a.ts"; +import {} from "./a.d.ts"; +import type {} from "./a.d.ts"; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt new file mode 100644 index 0000000000000..cdf02ebb53120 --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt @@ -0,0 +1,65 @@ +/project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? +/project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. +/project/types.d.ts(2,16): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. +/project/types.d.ts(3,21): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. + + +==== /project/a.ts (0 errors) ==== + export {}; + +==== /project/b.ts (0 errors) ==== + export {}; + +==== /project/b.js (0 errors) ==== + export {}; + +==== /project/b.d.ts (0 errors) ==== + export {}; + +==== /project/c.ts (0 errors) ==== + export {}; + +==== /project/c.tsx (0 errors) ==== + export {}; + +==== /project/d/index.ts (0 errors) ==== + export {}; + +==== /project/e (0 errors) ==== + WOMP WOMP BINARY DATA + +==== /project/e.ts (0 errors) ==== + export {}; + +==== /project/main.ts (2 errors) ==== + import {} from "./a"; + import {} from "./a.js"; + import {} from "./a.ts"; + + import {} from "./b"; + import {} from "./b.js"; + import {} from "./b.ts"; + import {} from "./b.d.ts"; + ~~~~~~~~~~ +!!! error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? + import type {} from "./b.d.ts"; + + import {} from "./c.ts"; + import {} from "./c.tsx"; + ~~~~~~~~~ +!!! error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. + + import {} from "./d"; + import {} from "./d/index"; + import {} from "./d/index.ts"; + + import {} from "./e"; + +==== /project/types.d.ts (2 errors) ==== + import {} from "./a.ts"; + import {} from "./a.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. + import type {} from "./a.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. \ No newline at end of file diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).symbols b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).symbols new file mode 100644 index 0000000000000..bcf03f8d9917e --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).symbols @@ -0,0 +1,58 @@ +=== /project/a.ts === + +export {}; + +=== /project/b.ts === + +export {}; + +=== /project/b.js === + +export {}; + +=== /project/b.d.ts === + +export {}; + +=== /project/c.ts === + +export {}; + +=== /project/c.tsx === + +export {}; + +=== /project/d/index.ts === + +export {}; + +=== /project/e.ts === + +export {}; + +=== /project/main.ts === + +import {} from "./a"; +import {} from "./a.js"; +import {} from "./a.ts"; + +import {} from "./b"; +import {} from "./b.js"; +import {} from "./b.ts"; +import {} from "./b.d.ts"; +import type {} from "./b.d.ts"; + +import {} from "./c.ts"; +import {} from "./c.tsx"; + +import {} from "./d"; +import {} from "./d/index"; +import {} from "./d/index.ts"; + +import {} from "./e"; + +=== /project/types.d.ts === + +import {} from "./a.ts"; +import {} from "./a.d.ts"; +import type {} from "./a.d.ts"; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json new file mode 100644 index 0000000000000..1c0a228b1841f --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json @@ -0,0 +1,101 @@ +[ + "======== Resolving module './a' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/a', target file type 'TypeScript'.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/a.js', target file type 'TypeScript'.", + "File name '/project/a.js' has a '.js' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/a.ts', target file type 'TypeScript'.", + "File name '/project/a.ts' has a '.ts' extension - stripping it.", + "File '/project/a.ts' exist - use it as a name resolution result.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './b' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/b', target file type 'TypeScript'.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.js' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/b.js', target file type 'TypeScript'.", + "File name '/project/b.js' has a '.js' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/b.ts', target file type 'TypeScript'.", + "File name '/project/b.ts' has a '.ts' extension - stripping it.", + "File '/project/b.ts' exist - use it as a name resolution result.", + "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", + "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/b.d.ts', target file type 'TypeScript'.", + "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/b.d.ts' exist - use it as a name resolution result.", + "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", + "======== Resolving module './c.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/c.ts', target file type 'TypeScript'.", + "File name '/project/c.ts' has a '.ts' extension - stripping it.", + "File '/project/c.ts' exist - use it as a name resolution result.", + "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", + "======== Resolving module './c.tsx' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/c.tsx', target file type 'TypeScript'.", + "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", + "File '/project/c.tsx' exist - use it as a name resolution result.", + "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", + "======== Resolving module './d' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/d', target file type 'TypeScript'.", + "File '/project/d.ts' does not exist.", + "File '/project/d.tsx' does not exist.", + "File '/project/d.d.ts' does not exist.", + "File '/project/d/package.json' does not exist.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './d/index' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/d/index', target file type 'TypeScript'.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d/index' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/d/index.ts', target file type 'TypeScript'.", + "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", + "File '/project/d/index.ts' exist - use it as a name resolution result.", + "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", + "======== Resolving module './e' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/e', target file type 'TypeScript'.", + "File '/project/e.ts' exist - use it as a name resolution result.", + "======== Module name './e' was successfully resolved to '/project/e.ts'. ========", + "======== Resolving module './a.ts' from '/project/types.d.ts'. ========", + "Resolution for module './a.ts' was found in cache from location '/project'.", + "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", + "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/a.d.ts', target file type 'TypeScript'.", + "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/a.d.ts' does not exist.", + "File '/project/a.d.ts.ts' does not exist.", + "File '/project/a.d.ts.tsx' does not exist.", + "File '/project/a.d.ts.d.ts' does not exist.", + "Directory '/project/a.d.ts' does not exist, skipping all lookups in it.", + "Loading module as file / folder, candidate module location '/project/a.d.ts', target file type 'JavaScript'.", + "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", + "File '/project/a.js' does not exist.", + "File '/project/a.jsx' does not exist.", + "File '/project/a.d.ts.js' does not exist.", + "File '/project/a.d.ts.jsx' does not exist.", + "Directory '/project/a.d.ts' does not exist, skipping all lookups in it.", + "Loading module as file / folder, candidate module location '/project/a.d.ts', target file type 'Json'.", + "Directory '/project/a.d.ts' does not exist, skipping all lookups in it.", + "======== Module name './a.d.ts' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).types b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).types new file mode 100644 index 0000000000000..bcf03f8d9917e --- /dev/null +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).types @@ -0,0 +1,58 @@ +=== /project/a.ts === + +export {}; + +=== /project/b.ts === + +export {}; + +=== /project/b.js === + +export {}; + +=== /project/b.d.ts === + +export {}; + +=== /project/c.ts === + +export {}; + +=== /project/c.tsx === + +export {}; + +=== /project/d/index.ts === + +export {}; + +=== /project/e.ts === + +export {}; + +=== /project/main.ts === + +import {} from "./a"; +import {} from "./a.js"; +import {} from "./a.ts"; + +import {} from "./b"; +import {} from "./b.js"; +import {} from "./b.ts"; +import {} from "./b.d.ts"; +import type {} from "./b.d.ts"; + +import {} from "./c.ts"; +import {} from "./c.tsx"; + +import {} from "./d"; +import {} from "./d/index"; +import {} from "./d/index.ts"; + +import {} from "./e"; + +=== /project/types.d.ts === + +import {} from "./a.ts"; +import {} from "./a.d.ts"; +import type {} from "./a.d.ts"; diff --git a/tests/baselines/reference/hybridNodeModules1.errors.txt b/tests/baselines/reference/hybridNodeModules1.errors.txt new file mode 100644 index 0000000000000..69921a8ce1425 --- /dev/null +++ b/tests/baselines/reference/hybridNodeModules1.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/hybridNodeModules1.js b/tests/baselines/reference/hybridNodeModules1.js new file mode 100644 index 0000000000000..03ed212a2f875 --- /dev/null +++ b/tests/baselines/reference/hybridNodeModules1.js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/moduleResolution/hybrid/hybridNodeModules1.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] +"use strict"; +exports.__esModule = true; +//// [main.mjs] +"use strict"; +exports.__esModule = true; +//// [main.cjs] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/hybridNodeModules1.symbols b/tests/baselines/reference/hybridNodeModules1.symbols new file mode 100644 index 0000000000000..d19c2e18f2c4d --- /dev/null +++ b/tests/baselines/reference/hybridNodeModules1.symbols @@ -0,0 +1,23 @@ +=== /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/hybridNodeModules1.trace.json b/tests/baselines/reference/hybridNodeModules1.trace.json new file mode 100644 index 0000000000000..0064397011c9f --- /dev/null +++ b/tests/baselines/reference/hybridNodeModules1.trace.json @@ -0,0 +1,22 @@ +[ + "======== Resolving module 'dual' from '/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "File '/package.json' does not exist.", + "Loading module 'dual' from 'node_modules' folder, target file type 'TypeScript'.", + "Found 'package.json' at '/node_modules/dual/package.json'.", + "'package.json' does not have a 'typesVersions' field.", + "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' exist - use it as a name resolution result.", + "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'. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/hybridNodeModules1.types b/tests/baselines/reference/hybridNodeModules1.types new file mode 100644 index 0000000000000..038aac71d8928 --- /dev/null +++ b/tests/baselines/reference/hybridNodeModules1.types @@ -0,0 +1,23 @@ +=== /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/hybridRelative1.errors.txt b/tests/baselines/reference/hybridRelative1.errors.txt index 2381787fbc254..738eafa19304f 100644 --- a/tests/baselines/reference/hybridRelative1.errors.txt +++ b/tests/baselines/reference/hybridRelative1.errors.txt @@ -1,9 +1,7 @@ -error TS5070: Option '--resolveJsonModule' cannot be specified without 'node' module resolution strategy. /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. -!!! error TS5070: Option '--resolveJsonModule' cannot be specified without 'node' module resolution strategy. ==== /dir/index.ts (0 errors) ==== export const x = 0; diff --git a/tests/baselines/reference/hybridRelative1.trace.json b/tests/baselines/reference/hybridRelative1.trace.json index 75cb1a973184e..77923b457c67a 100644 --- a/tests/baselines/reference/hybridRelative1.trace.json +++ b/tests/baselines/reference/hybridRelative1.trace.json @@ -16,18 +16,12 @@ "======== Resolving module './dir/index.js' from '/main.ts'. ========", "Explicitly specified module resolution kind: 'Hybrid'.", "Loading module as file / folder, candidate module location '/dir/index.js', target file type 'TypeScript'.", - "File '/dir/index.js.ts' does not exist.", - "File '/dir/index.js.tsx' does not exist.", - "File '/dir/index.js.d.ts' does not exist.", "File name '/dir/index.js' has a '.js' extension - stripping it.", "File '/dir/index.ts' exist - 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: 'Hybrid'.", "Loading module as file / folder, candidate module location '/dir/index.ts', target file type 'TypeScript'.", - "File '/dir/index.ts.ts' does not exist.", - "File '/dir/index.ts.tsx' does not exist.", - "File '/dir/index.ts.d.ts' does not exist.", "File name '/dir/index.ts' has a '.ts' extension - stripping it.", "File '/dir/index.ts' exist - use it as a name resolution result.", "======== Module name './dir/index.ts' was successfully resolved to '/dir/index.ts'. ========", diff --git a/tests/baselines/reference/hybridSyntaxRestrictions.symbols b/tests/baselines/reference/hybridSyntaxRestrictions.symbols index d92eb6ffe04b4..5f06564f2a083 100644 --- a/tests/baselines/reference/hybridSyntaxRestrictions.symbols +++ b/tests/baselines/reference/hybridSyntaxRestrictions.symbols @@ -12,6 +12,6 @@ declare var require: (...args: any[]) => any; >args : Symbol(args, Decl(index.d.ts, 0, 22)) === /a.ts === + export {}; -No type information for this code. -No type information for this code. \ No newline at end of file + diff --git a/tests/baselines/reference/hybridSyntaxRestrictions.types b/tests/baselines/reference/hybridSyntaxRestrictions.types index 16066a8493dcc..82fbd016666b3 100644 --- a/tests/baselines/reference/hybridSyntaxRestrictions.types +++ b/tests/baselines/reference/hybridSyntaxRestrictions.types @@ -14,6 +14,6 @@ declare var require: (...args: any[]) => any; >args : any[] === /a.ts === + export {}; -No type information for this code. -No type information for this code. \ No newline at end of file + diff --git a/tests/baselines/reference/moduleResolutionWithExtensions.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions.trace.json index 104853f8aa3f5..6ba563f31c74d 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions.trace.json @@ -7,18 +7,12 @@ "======== Resolving module './a.js' from '/src/d.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module as file / folder, candidate module location '/src/a.js', target file type 'TypeScript'.", - "File '/src/a.js.ts' does not exist.", - "File '/src/a.js.tsx' does not exist.", - "File '/src/a.js.d.ts' does not exist.", "File name '/src/a.js' has a '.js' extension - stripping it.", "File '/src/a.ts' exist - use it as a name resolution result.", "======== Module name './a.js' was successfully resolved to '/src/a.ts'. ========", "======== Resolving module './jquery.js' from '/src/jquery_user_1.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module as file / folder, candidate module location '/src/jquery.js', target file type 'TypeScript'.", - "File '/src/jquery.js.ts' does not exist.", - "File '/src/jquery.js.tsx' does not exist.", - "File '/src/jquery.js.d.ts' does not exist.", "File name '/src/jquery.js' has a '.js' extension - stripping it.", "File '/src/jquery.ts' does not exist.", "File '/src/jquery.tsx' does not exist.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json index 7c988b2ceec64..0dd18e2ff4e91 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json @@ -12,13 +12,13 @@ "File '/node_modules/foo/foo.js' exist - use it as a name resolution result.", "File '/node_modules/foo/foo.js' has an unsupported extension, so skipping it.", "Loading module as file / folder, candidate module location '/node_modules/foo/foo.js', target file type 'TypeScript'.", - "File '/node_modules/foo/foo.js.ts' does not exist.", - "File '/node_modules/foo/foo.js.tsx' does not exist.", - "File '/node_modules/foo/foo.js.d.ts' does not exist.", "File name '/node_modules/foo/foo.js' has a '.js' extension - stripping it.", "File '/node_modules/foo/foo.ts' does not exist.", "File '/node_modules/foo/foo.tsx' does not exist.", "File '/node_modules/foo/foo.d.ts' does not exist.", + "File '/node_modules/foo/foo.js.ts' does not exist.", + "File '/node_modules/foo/foo.js.tsx' does not exist.", + "File '/node_modules/foo/foo.js.d.ts' does not exist.", "Directory '/node_modules/foo/foo.js' does not exist, skipping all lookups in it.", "File '/node_modules/foo/index.ts' does not exist.", "File '/node_modules/foo/index.tsx' does not exist.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_withPaths.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_withPaths.trace.json index 85fa415976b99..5801adea97844 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_withPaths.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_withPaths.trace.json @@ -6,9 +6,6 @@ "Module name 'foo/test.js', matched pattern 'foo/*'.", "Trying substitution 'node_modules/foo/lib/*', candidate module location: 'node_modules/foo/lib/test.js'.", "Loading module as file / folder, candidate module location '/node_modules/foo/lib/test.js', target file type 'TypeScript'.", - "File '/node_modules/foo/lib/test.js.ts' does not exist.", - "File '/node_modules/foo/lib/test.js.tsx' does not exist.", - "File '/node_modules/foo/lib/test.js.d.ts' does not exist.", "File name '/node_modules/foo/lib/test.js' has a '.js' extension - stripping it.", "File '/node_modules/foo/lib/test.ts' does not exist.", "File '/node_modules/foo/lib/test.tsx' does not exist.", @@ -30,9 +27,6 @@ "======== Resolving module './relative.js' from '/test.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module as file / folder, candidate module location '/relative.js', target file type 'TypeScript'.", - "File '/relative.js.ts' does not exist.", - "File '/relative.js.tsx' does not exist.", - "File '/relative.js.d.ts' does not exist.", "File name '/relative.js' has a '.js' extension - stripping it.", "File '/relative.ts' does not exist.", "File '/relative.tsx' does not exist.", diff --git a/tests/baselines/reference/moduleResolutionWithSuffixes_one_externalModule_withPaths.trace.json b/tests/baselines/reference/moduleResolutionWithSuffixes_one_externalModule_withPaths.trace.json index bb8df8b026651..13e30fece8208 100644 --- a/tests/baselines/reference/moduleResolutionWithSuffixes_one_externalModule_withPaths.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSuffixes_one_externalModule_withPaths.trace.json @@ -33,9 +33,6 @@ "Module name 'some-library/index.js', matched pattern 'some-library/*'.", "Trying substitution 'node_modules/some-library/lib/*', candidate module location: 'node_modules/some-library/lib/index.js'.", "Loading module as file / folder, candidate module location '/node_modules/some-library/lib/index.js', target file type 'TypeScript'.", - "File '/node_modules/some-library/lib/index.js.ios.ts' does not exist.", - "File '/node_modules/some-library/lib/index.js.ios.tsx' does not exist.", - "File '/node_modules/some-library/lib/index.js.ios.d.ts' does not exist.", "File name '/node_modules/some-library/lib/index.js' has a '.js' extension - stripping it.", "File '/node_modules/some-library/lib/index.ios.ts' does not exist.", "File '/node_modules/some-library/lib/index.ios.tsx' does not exist.", diff --git a/tests/baselines/reference/moduleResolutionWithSuffixes_one_jsModule.trace.json b/tests/baselines/reference/moduleResolutionWithSuffixes_one_jsModule.trace.json index 473007233e556..943605d358b3b 100644 --- a/tests/baselines/reference/moduleResolutionWithSuffixes_one_jsModule.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSuffixes_one_jsModule.trace.json @@ -2,17 +2,15 @@ "======== Resolving module './foo.js' from '/index.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module as file / folder, candidate module location '/foo.js', target file type 'TypeScript'.", - "File '/foo.js.ios.ts' does not exist.", - "File '/foo.js.ios.tsx' does not exist.", - "File '/foo.js.ios.d.ts' does not exist.", "File name '/foo.js' has a '.js' extension - stripping it.", "File '/foo.ios.ts' does not exist.", "File '/foo.ios.tsx' does not exist.", "File '/foo.ios.d.ts' does not exist.", + "File '/foo.js.ios.ts' does not exist.", + "File '/foo.js.ios.tsx' does not exist.", + "File '/foo.js.ios.d.ts' does not exist.", "Directory '/foo.js' does not exist, skipping all lookups in it.", "Loading module as file / folder, candidate module location '/foo.js', target file type 'JavaScript'.", - "File '/foo.js.ios.js' does not exist.", - "File '/foo.js.ios.jsx' does not exist.", "File name '/foo.js' has a '.js' extension - stripping it.", "File '/foo.ios.js' exist - use it as a name resolution result.", "======== Module name './foo.js' was successfully resolved to '/foo.ios.js'. ========" diff --git a/tests/baselines/reference/moduleResolutionWithSuffixes_one_jsonModule.trace.json b/tests/baselines/reference/moduleResolutionWithSuffixes_one_jsonModule.trace.json index ed1b58abf25e5..c0a4ed04d5a6a 100644 --- a/tests/baselines/reference/moduleResolutionWithSuffixes_one_jsonModule.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSuffixes_one_jsonModule.trace.json @@ -2,15 +2,13 @@ "======== Resolving module './foo.json' from '/index.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module as file / folder, candidate module location '/foo.json', target file type 'TypeScript'.", + "File name '/foo.json' has a '.json' extension - stripping it.", + "File '/foo.json.ios.d.ts' does not exist.", "File '/foo.json.ios.ts' does not exist.", "File '/foo.json.ios.tsx' does not exist.", "File '/foo.json.ios.d.ts' does not exist.", - "File name '/foo.json' has a '.json' extension - stripping it.", - "File '/foo.json.ios.d.ts' does not exist.", "Directory '/foo.json' does not exist, skipping all lookups in it.", "Loading module as file / folder, candidate module location '/foo.json', target file type 'JavaScript'.", - "File '/foo.json.ios.js' does not exist.", - "File '/foo.json.ios.jsx' does not exist.", "File name '/foo.json' has a '.json' extension - stripping it.", "File '/foo.ios.json' exist - use it as a name resolution result.", "======== Module name './foo.json' was successfully resolved to '/foo.ios.json'. ========" diff --git a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json index cf2b1082bf88f..7b4a32446f05f 100644 --- a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json +++ b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_mainFieldInSubDirectory.trace.json @@ -12,9 +12,6 @@ "'package.json' has 'main' field 'src/index.js' that references '/node_modules/foo/src/index.js'.", "File '/node_modules/foo/src/index.js' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/foo/src/index.js', target file type 'TypeScript'.", - "File '/node_modules/foo/src/index.js.ts' does not exist.", - "File '/node_modules/foo/src/index.js.tsx' does not exist.", - "File '/node_modules/foo/src/index.js.d.ts' does not exist.", "File name '/node_modules/foo/src/index.js' has a '.js' extension - stripping it.", "File '/node_modules/foo/src/index.ts' does not exist.", "File '/node_modules/foo/src/index.tsx' does not exist.", diff --git a/tests/baselines/reference/packageJsonMain.trace.json b/tests/baselines/reference/packageJsonMain.trace.json index e5ae23f1d011a..3047b8a92325a 100644 --- a/tests/baselines/reference/packageJsonMain.trace.json +++ b/tests/baselines/reference/packageJsonMain.trace.json @@ -44,13 +44,13 @@ "File '/node_modules/bar/rab.js' exist - use it as a name resolution result.", "File '/node_modules/bar/rab.js' has an unsupported extension, so skipping it.", "Loading module as file / folder, candidate module location '/node_modules/bar/rab.js', target file type 'TypeScript'.", - "File '/node_modules/bar/rab.js.ts' does not exist.", - "File '/node_modules/bar/rab.js.tsx' does not exist.", - "File '/node_modules/bar/rab.js.d.ts' does not exist.", "File name '/node_modules/bar/rab.js' has a '.js' extension - stripping it.", "File '/node_modules/bar/rab.ts' does not exist.", "File '/node_modules/bar/rab.tsx' does not exist.", "File '/node_modules/bar/rab.d.ts' does not exist.", + "File '/node_modules/bar/rab.js.ts' does not exist.", + "File '/node_modules/bar/rab.js.tsx' does not exist.", + "File '/node_modules/bar/rab.js.d.ts' does not exist.", "Directory '/node_modules/bar/rab.js' does not exist, skipping all lookups in it.", "File '/node_modules/bar/index.ts' does not exist.", "File '/node_modules/bar/index.tsx' does not exist.", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtensionInName.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtensionInName.trace.json index c23f61c1c3e2c..ae357af395c40 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtensionInName.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtensionInName.trace.json @@ -6,13 +6,13 @@ "Module name 'zone.js', matched pattern '*'.", "Trying substitution 'foo/*', candidate module location: 'foo/zone.js'.", "Loading module as file / folder, candidate module location '/foo/zone.js', target file type 'TypeScript'.", - "File '/foo/zone.js.ts' does not exist.", - "File '/foo/zone.js.tsx' does not exist.", - "File '/foo/zone.js.d.ts' does not exist.", "File name '/foo/zone.js' has a '.js' extension - stripping it.", "File '/foo/zone.ts' does not exist.", "File '/foo/zone.tsx' does not exist.", "File '/foo/zone.d.ts' does not exist.", + "File '/foo/zone.js.ts' does not exist.", + "File '/foo/zone.js.tsx' does not exist.", + "File '/foo/zone.js.d.ts' does not exist.", "File '/foo/zone.js/package.json' does not exist.", "File '/foo/zone.js/index.ts' does not exist.", "File '/foo/zone.js/index.tsx' does not exist.", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.trace.json index 2597e6ac2eb84..8dc54639e8c5c 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.trace.json @@ -6,25 +6,25 @@ "Module name 'foo/bar/foobar.js', matched pattern '*'.", "Trying substitution 'node_modules/*', candidate module location: 'node_modules/foo/bar/foobar.js'.", "Loading module as file / folder, candidate module location '/node_modules/foo/bar/foobar.js', target file type 'TypeScript'.", - "File '/node_modules/foo/bar/foobar.js.ts' does not exist.", - "File '/node_modules/foo/bar/foobar.js.tsx' does not exist.", - "File '/node_modules/foo/bar/foobar.js.d.ts' does not exist.", "File name '/node_modules/foo/bar/foobar.js' has a '.js' extension - stripping it.", "File '/node_modules/foo/bar/foobar.ts' does not exist.", "File '/node_modules/foo/bar/foobar.tsx' does not exist.", "File '/node_modules/foo/bar/foobar.d.ts' does not exist.", + "File '/node_modules/foo/bar/foobar.js.ts' does not exist.", + "File '/node_modules/foo/bar/foobar.js.tsx' does not exist.", + "File '/node_modules/foo/bar/foobar.js.d.ts' does not exist.", "Directory '/node_modules/foo/bar/foobar.js' does not exist, skipping all lookups in it.", "Trying substitution 'src/types', candidate module location: 'src/types'.", "Loading module as file / folder, candidate module location '/src/types', target file type 'TypeScript'.", "Loading module 'foo/bar/foobar.js' from 'node_modules' folder, target file type 'TypeScript'.", "File '/node_modules/foo/package.json' does not exist.", - "File '/node_modules/foo/bar/foobar.js.ts' does not exist.", - "File '/node_modules/foo/bar/foobar.js.tsx' does not exist.", - "File '/node_modules/foo/bar/foobar.js.d.ts' does not exist.", "File name '/node_modules/foo/bar/foobar.js' has a '.js' extension - stripping it.", "File '/node_modules/foo/bar/foobar.ts' does not exist.", "File '/node_modules/foo/bar/foobar.tsx' does not exist.", "File '/node_modules/foo/bar/foobar.d.ts' does not exist.", + "File '/node_modules/foo/bar/foobar.js.ts' does not exist.", + "File '/node_modules/foo/bar/foobar.js.tsx' does not exist.", + "File '/node_modules/foo/bar/foobar.js.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "File name '/node_modules/@types/foo/bar/foobar.js' has a '.js' extension - stripping it.", "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo/bar/foobar.js'.", @@ -32,8 +32,6 @@ "Module name 'foo/bar/foobar.js', matched pattern '*'.", "Trying substitution 'node_modules/*', candidate module location: 'node_modules/foo/bar/foobar.js'.", "Loading module as file / folder, candidate module location '/node_modules/foo/bar/foobar.js', target file type 'JavaScript'.", - "File '/node_modules/foo/bar/foobar.js.js' does not exist.", - "File '/node_modules/foo/bar/foobar.js.jsx' does not exist.", "File name '/node_modules/foo/bar/foobar.js' has a '.js' extension - stripping it.", "File '/node_modules/foo/bar/foobar.js' exist - use it as a name resolution result.", "File '/node_modules/foo/package.json' does not exist according to earlier cached lookups.", diff --git a/tests/baselines/reference/requireOfJsonFile_PathMapping.trace.json b/tests/baselines/reference/requireOfJsonFile_PathMapping.trace.json index e13cc91a3da29..8744a83f6b5a1 100644 --- a/tests/baselines/reference/requireOfJsonFile_PathMapping.trace.json +++ b/tests/baselines/reference/requireOfJsonFile_PathMapping.trace.json @@ -6,21 +6,21 @@ "Module name 'foo/bar/foobar.json', matched pattern '*'.", "Trying substitution 'node_modules/*', candidate module location: 'node_modules/foo/bar/foobar.json'.", "Loading module as file / folder, candidate module location '/node_modules/foo/bar/foobar.json', target file type 'TypeScript'.", + "File name '/node_modules/foo/bar/foobar.json' has a '.json' extension - stripping it.", + "File '/node_modules/foo/bar/foobar.json.d.ts' does not exist.", "File '/node_modules/foo/bar/foobar.json.ts' does not exist.", "File '/node_modules/foo/bar/foobar.json.tsx' does not exist.", "File '/node_modules/foo/bar/foobar.json.d.ts' does not exist.", - "File name '/node_modules/foo/bar/foobar.json' has a '.json' extension - stripping it.", - "File '/node_modules/foo/bar/foobar.json.d.ts' does not exist.", "Directory '/node_modules/foo/bar/foobar.json' does not exist, skipping all lookups in it.", "Trying substitution 'src/types', candidate module location: 'src/types'.", "Loading module as file / folder, candidate module location '/src/types', target file type 'TypeScript'.", "Loading module 'foo/bar/foobar.json' from 'node_modules' folder, target file type 'TypeScript'.", "File '/node_modules/foo/package.json' does not exist.", + "File name '/node_modules/foo/bar/foobar.json' has a '.json' extension - stripping it.", + "File '/node_modules/foo/bar/foobar.json.d.ts' does not exist.", "File '/node_modules/foo/bar/foobar.json.ts' does not exist.", "File '/node_modules/foo/bar/foobar.json.tsx' does not exist.", "File '/node_modules/foo/bar/foobar.json.d.ts' does not exist.", - "File name '/node_modules/foo/bar/foobar.json' has a '.json' extension - stripping it.", - "File '/node_modules/foo/bar/foobar.json.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "File name '/node_modules/@types/foo/bar/foobar.json' has a '.json' extension - stripping it.", "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo/bar/foobar.json'.", @@ -28,8 +28,6 @@ "Module name 'foo/bar/foobar.json', matched pattern '*'.", "Trying substitution 'node_modules/*', candidate module location: 'node_modules/foo/bar/foobar.json'.", "Loading module as file / folder, candidate module location '/node_modules/foo/bar/foobar.json', target file type 'JavaScript'.", - "File '/node_modules/foo/bar/foobar.json.js' does not exist.", - "File '/node_modules/foo/bar/foobar.json.jsx' does not exist.", "File name '/node_modules/foo/bar/foobar.json' has a '.json' extension - stripping it.", "File '/node_modules/foo/bar/foobar.json' exist - use it as a name resolution result.", "File '/node_modules/foo/package.json' does not exist according to earlier cached lookups.", diff --git a/tests/baselines/reference/tsbuild/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-preserveSymlinks.js b/tests/baselines/reference/tsbuild/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-preserveSymlinks.js index 7b22f14418075..341ad7d5c6f1c 100644 --- a/tests/baselines/reference/tsbuild/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-preserveSymlinks.js +++ b/tests/baselines/reference/tsbuild/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-preserveSymlinks.js @@ -70,9 +70,6 @@ File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result. File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it. Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist. File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. diff --git a/tests/baselines/reference/tsbuild/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly.js b/tests/baselines/reference/tsbuild/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly.js index 9f0d8d6ff0532..abfe669f3dabe 100644 --- a/tests/baselines/reference/tsbuild/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly.js +++ b/tests/baselines/reference/tsbuild/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly.js @@ -70,9 +70,6 @@ File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result. File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it. Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist. File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. diff --git a/tests/baselines/reference/tsbuildWatch/moduleResolution/build-mode-watches-for-changes-to-package-json-main-fields.js b/tests/baselines/reference/tsbuildWatch/moduleResolution/build-mode-watches-for-changes-to-package-json-main-fields.js index f56626112030d..a83b038320a17 100644 --- a/tests/baselines/reference/tsbuildWatch/moduleResolution/build-mode-watches-for-changes-to-package-json-main-fields.js +++ b/tests/baselines/reference/tsbuildWatch/moduleResolution/build-mode-watches-for-changes-to-package-json-main-fields.js @@ -55,9 +55,6 @@ Output:: ======== Resolving module './const.js' from '/user/username/projects/myproject/packages/pkg2/index.ts'. ======== Module resolution kind is not specified, using 'NodeJs'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/const.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/packages/pkg2/const.js.ts' does not exist. -File '/user/username/projects/myproject/packages/pkg2/const.js.tsx' does not exist. -File '/user/username/projects/myproject/packages/pkg2/const.js.d.ts' does not exist. File name '/user/username/projects/myproject/packages/pkg2/const.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/const.ts' exist - use it as a name resolution result. ======== Module name './const.js' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/const.ts'. ======== @@ -81,9 +78,6 @@ File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result. File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it. Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist. File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. @@ -94,9 +88,6 @@ Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/bui Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. Module resolution kind is not specified, using 'NodeJs'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/packages/pkg2/build/const.js.ts' does not exist. -File '/user/username/projects/myproject/packages/pkg2/build/const.js.tsx' does not exist. -File '/user/username/projects/myproject/packages/pkg2/build/const.js.d.ts' does not exist. File name '/user/username/projects/myproject/packages/pkg2/build/const.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/build/const.ts' does not exist. File '/user/username/projects/myproject/packages/pkg2/build/const.tsx' does not exist. @@ -318,9 +309,6 @@ File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/other.js' exist - use it as a name resolution result. File '/user/username/projects/myproject/node_modules/pkg2/build/other.js' has an unsupported extension, so skipping it. Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/other.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/node_modules/pkg2/build/other.js.ts' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/other.js.tsx' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/other.js.d.ts' does not exist. File name '/user/username/projects/myproject/node_modules/pkg2/build/other.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/node_modules/pkg2/build/other.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/other.tsx' does not exist. @@ -410,9 +398,6 @@ File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result. File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it. Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist. File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. @@ -423,9 +408,6 @@ Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/bui Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. Module resolution kind is not specified, using 'NodeJs'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/packages/pkg2/build/const.js.ts' does not exist. -File '/user/username/projects/myproject/packages/pkg2/build/const.js.tsx' does not exist. -File '/user/username/projects/myproject/packages/pkg2/build/const.js.d.ts' does not exist. File name '/user/username/projects/myproject/packages/pkg2/build/const.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/build/const.ts' does not exist. File '/user/username/projects/myproject/packages/pkg2/build/const.tsx' does not exist. diff --git a/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js b/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js index b6c00656975f4..7859cbeee8291 100644 --- a/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js +++ b/tests/baselines/reference/tsbuildWatch/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js @@ -311,9 +311,6 @@ File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result. File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it. Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist. File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. @@ -538,9 +535,6 @@ File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result. File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it. Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist. File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. @@ -645,9 +639,6 @@ Output:: Module resolution kind is not specified, using 'Node16'. Resolving in CJS mode with conditions 'node', 'require', 'types'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/const.cjs', target file type 'TypeScript'. -File '/user/username/projects/myproject/packages/pkg2/const.cjs.ts' does not exist. -File '/user/username/projects/myproject/packages/pkg2/const.cjs.tsx' does not exist. -File '/user/username/projects/myproject/packages/pkg2/const.cjs.d.ts' does not exist. File name '/user/username/projects/myproject/packages/pkg2/const.cjs' has a '.cjs' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/const.cts' exist - use it as a name resolution result. ======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/const.cts'. ======== @@ -678,9 +669,6 @@ File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.cjs' exist - use it as a name resolution result. File '/user/username/projects/myproject/node_modules/pkg2/build/index.cjs' has an unsupported extension, so skipping it. Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.cjs', target file type 'TypeScript'. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.cjs.ts' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.cjs.tsx' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.cjs.d.ts' does not exist. File name '/user/username/projects/myproject/node_modules/pkg2/build/index.cjs' has a '.cjs' extension - stripping it. File '/user/username/projects/myproject/node_modules/pkg2/build/index.cts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.cts' exist - use it as a name resolution result. @@ -691,9 +679,6 @@ Using compiler options of project reference redirect '/user/username/projects/my Module resolution kind is not specified, using 'Node16'. Resolving in CJS mode with conditions 'node', 'require', 'types'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file type 'TypeScript'. -File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.ts' does not exist. -File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.tsx' does not exist. -File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.d.ts' does not exist. File name '/user/username/projects/myproject/packages/pkg2/build/const.cjs' has a '.cjs' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/build/const.cts' does not exist. File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - use it as a name resolution result. diff --git a/tests/baselines/reference/tsc/declarationEmit/when-same-version-is-referenced-through-source-and-another-symlinked-package-with-indirect-link-moduleCaseChange.js b/tests/baselines/reference/tsc/declarationEmit/when-same-version-is-referenced-through-source-and-another-symlinked-package-with-indirect-link-moduleCaseChange.js index 49ea0557cde35..a3742f5625ac6 100644 --- a/tests/baselines/reference/tsc/declarationEmit/when-same-version-is-referenced-through-source-and-another-symlinked-package-with-indirect-link-moduleCaseChange.js +++ b/tests/baselines/reference/tsc/declarationEmit/when-same-version-is-referenced-through-source-and-another-symlinked-package-with-indirect-link-moduleCaseChange.js @@ -102,9 +102,6 @@ File '/user/username/projects/myproject/plugin-one/node_modules/plugin-two.d.ts' 'package.json' has 'main' field 'dist/commonjs/index.js' that references '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.js'. File '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.js' does not exist. Loading module as file / folder, candidate module location '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.js.ts' does not exist. -File '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.js.tsx' does not exist. -File '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.js.d.ts' does not exist. File name '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.ts' does not exist. File '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.tsx' does not exist. diff --git a/tests/baselines/reference/tsc/declarationEmit/when-same-version-is-referenced-through-source-and-another-symlinked-package-with-indirect-link.js b/tests/baselines/reference/tsc/declarationEmit/when-same-version-is-referenced-through-source-and-another-symlinked-package-with-indirect-link.js index 5a03c9782e184..3c0f60dc3b9f8 100644 --- a/tests/baselines/reference/tsc/declarationEmit/when-same-version-is-referenced-through-source-and-another-symlinked-package-with-indirect-link.js +++ b/tests/baselines/reference/tsc/declarationEmit/when-same-version-is-referenced-through-source-and-another-symlinked-package-with-indirect-link.js @@ -102,9 +102,6 @@ File '/user/username/projects/myproject/plugin-one/node_modules/plugin-two.d.ts' 'package.json' has 'main' field 'dist/commonjs/index.js' that references '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.js'. File '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.js' does not exist. Loading module as file / folder, candidate module location '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.js.ts' does not exist. -File '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.js.tsx' does not exist. -File '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.js.d.ts' does not exist. File name '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.ts' does not exist. File '/user/username/projects/myproject/plugin-one/node_modules/plugin-two/dist/commonjs/index.tsx' does not exist. diff --git a/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js b/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js index 14cf44aff96ae..4186759ac07ed 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js @@ -161,18 +161,18 @@ File '/user/username/projects/myproject/package.json' exists according to earlie Module resolution kind is not specified, using 'Node16'. Resolving in CJS mode with conditions 'node', 'require', 'types'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'TypeScript'. -File '/user/username/projects/myproject/src/fileB.mjs.ts' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mts' does not exist. File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.ts' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'JavaScript'. -File '/user/username/projects/myproject/src/fileB.mjs.js' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs.jsx' does not exist. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mjs' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.js' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.jsx' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. ======== Module name './fileB.mjs' was not resolved. ======== DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/fileB.mjs 1 undefined Failed Lookup Locations @@ -381,18 +381,18 @@ File '/package.json' does not exist according to earlier cached lookups. Module resolution kind is not specified, using 'Node16'. Resolving in CJS mode with conditions 'node', 'require', 'types'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'TypeScript'. -File '/user/username/projects/myproject/src/fileB.mjs.ts' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mts' does not exist. File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.ts' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'JavaScript'. -File '/user/username/projects/myproject/src/fileB.mjs.js' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs.jsx' does not exist. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mjs' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.js' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.jsx' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. ======== Module name './fileB.mjs' was not resolved. ======== DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/fileB.mjs 1 undefined Failed Lookup Locations diff --git a/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited.js b/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited.js index 8144af275245e..5ac2efe576b13 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited.js @@ -47,18 +47,18 @@ FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/fileA.ts Module resolution kind is not specified, using 'Node16'. Resolving in CJS mode with conditions 'node', 'require', 'types'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'TypeScript'. -File '/user/username/projects/myproject/src/fileB.mjs.ts' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mts' does not exist. File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.ts' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'JavaScript'. -File '/user/username/projects/myproject/src/fileB.mjs.js' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs.jsx' does not exist. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mjs' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.js' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.jsx' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. ======== Module name './fileB.mjs' was not resolved. ======== DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/fileB.mjs 1 undefined Failed Lookup Locations @@ -275,18 +275,18 @@ File '/user/username/projects/myproject/package.json' exists according to earlie Module resolution kind is not specified, using 'Node16'. Resolving in CJS mode with conditions 'node', 'require', 'types'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'TypeScript'. -File '/user/username/projects/myproject/src/fileB.mjs.ts' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mts' does not exist. File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.ts' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'JavaScript'. -File '/user/username/projects/myproject/src/fileB.mjs.js' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs.jsx' does not exist. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mjs' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.js' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.jsx' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. ======== Module name './fileB.mjs' was not resolved. ======== DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/fileB.mjs 1 undefined Failed Lookup Locations @@ -588,18 +588,18 @@ File '/package.json' does not exist according to earlier cached lookups. Module resolution kind is not specified, using 'Node16'. Resolving in CJS mode with conditions 'node', 'require', 'types'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'TypeScript'. -File '/user/username/projects/myproject/src/fileB.mjs.ts' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mts' does not exist. File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.ts' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'JavaScript'. -File '/user/username/projects/myproject/src/fileB.mjs.js' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs.jsx' does not exist. File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. File '/user/username/projects/myproject/src/fileB.mjs' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.js' does not exist. +File '/user/username/projects/myproject/src/fileB.mjs.jsx' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. ======== Module name './fileB.mjs' was not resolved. ======== DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/fileB.mjs 1 undefined Failed Lookup Locations diff --git a/tests/baselines/reference/tscWatch/moduleResolution/watches-for-changes-to-package-json-main-fields.js b/tests/baselines/reference/tscWatch/moduleResolution/watches-for-changes-to-package-json-main-fields.js index 93c3f3fcb4802..692ee22aaf07e 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/watches-for-changes-to-package-json-main-fields.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/watches-for-changes-to-package-json-main-fields.js @@ -56,9 +56,6 @@ File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. 'package.json' has 'main' field 'build/index.js' that references '/user/username/projects/myproject/node_modules/pkg2/build/index.js'. File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' does not exist. Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist. File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. @@ -68,9 +65,6 @@ Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/bui ======== Resolving module './const.js' from '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== Module resolution kind is not specified, using 'NodeJs'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/packages/pkg2/build/const.js.ts' does not exist. -File '/user/username/projects/myproject/packages/pkg2/build/const.js.tsx' does not exist. -File '/user/username/projects/myproject/packages/pkg2/build/const.js.d.ts' does not exist. File name '/user/username/projects/myproject/packages/pkg2/build/const.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/build/const.ts' does not exist. File '/user/username/projects/myproject/packages/pkg2/build/const.tsx' does not exist. @@ -171,9 +165,6 @@ File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. 'package.json' has 'main' field 'build/other.js' that references '/user/username/projects/myproject/node_modules/pkg2/build/other.js'. File '/user/username/projects/myproject/node_modules/pkg2/build/other.js' does not exist. Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/other.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/node_modules/pkg2/build/other.js.ts' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/other.js.tsx' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/other.js.d.ts' does not exist. File name '/user/username/projects/myproject/node_modules/pkg2/build/other.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/node_modules/pkg2/build/other.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/other.tsx' does not exist. @@ -265,9 +256,6 @@ File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. 'package.json' has 'main' field 'build/index.js' that references '/user/username/projects/myproject/node_modules/pkg2/build/index.js'. File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' does not exist. Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist. -File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist. File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist. File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. @@ -277,9 +265,6 @@ Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/bui ======== Resolving module './const.js' from '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== Module resolution kind is not specified, using 'NodeJs'. Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.js', target file type 'TypeScript'. -File '/user/username/projects/myproject/packages/pkg2/build/const.js.ts' does not exist. -File '/user/username/projects/myproject/packages/pkg2/build/const.js.tsx' does not exist. -File '/user/username/projects/myproject/packages/pkg2/build/const.js.d.ts' does not exist. File name '/user/username/projects/myproject/packages/pkg2/build/const.js' has a '.js' extension - stripping it. File '/user/username/projects/myproject/packages/pkg2/build/const.ts' does not exist. File '/user/username/projects/myproject/packages/pkg2/build/const.tsx' does not exist. diff --git a/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js b/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js index 79b1043dc47be..aea638ed4f748 100644 --- a/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js +++ b/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js @@ -246,38 +246,33 @@ Info 60 [00:01:36.000] ======== Resolving module './fileB.mjs' from '/user/use Info 61 [00:01:37.000] Module resolution kind is not specified, using 'Node16'. Info 62 [00:01:38.000] Resolving in CJS mode with conditions 'node', 'require', 'types'. Info 63 [00:01:39.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'TypeScript'. -Info 64 [00:01:40.000] File '/user/username/projects/myproject/src/fileB.mjs.ts' does not exist. -Info 65 [00:01:41.000] File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. -Info 66 [00:01:42.000] File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. -Info 67 [00:01:43.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. -Info 68 [00:01:44.000] File '/user/username/projects/myproject/src/fileB.mts' exist - use it as a name resolution result. -Info 69 [00:01:45.000] ======== Module name './fileB.mjs' was successfully resolved to '/user/username/projects/myproject/src/fileB.mts'. ======== -Info 70 [00:01:46.000] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src 0 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations -Info 71 [00:01:47.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src 0 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations -Info 72 [00:01:48.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 73 [00:01:49.000] File '/a/package.json' does not exist according to earlier cached lookups. -Info 74 [00:01:50.000] File '/package.json' does not exist according to earlier cached lookups. -Info 75 [00:01:51.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 2 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms -Info 76 [00:01:52.000] Different program with same set of files -Info 77 [00:01:53.000] Running: *ensureProjectForOpenFiles* -Info 78 [00:01:54.000] Before ensureProjectForOpenFiles: -Info 79 [00:01:55.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 79 [00:01:56.000] Files (3) - -Info 79 [00:01:57.000] ----------------------------------------------- -Info 79 [00:01:58.000] Open files: -Info 79 [00:01:59.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 79 [00:02:00.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 79 [00:02:01.000] After ensureProjectForOpenFiles: -Info 80 [00:02:02.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 80 [00:02:03.000] Files (3) - -Info 80 [00:02:04.000] ----------------------------------------------- -Info 80 [00:02:05.000] Open files: -Info 80 [00:02:06.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 80 [00:02:07.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 80 [00:02:08.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts -Info 81 [00:02:09.000] event: +Info 64 [00:01:40.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. +Info 65 [00:01:41.000] File '/user/username/projects/myproject/src/fileB.mts' exist - use it as a name resolution result. +Info 66 [00:01:42.000] ======== Module name './fileB.mjs' was successfully resolved to '/user/username/projects/myproject/src/fileB.mts'. ======== +Info 67 [00:01:43.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 68 [00:01:44.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 69 [00:01:45.000] File '/package.json' does not exist according to earlier cached lookups. +Info 70 [00:01:46.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 2 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms +Info 71 [00:01:47.000] Different program with same set of files +Info 72 [00:01:48.000] Running: *ensureProjectForOpenFiles* +Info 73 [00:01:49.000] Before ensureProjectForOpenFiles: +Info 74 [00:01:50.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 74 [00:01:51.000] Files (3) + +Info 74 [00:01:52.000] ----------------------------------------------- +Info 74 [00:01:53.000] Open files: +Info 74 [00:01:54.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 74 [00:01:55.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 74 [00:01:56.000] After ensureProjectForOpenFiles: +Info 75 [00:01:57.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 75 [00:01:58.000] Files (3) + +Info 75 [00:01:59.000] ----------------------------------------------- +Info 75 [00:02:00.000] Open files: +Info 75 [00:02:01.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 75 [00:02:02.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 75 [00:02:03.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts +Info 76 [00:02:04.000] event: {"seq":0,"type":"event","event":"projectsUpdatedInBackground","body":{"openFiles":["/user/username/projects/myproject/src/fileA.ts"]}} After running timeout callbacks @@ -298,14 +293,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 82 [00:02:10.000] request: +Info 77 [00:02:05.000] request: { "command": "geterr", "arguments": { @@ -336,8 +329,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -362,14 +353,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 83 [00:02:11.000] response: +Info 78 [00:02:06.000] response: { "responseRequired": false } @@ -392,14 +381,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 84 [00:02:12.000] event: +Info 79 [00:02:07.000] event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} After checking timeout queue length (1) and running @@ -420,8 +407,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -446,14 +431,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 85 [00:02:13.000] event: +Info 80 [00:02:08.000] event: {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.\n To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","code":1479,"category":"error"}]}} Before running immediate callbacks and checking length (1) @@ -474,8 +457,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -500,16 +481,14 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 86 [00:02:14.000] event: +Info 81 [00:02:09.000] event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} -Info 87 [00:02:15.000] event: +Info 82 [00:02:10.000] event: {"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":1}} Before running immediate callbacks and checking length (1) @@ -530,19 +509,17 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 88 [00:02:16.000] Modify package json file to add type module -Info 89 [00:02:20.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 90 [00:02:21.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 91 [00:02:22.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 92 [00:02:23.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file -Info 93 [00:02:24.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file +Info 83 [00:02:11.000] Modify package json file to add type module +Info 84 [00:02:15.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 85 [00:02:16.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 86 [00:02:17.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 87 [00:02:18.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file +Info 88 [00:02:19.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file Before running timeout callbacks //// [/user/username/projects/myproject/package.json] {"name":"app","version":"1.0.0","type":"module"} @@ -565,16 +542,14 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 94 [00:02:25.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 95 [00:02:26.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json -Info 96 [00:02:27.000] Scheduled: *ensureProjectForOpenFiles* +Info 89 [00:02:20.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 90 [00:02:21.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json +Info 91 [00:02:22.000] Scheduled: *ensureProjectForOpenFiles* After running timeout callbacks PolledWatches:: @@ -594,8 +569,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -620,56 +593,52 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 97 [00:02:28.000] Running: /user/username/projects/myproject/src/tsconfig.json -Info 98 [00:02:29.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json -Info 99 [00:02:30.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 100 [00:02:31.000] File '/a/package.json' does not exist according to earlier cached lookups. -Info 101 [00:02:32.000] File '/package.json' does not exist according to earlier cached lookups. -Info 102 [00:02:33.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 103 [00:02:34.000] Found 'package.json' at '/user/username/projects/myproject/package.json'. -Info 104 [00:02:35.000] 'package.json' does not have a 'typesVersions' field. -Info 105 [00:02:36.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 106 [00:02:37.000] File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. -Info 107 [00:02:38.000] ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== -Info 108 [00:02:39.000] Module resolution kind is not specified, using 'Node16'. -Info 109 [00:02:40.000] Resolving in ESM mode with conditions 'node', 'import', 'types'. -Info 110 [00:02:41.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'TypeScript'. -Info 111 [00:02:42.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. -Info 112 [00:02:43.000] File '/user/username/projects/myproject/src/fileB.mts' exist - use it as a name resolution result. -Info 113 [00:02:44.000] ======== Module name './fileB.mjs' was successfully resolved to '/user/username/projects/myproject/src/fileB.mts'. ======== -Info 114 [00:02:45.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 115 [00:02:46.000] File '/a/package.json' does not exist according to earlier cached lookups. -Info 116 [00:02:47.000] File '/package.json' does not exist according to earlier cached lookups. -Info 117 [00:02:48.000] DirectoryWatcher:: Close:: WatchInfo: /user/username/projects/myproject/src 0 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations -Info 118 [00:02:49.000] Elapsed:: *ms DirectoryWatcher:: Close:: WatchInfo: /user/username/projects/myproject/src 0 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations -Info 119 [00:02:50.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 3 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms -Info 120 [00:02:51.000] Different program with same set of files -Info 121 [00:02:52.000] Running: *ensureProjectForOpenFiles* -Info 122 [00:02:53.000] Before ensureProjectForOpenFiles: -Info 123 [00:02:54.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 123 [00:02:55.000] Files (3) - -Info 123 [00:02:56.000] ----------------------------------------------- -Info 123 [00:02:57.000] Open files: -Info 123 [00:02:58.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 123 [00:02:59.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 123 [00:03:00.000] After ensureProjectForOpenFiles: -Info 124 [00:03:01.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 124 [00:03:02.000] Files (3) - -Info 124 [00:03:03.000] ----------------------------------------------- -Info 124 [00:03:04.000] Open files: -Info 124 [00:03:05.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 124 [00:03:06.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 124 [00:03:07.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts -Info 125 [00:03:08.000] event: +Info 92 [00:02:23.000] Running: /user/username/projects/myproject/src/tsconfig.json +Info 93 [00:02:24.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json +Info 94 [00:02:25.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 95 [00:02:26.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 96 [00:02:27.000] File '/package.json' does not exist according to earlier cached lookups. +Info 97 [00:02:28.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 98 [00:02:29.000] Found 'package.json' at '/user/username/projects/myproject/package.json'. +Info 99 [00:02:30.000] 'package.json' does not have a 'typesVersions' field. +Info 100 [00:02:31.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 101 [00:02:32.000] File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. +Info 102 [00:02:33.000] ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== +Info 103 [00:02:34.000] Module resolution kind is not specified, using 'Node16'. +Info 104 [00:02:35.000] Resolving in ESM mode with conditions 'node', 'import', 'types'. +Info 105 [00:02:36.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'TypeScript'. +Info 106 [00:02:37.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. +Info 107 [00:02:38.000] File '/user/username/projects/myproject/src/fileB.mts' exist - use it as a name resolution result. +Info 108 [00:02:39.000] ======== Module name './fileB.mjs' was successfully resolved to '/user/username/projects/myproject/src/fileB.mts'. ======== +Info 109 [00:02:40.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 110 [00:02:41.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 111 [00:02:42.000] File '/package.json' does not exist according to earlier cached lookups. +Info 112 [00:02:43.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 3 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms +Info 113 [00:02:44.000] Different program with same set of files +Info 114 [00:02:45.000] Running: *ensureProjectForOpenFiles* +Info 115 [00:02:46.000] Before ensureProjectForOpenFiles: +Info 116 [00:02:47.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 116 [00:02:48.000] Files (3) + +Info 116 [00:02:49.000] ----------------------------------------------- +Info 116 [00:02:50.000] Open files: +Info 116 [00:02:51.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 116 [00:02:52.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 116 [00:02:53.000] After ensureProjectForOpenFiles: +Info 117 [00:02:54.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 117 [00:02:55.000] Files (3) + +Info 117 [00:02:56.000] ----------------------------------------------- +Info 117 [00:02:57.000] Open files: +Info 117 [00:02:58.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 117 [00:02:59.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 117 [00:03:00.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts +Info 118 [00:03:01.000] event: {"seq":0,"type":"event","event":"projectsUpdatedInBackground","body":{"openFiles":["/user/username/projects/myproject/src/fileA.ts"]}} After running timeout callbacks @@ -695,7 +664,7 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 126 [00:03:09.000] request: +Info 119 [00:03:02.000] request: { "command": "geterr", "arguments": { @@ -755,7 +724,7 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 127 [00:03:10.000] response: +Info 120 [00:03:03.000] response: { "responseRequired": false } @@ -783,7 +752,7 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 128 [00:03:11.000] event: +Info 121 [00:03:04.000] event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} After checking timeout queue length (1) and running @@ -833,7 +802,7 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 129 [00:03:12.000] event: +Info 122 [00:03:05.000] event: {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} Before running immediate callbacks and checking length (1) @@ -883,9 +852,9 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 130 [00:03:13.000] event: +Info 123 [00:03:06.000] event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} -Info 131 [00:03:14.000] event: +Info 124 [00:03:07.000] event: {"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":2}} Before running immediate callbacks and checking length (1) @@ -911,13 +880,13 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 132 [00:03:15.000] Delete package.json -Info 133 [00:03:17.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 134 [00:03:18.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 135 [00:03:19.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 136 [00:03:20.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file -Info 137 [00:03:21.000] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file -Info 138 [00:03:22.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file +Info 125 [00:03:08.000] Delete package.json +Info 126 [00:03:10.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 127 [00:03:11.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 128 [00:03:12.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 129 [00:03:13.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file +Info 130 [00:03:14.000] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file +Info 131 [00:03:15.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file Before running timeout callbacks //// [/user/username/projects/myproject/package.json] deleted @@ -943,9 +912,9 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 139 [00:03:23.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 140 [00:03:24.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json -Info 141 [00:03:25.000] Scheduled: *ensureProjectForOpenFiles* +Info 132 [00:03:16.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 133 [00:03:17.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json +Info 134 [00:03:18.000] Scheduled: *ensureProjectForOpenFiles* After running timeout callbacks PolledWatches:: @@ -994,48 +963,48 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 142 [00:03:26.000] Running: /user/username/projects/myproject/src/tsconfig.json -Info 143 [00:03:27.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json -Info 144 [00:03:28.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 145 [00:03:29.000] File '/a/package.json' does not exist according to earlier cached lookups. -Info 146 [00:03:30.000] File '/package.json' does not exist according to earlier cached lookups. -Info 147 [00:03:31.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 148 [00:03:32.000] File '/user/username/projects/myproject/package.json' does not exist. -Info 149 [00:03:33.000] File '/user/username/projects/package.json' does not exist. -Info 150 [00:03:34.000] File '/user/username/package.json' does not exist. -Info 151 [00:03:35.000] File '/user/package.json' does not exist. -Info 152 [00:03:36.000] File '/package.json' does not exist according to earlier cached lookups. -Info 153 [00:03:37.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 154 [00:03:38.000] File '/user/username/projects/myproject/package.json' does not exist according to earlier cached lookups. -Info 155 [00:03:39.000] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. -Info 156 [00:03:40.000] File '/user/username/package.json' does not exist according to earlier cached lookups. -Info 157 [00:03:41.000] File '/user/package.json' does not exist according to earlier cached lookups. -Info 158 [00:03:42.000] File '/package.json' does not exist according to earlier cached lookups. -Info 159 [00:03:43.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 160 [00:03:44.000] File '/a/package.json' does not exist according to earlier cached lookups. -Info 161 [00:03:45.000] File '/package.json' does not exist according to earlier cached lookups. -Info 162 [00:03:46.000] FileWatcher:: Added:: WatchInfo: /user/username/projects/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 163 [00:03:47.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 4 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms -Info 164 [00:03:48.000] Different program with same set of files -Info 165 [00:03:49.000] Running: *ensureProjectForOpenFiles* -Info 166 [00:03:50.000] Before ensureProjectForOpenFiles: -Info 167 [00:03:51.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 167 [00:03:52.000] Files (3) - -Info 167 [00:03:53.000] ----------------------------------------------- -Info 167 [00:03:54.000] Open files: -Info 167 [00:03:55.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 167 [00:03:56.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 167 [00:03:57.000] After ensureProjectForOpenFiles: -Info 168 [00:03:58.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 168 [00:03:59.000] Files (3) - -Info 168 [00:04:00.000] ----------------------------------------------- -Info 168 [00:04:01.000] Open files: -Info 168 [00:04:02.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 168 [00:04:03.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 168 [00:04:04.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts -Info 169 [00:04:05.000] event: +Info 135 [00:03:19.000] Running: /user/username/projects/myproject/src/tsconfig.json +Info 136 [00:03:20.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json +Info 137 [00:03:21.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 138 [00:03:22.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 139 [00:03:23.000] File '/package.json' does not exist according to earlier cached lookups. +Info 140 [00:03:24.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 141 [00:03:25.000] File '/user/username/projects/myproject/package.json' does not exist. +Info 142 [00:03:26.000] File '/user/username/projects/package.json' does not exist. +Info 143 [00:03:27.000] File '/user/username/package.json' does not exist. +Info 144 [00:03:28.000] File '/user/package.json' does not exist. +Info 145 [00:03:29.000] File '/package.json' does not exist according to earlier cached lookups. +Info 146 [00:03:30.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 147 [00:03:31.000] File '/user/username/projects/myproject/package.json' does not exist according to earlier cached lookups. +Info 148 [00:03:32.000] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. +Info 149 [00:03:33.000] File '/user/username/package.json' does not exist according to earlier cached lookups. +Info 150 [00:03:34.000] File '/user/package.json' does not exist according to earlier cached lookups. +Info 151 [00:03:35.000] File '/package.json' does not exist according to earlier cached lookups. +Info 152 [00:03:36.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 153 [00:03:37.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 154 [00:03:38.000] File '/package.json' does not exist according to earlier cached lookups. +Info 155 [00:03:39.000] FileWatcher:: Added:: WatchInfo: /user/username/projects/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 156 [00:03:40.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 4 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms +Info 157 [00:03:41.000] Different program with same set of files +Info 158 [00:03:42.000] Running: *ensureProjectForOpenFiles* +Info 159 [00:03:43.000] Before ensureProjectForOpenFiles: +Info 160 [00:03:44.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 160 [00:03:45.000] Files (3) + +Info 160 [00:03:46.000] ----------------------------------------------- +Info 160 [00:03:47.000] Open files: +Info 160 [00:03:48.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 160 [00:03:49.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 160 [00:03:50.000] After ensureProjectForOpenFiles: +Info 161 [00:03:51.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 161 [00:03:52.000] Files (3) + +Info 161 [00:03:53.000] ----------------------------------------------- +Info 161 [00:03:54.000] Open files: +Info 161 [00:03:55.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 161 [00:03:56.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 161 [00:03:57.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts +Info 162 [00:03:58.000] event: {"seq":0,"type":"event","event":"projectsUpdatedInBackground","body":{"openFiles":["/user/username/projects/myproject/src/fileA.ts"]}} After running timeout callbacks @@ -1063,7 +1032,7 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 170 [00:04:06.000] request: +Info 163 [00:03:59.000] request: { "command": "geterr", "arguments": { @@ -1127,7 +1096,7 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 171 [00:04:07.000] response: +Info 164 [00:04:00.000] response: { "responseRequired": false } @@ -1157,7 +1126,7 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 172 [00:04:08.000] event: +Info 165 [00:04:01.000] event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} After checking timeout queue length (1) and running @@ -1211,7 +1180,7 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 173 [00:04:09.000] event: +Info 166 [00:04:02.000] event: {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.\n To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","code":1479,"category":"error"}]}} Before running immediate callbacks and checking length (1) @@ -1265,9 +1234,9 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 174 [00:04:10.000] event: +Info 167 [00:04:03.000] event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} -Info 175 [00:04:11.000] event: +Info 168 [00:04:04.000] event: {"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":3}} Before running immediate callbacks and checking length (1) @@ -1295,10 +1264,10 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 176 [00:04:12.000] Modify package json file to without type module -Info 177 [00:04:15.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 0:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 178 [00:04:16.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 179 [00:04:17.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 0:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 169 [00:04:05.000] Modify package json file to without type module +Info 170 [00:04:08.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 0:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 171 [00:04:09.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 172 [00:04:10.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 0:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution Before running timeout callbacks //// [/user/username/projects/myproject/package.json] {"name":"app","version":"1.0.0"} @@ -1328,9 +1297,9 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 180 [00:04:18.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 181 [00:04:19.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json -Info 182 [00:04:20.000] Scheduled: *ensureProjectForOpenFiles* +Info 173 [00:04:11.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 174 [00:04:12.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json +Info 175 [00:04:13.000] Scheduled: *ensureProjectForOpenFiles* After running timeout callbacks PolledWatches:: @@ -1383,53 +1352,48 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 183 [00:04:21.000] Running: /user/username/projects/myproject/src/tsconfig.json -Info 184 [00:04:22.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json -Info 185 [00:04:23.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 186 [00:04:24.000] File '/a/package.json' does not exist according to earlier cached lookups. -Info 187 [00:04:25.000] File '/package.json' does not exist according to earlier cached lookups. -Info 188 [00:04:26.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 189 [00:04:27.000] Found 'package.json' at '/user/username/projects/myproject/package.json'. -Info 190 [00:04:28.000] 'package.json' does not have a 'typesVersions' field. -Info 191 [00:04:29.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 192 [00:04:30.000] File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. -Info 193 [00:04:31.000] ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== -Info 194 [00:04:32.000] Module resolution kind is not specified, using 'Node16'. -Info 195 [00:04:33.000] Resolving in CJS mode with conditions 'node', 'require', 'types'. -Info 196 [00:04:34.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'TypeScript'. -Info 197 [00:04:35.000] File '/user/username/projects/myproject/src/fileB.mjs.ts' does not exist. -Info 198 [00:04:36.000] File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. -Info 199 [00:04:37.000] File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. -Info 200 [00:04:38.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. -Info 201 [00:04:39.000] File '/user/username/projects/myproject/src/fileB.mts' exist - use it as a name resolution result. -Info 202 [00:04:40.000] ======== Module name './fileB.mjs' was successfully resolved to '/user/username/projects/myproject/src/fileB.mts'. ======== -Info 203 [00:04:41.000] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src 0 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations -Info 204 [00:04:42.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src 0 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations -Info 205 [00:04:43.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 206 [00:04:44.000] File '/a/package.json' does not exist according to earlier cached lookups. -Info 207 [00:04:45.000] File '/package.json' does not exist according to earlier cached lookups. -Info 208 [00:04:46.000] FileWatcher:: Close:: WatchInfo: /user/username/projects/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 209 [00:04:47.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 5 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms -Info 210 [00:04:48.000] Different program with same set of files -Info 211 [00:04:49.000] Running: *ensureProjectForOpenFiles* -Info 212 [00:04:50.000] Before ensureProjectForOpenFiles: -Info 213 [00:04:51.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 213 [00:04:52.000] Files (3) - -Info 213 [00:04:53.000] ----------------------------------------------- -Info 213 [00:04:54.000] Open files: -Info 213 [00:04:55.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 213 [00:04:56.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 213 [00:04:57.000] After ensureProjectForOpenFiles: -Info 214 [00:04:58.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 214 [00:04:59.000] Files (3) - -Info 214 [00:05:00.000] ----------------------------------------------- -Info 214 [00:05:01.000] Open files: -Info 214 [00:05:02.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 214 [00:05:03.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 214 [00:05:04.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts -Info 215 [00:05:05.000] event: +Info 176 [00:04:14.000] Running: /user/username/projects/myproject/src/tsconfig.json +Info 177 [00:04:15.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json +Info 178 [00:04:16.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 179 [00:04:17.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 180 [00:04:18.000] File '/package.json' does not exist according to earlier cached lookups. +Info 181 [00:04:19.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 182 [00:04:20.000] Found 'package.json' at '/user/username/projects/myproject/package.json'. +Info 183 [00:04:21.000] 'package.json' does not have a 'typesVersions' field. +Info 184 [00:04:22.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 185 [00:04:23.000] File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. +Info 186 [00:04:24.000] ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== +Info 187 [00:04:25.000] Module resolution kind is not specified, using 'Node16'. +Info 188 [00:04:26.000] Resolving in CJS mode with conditions 'node', 'require', 'types'. +Info 189 [00:04:27.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'TypeScript'. +Info 190 [00:04:28.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. +Info 191 [00:04:29.000] File '/user/username/projects/myproject/src/fileB.mts' exist - use it as a name resolution result. +Info 192 [00:04:30.000] ======== Module name './fileB.mjs' was successfully resolved to '/user/username/projects/myproject/src/fileB.mts'. ======== +Info 193 [00:04:31.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 194 [00:04:32.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 195 [00:04:33.000] File '/package.json' does not exist according to earlier cached lookups. +Info 196 [00:04:34.000] FileWatcher:: Close:: WatchInfo: /user/username/projects/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 197 [00:04:35.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 5 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms +Info 198 [00:04:36.000] Different program with same set of files +Info 199 [00:04:37.000] Running: *ensureProjectForOpenFiles* +Info 200 [00:04:38.000] Before ensureProjectForOpenFiles: +Info 201 [00:04:39.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 201 [00:04:40.000] Files (3) + +Info 201 [00:04:41.000] ----------------------------------------------- +Info 201 [00:04:42.000] Open files: +Info 201 [00:04:43.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 201 [00:04:44.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 201 [00:04:45.000] After ensureProjectForOpenFiles: +Info 202 [00:04:46.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 202 [00:04:47.000] Files (3) + +Info 202 [00:04:48.000] ----------------------------------------------- +Info 202 [00:04:49.000] Open files: +Info 202 [00:04:50.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 202 [00:04:51.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 202 [00:04:52.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts +Info 203 [00:04:53.000] event: {"seq":0,"type":"event","event":"projectsUpdatedInBackground","body":{"openFiles":["/user/username/projects/myproject/src/fileA.ts"]}} After running timeout callbacks @@ -1450,14 +1414,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 216 [00:05:06.000] request: +Info 204 [00:04:54.000] request: { "command": "geterr", "arguments": { @@ -1488,8 +1450,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -1514,14 +1474,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 217 [00:05:07.000] response: +Info 205 [00:04:55.000] response: { "responseRequired": false } @@ -1544,14 +1502,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 218 [00:05:08.000] event: +Info 206 [00:04:56.000] event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} After checking timeout queue length (1) and running @@ -1572,8 +1528,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -1598,14 +1552,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 219 [00:05:09.000] event: +Info 207 [00:04:57.000] event: {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.\n To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","code":1479,"category":"error"}]}} Before running immediate callbacks and checking length (1) @@ -1626,8 +1578,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -1652,16 +1602,14 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 220 [00:05:10.000] event: +Info 208 [00:04:58.000] event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} -Info 221 [00:05:11.000] event: +Info 209 [00:04:59.000] event: {"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":4}} Before running immediate callbacks and checking length (1) @@ -1682,17 +1630,15 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 222 [00:05:12.000] Delete package.json -Info 223 [00:05:14.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 224 [00:05:15.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 225 [00:05:16.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 210 [00:05:00.000] Delete package.json +Info 211 [00:05:02.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 212 [00:05:03.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 213 [00:05:04.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution Before running timeout callbacks //// [/user/username/projects/myproject/package.json] deleted @@ -1713,16 +1659,14 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 226 [00:05:17.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 227 [00:05:18.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json -Info 228 [00:05:19.000] Scheduled: *ensureProjectForOpenFiles* +Info 214 [00:05:05.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 215 [00:05:06.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json +Info 216 [00:05:07.000] Scheduled: *ensureProjectForOpenFiles* After running timeout callbacks PolledWatches:: @@ -1742,8 +1686,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -1768,56 +1710,54 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 229 [00:05:20.000] Running: /user/username/projects/myproject/src/tsconfig.json -Info 230 [00:05:21.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json -Info 231 [00:05:22.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 232 [00:05:23.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 217 [00:05:08.000] Running: /user/username/projects/myproject/src/tsconfig.json +Info 218 [00:05:09.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json +Info 219 [00:05:10.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 220 [00:05:11.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 221 [00:05:12.000] File '/package.json' does not exist according to earlier cached lookups. +Info 222 [00:05:13.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 223 [00:05:14.000] File '/user/username/projects/myproject/package.json' does not exist. +Info 224 [00:05:15.000] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. +Info 225 [00:05:16.000] File '/user/username/package.json' does not exist according to earlier cached lookups. +Info 226 [00:05:17.000] File '/user/package.json' does not exist according to earlier cached lookups. +Info 227 [00:05:18.000] File '/package.json' does not exist according to earlier cached lookups. +Info 228 [00:05:19.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 229 [00:05:20.000] File '/user/username/projects/myproject/package.json' does not exist according to earlier cached lookups. +Info 230 [00:05:21.000] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. +Info 231 [00:05:22.000] File '/user/username/package.json' does not exist according to earlier cached lookups. +Info 232 [00:05:23.000] File '/user/package.json' does not exist according to earlier cached lookups. Info 233 [00:05:24.000] File '/package.json' does not exist according to earlier cached lookups. -Info 234 [00:05:25.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 235 [00:05:26.000] File '/user/username/projects/myproject/package.json' does not exist. -Info 236 [00:05:27.000] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. -Info 237 [00:05:28.000] File '/user/username/package.json' does not exist according to earlier cached lookups. -Info 238 [00:05:29.000] File '/user/package.json' does not exist according to earlier cached lookups. -Info 239 [00:05:30.000] File '/package.json' does not exist according to earlier cached lookups. -Info 240 [00:05:31.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 241 [00:05:32.000] File '/user/username/projects/myproject/package.json' does not exist according to earlier cached lookups. -Info 242 [00:05:33.000] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. -Info 243 [00:05:34.000] File '/user/username/package.json' does not exist according to earlier cached lookups. -Info 244 [00:05:35.000] File '/user/package.json' does not exist according to earlier cached lookups. -Info 245 [00:05:36.000] File '/package.json' does not exist according to earlier cached lookups. -Info 246 [00:05:37.000] Reusing resolution of module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts' of old program, it was successfully resolved to '/user/username/projects/myproject/src/fileB.mts'. -Info 247 [00:05:38.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 248 [00:05:39.000] File '/a/package.json' does not exist according to earlier cached lookups. -Info 249 [00:05:40.000] File '/package.json' does not exist according to earlier cached lookups. -Info 250 [00:05:41.000] FileWatcher:: Added:: WatchInfo: /user/username/projects/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 251 [00:05:42.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 6 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms -Info 252 [00:05:43.000] Different program with same set of files -Info 253 [00:05:44.000] Running: *ensureProjectForOpenFiles* -Info 254 [00:05:45.000] Before ensureProjectForOpenFiles: -Info 255 [00:05:46.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 255 [00:05:47.000] Files (3) - -Info 255 [00:05:48.000] ----------------------------------------------- -Info 255 [00:05:49.000] Open files: -Info 255 [00:05:50.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 255 [00:05:51.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 255 [00:05:52.000] After ensureProjectForOpenFiles: -Info 256 [00:05:53.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 256 [00:05:54.000] Files (3) - -Info 256 [00:05:55.000] ----------------------------------------------- -Info 256 [00:05:56.000] Open files: -Info 256 [00:05:57.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 256 [00:05:58.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 256 [00:05:59.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts -Info 257 [00:06:00.000] event: +Info 234 [00:05:25.000] Reusing resolution of module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts' of old program, it was successfully resolved to '/user/username/projects/myproject/src/fileB.mts'. +Info 235 [00:05:26.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 236 [00:05:27.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 237 [00:05:28.000] File '/package.json' does not exist according to earlier cached lookups. +Info 238 [00:05:29.000] FileWatcher:: Added:: WatchInfo: /user/username/projects/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 239 [00:05:30.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 6 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms +Info 240 [00:05:31.000] Different program with same set of files +Info 241 [00:05:32.000] Running: *ensureProjectForOpenFiles* +Info 242 [00:05:33.000] Before ensureProjectForOpenFiles: +Info 243 [00:05:34.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 243 [00:05:35.000] Files (3) + +Info 243 [00:05:36.000] ----------------------------------------------- +Info 243 [00:05:37.000] Open files: +Info 243 [00:05:38.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 243 [00:05:39.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 243 [00:05:40.000] After ensureProjectForOpenFiles: +Info 244 [00:05:41.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 244 [00:05:42.000] Files (3) + +Info 244 [00:05:43.000] ----------------------------------------------- +Info 244 [00:05:44.000] Open files: +Info 244 [00:05:45.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 244 [00:05:46.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 244 [00:05:47.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts +Info 245 [00:05:48.000] event: {"seq":0,"type":"event","event":"projectsUpdatedInBackground","body":{"openFiles":["/user/username/projects/myproject/src/fileA.ts"]}} After running timeout callbacks @@ -1840,14 +1780,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 258 [00:06:01.000] request: +Info 246 [00:05:49.000] request: { "command": "geterr", "arguments": { @@ -1880,8 +1818,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -1908,14 +1844,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 259 [00:06:02.000] response: +Info 247 [00:05:50.000] response: { "responseRequired": false } @@ -1940,14 +1874,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 260 [00:06:03.000] event: +Info 248 [00:05:51.000] event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} After checking timeout queue length (1) and running @@ -1970,8 +1902,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -1998,14 +1928,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 261 [00:06:04.000] event: +Info 249 [00:05:52.000] event: {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.\n To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","code":1479,"category":"error"}]}} Before running immediate callbacks and checking length (1) @@ -2028,8 +1956,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -2056,16 +1982,14 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 262 [00:06:05.000] event: +Info 250 [00:05:53.000] event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} -Info 263 [00:06:06.000] event: +Info 251 [00:05:54.000] event: {"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":5}} Before running immediate callbacks and checking length (1) @@ -2088,8 +2012,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: diff --git a/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited.js b/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited.js index e5bc763d8120c..3dcb8f377362e 100644 --- a/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited.js +++ b/tests/baselines/reference/tsserver/moduleResolution/package-json-file-is-edited.js @@ -75,27 +75,22 @@ Info 15 [00:00:42.000] ======== Resolving module './fileB.mjs' from '/user/use Info 16 [00:00:43.000] Module resolution kind is not specified, using 'Node16'. Info 17 [00:00:44.000] Resolving in CJS mode with conditions 'node', 'require', 'types'. Info 18 [00:00:45.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'TypeScript'. -Info 19 [00:00:46.000] File '/user/username/projects/myproject/src/fileB.mjs.ts' does not exist. -Info 20 [00:00:47.000] File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. -Info 21 [00:00:48.000] File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. -Info 22 [00:00:49.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. -Info 23 [00:00:50.000] File '/user/username/projects/myproject/src/fileB.mts' exist - use it as a name resolution result. -Info 24 [00:00:51.000] ======== Module name './fileB.mjs' was successfully resolved to '/user/username/projects/myproject/src/fileB.mts'. ======== -Info 25 [00:00:52.000] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src 0 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations -Info 26 [00:00:53.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src 0 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations -Info 27 [00:00:54.000] File '/a/lib/package.json' does not exist. -Info 28 [00:00:55.000] File '/a/package.json' does not exist. -Info 29 [00:00:56.000] File '/package.json' does not exist. -Info 30 [00:00:57.000] FileWatcher:: Added:: WatchInfo: /a/lib/lib.es2016.full.d.ts 500 undefined WatchType: Closed Script info -Info 31 [00:00:58.000] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 32 [00:00:59.000] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 33 [00:01:00.000] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/node_modules/@types 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Type roots -Info 34 [00:01:01.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/node_modules/@types 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Type roots -Info 35 [00:01:02.000] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Type roots -Info 36 [00:01:03.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Type roots -Info 37 [00:01:04.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms -Info 38 [00:01:05.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 39 [00:01:06.000] Files (3) +Info 19 [00:00:46.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. +Info 20 [00:00:47.000] File '/user/username/projects/myproject/src/fileB.mts' exist - use it as a name resolution result. +Info 21 [00:00:48.000] ======== Module name './fileB.mjs' was successfully resolved to '/user/username/projects/myproject/src/fileB.mts'. ======== +Info 22 [00:00:49.000] File '/a/lib/package.json' does not exist. +Info 23 [00:00:50.000] File '/a/package.json' does not exist. +Info 24 [00:00:51.000] File '/package.json' does not exist. +Info 25 [00:00:52.000] FileWatcher:: Added:: WatchInfo: /a/lib/lib.es2016.full.d.ts 500 undefined WatchType: Closed Script info +Info 26 [00:00:53.000] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 27 [00:00:54.000] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 28 [00:00:55.000] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/node_modules/@types 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Type roots +Info 29 [00:00:56.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/node_modules/@types 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Type roots +Info 30 [00:00:57.000] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Type roots +Info 31 [00:00:58.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules/@types 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Type roots +Info 32 [00:00:59.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms +Info 33 [00:01:00.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 34 [00:01:01.000] Files (3) /a/lib/lib.es2016.full.d.ts /user/username/projects/myproject/src/fileB.mts /user/username/projects/myproject/src/fileA.ts @@ -110,21 +105,21 @@ Info 39 [00:01:06.000] Files (3) Matched by default include pattern '**/*' File is CommonJS module because '../package.json' does not have field "type" -Info 40 [00:01:07.000] ----------------------------------------------- -Info 41 [00:01:08.000] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file -Info 42 [00:01:09.000] event: +Info 35 [00:01:02.000] ----------------------------------------------- +Info 36 [00:01:03.000] FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file +Info 37 [00:01:04.000] event: {"seq":0,"type":"event","event":"projectLoadingFinish","body":{"projectName":"/user/username/projects/myproject/src/tsconfig.json"}} -Info 43 [00:01:10.000] event: +Info 38 [00:01:05.000] event: {"seq":0,"type":"event","event":"telemetry","body":{"telemetryEventName":"projectInfo","payload":{"projectId":"f026568af42c61ce0537de8ee0fa07c9359a76dcfb046248ed49dc76c91e4a37","fileStats":{"js":0,"jsSize":0,"jsx":0,"jsxSize":0,"ts":2,"tsSize":68,"tsx":0,"tsxSize":0,"dts":1,"dtsSize":334,"deferred":0,"deferredSize":0},"compilerOptions":{"target":"es2016","module":"node16","outDir":"","traceResolution":true},"typeAcquisition":{"enable":false,"include":false,"exclude":false},"extends":false,"files":false,"include":false,"exclude":false,"compileOnSave":false,"configFileName":"tsconfig.json","projectType":"configured","languageServiceEnabled":true,"version":"FakeVersion"}}} -Info 44 [00:01:11.000] event: +Info 39 [00:01:06.000] event: {"seq":0,"type":"event","event":"configFileDiag","body":{"triggerFile":"/user/username/projects/myproject/src/fileA.ts","configFile":"/user/username/projects/myproject/src/tsconfig.json","diagnostics":[]}} -Info 45 [00:01:12.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 45 [00:01:13.000] Files (3) +Info 40 [00:01:07.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 40 [00:01:08.000] Files (3) -Info 45 [00:01:14.000] ----------------------------------------------- -Info 45 [00:01:15.000] Open files: -Info 45 [00:01:16.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 45 [00:01:17.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 40 [00:01:09.000] ----------------------------------------------- +Info 40 [00:01:10.000] Open files: +Info 40 [00:01:11.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 40 [00:01:12.000] Projects: /user/username/projects/myproject/src/tsconfig.json After request PolledWatches:: @@ -140,8 +135,6 @@ FsWatches:: {} /user/username/projects/myproject/src/fileb.mts: {} -/user/username/projects/myproject/src: - {} /a/lib/lib.es2016.full.d.ts: {} /user/username/projects/myproject/package.json: @@ -151,16 +144,16 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 45 [00:01:18.000] response: +Info 40 [00:01:13.000] response: { "responseRequired": false } -Info 46 [00:01:19.000] Modify package json file to add type module -Info 47 [00:01:23.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 48 [00:01:24.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 49 [00:01:25.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 50 [00:01:26.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file -Info 51 [00:01:27.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file +Info 41 [00:01:14.000] Modify package json file to add type module +Info 42 [00:01:18.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 43 [00:01:19.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 44 [00:01:20.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 45 [00:01:21.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file +Info 46 [00:01:22.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file Before running timeout callbacks //// [/user/username/projects/myproject/package.json] {"name":"app","version":"1.0.0","type":"module"} @@ -179,8 +172,6 @@ FsWatches:: {} /user/username/projects/myproject/src/fileb.mts: {} -/user/username/projects/myproject/src: - {} /a/lib/lib.es2016.full.d.ts: {} /user/username/projects/myproject/package.json: @@ -190,9 +181,9 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 52 [00:01:28.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 53 [00:01:29.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json -Info 54 [00:01:30.000] Scheduled: *ensureProjectForOpenFiles* +Info 47 [00:01:23.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 48 [00:01:24.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json +Info 49 [00:01:25.000] Scheduled: *ensureProjectForOpenFiles* After running timeout callbacks PolledWatches:: @@ -208,8 +199,6 @@ FsWatches:: {} /user/username/projects/myproject/src/fileb.mts: {} -/user/username/projects/myproject/src: - {} /a/lib/lib.es2016.full.d.ts: {} /user/username/projects/myproject/package.json: @@ -234,8 +223,6 @@ FsWatches:: {} /user/username/projects/myproject/src/fileb.mts: {} -/user/username/projects/myproject/src: - {} /a/lib/lib.es2016.full.d.ts: {} /user/username/projects/myproject/package.json: @@ -245,49 +232,47 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 55 [00:01:31.000] Running: /user/username/projects/myproject/src/tsconfig.json -Info 56 [00:01:32.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json -Info 57 [00:01:33.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 58 [00:01:34.000] File '/a/package.json' does not exist according to earlier cached lookups. -Info 59 [00:01:35.000] File '/package.json' does not exist according to earlier cached lookups. -Info 60 [00:01:36.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 61 [00:01:37.000] Found 'package.json' at '/user/username/projects/myproject/package.json'. -Info 62 [00:01:38.000] 'package.json' does not have a 'typesVersions' field. -Info 63 [00:01:39.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 64 [00:01:40.000] File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. -Info 65 [00:01:41.000] ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== -Info 66 [00:01:42.000] Module resolution kind is not specified, using 'Node16'. -Info 67 [00:01:43.000] Resolving in ESM mode with conditions 'node', 'import', 'types'. -Info 68 [00:01:44.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'TypeScript'. -Info 69 [00:01:45.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. -Info 70 [00:01:46.000] File '/user/username/projects/myproject/src/fileB.mts' exist - use it as a name resolution result. -Info 71 [00:01:47.000] ======== Module name './fileB.mjs' was successfully resolved to '/user/username/projects/myproject/src/fileB.mts'. ======== -Info 72 [00:01:48.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 73 [00:01:49.000] File '/a/package.json' does not exist according to earlier cached lookups. -Info 74 [00:01:50.000] File '/package.json' does not exist according to earlier cached lookups. -Info 75 [00:01:51.000] DirectoryWatcher:: Close:: WatchInfo: /user/username/projects/myproject/src 0 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations -Info 76 [00:01:52.000] Elapsed:: *ms DirectoryWatcher:: Close:: WatchInfo: /user/username/projects/myproject/src 0 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations -Info 77 [00:01:53.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 2 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms -Info 78 [00:01:54.000] Different program with same set of files -Info 79 [00:01:55.000] Running: *ensureProjectForOpenFiles* -Info 80 [00:01:56.000] Before ensureProjectForOpenFiles: -Info 81 [00:01:57.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 81 [00:01:58.000] Files (3) - -Info 81 [00:01:59.000] ----------------------------------------------- -Info 81 [00:02:00.000] Open files: -Info 81 [00:02:01.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 81 [00:02:02.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 81 [00:02:03.000] After ensureProjectForOpenFiles: -Info 82 [00:02:04.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 82 [00:02:05.000] Files (3) - -Info 82 [00:02:06.000] ----------------------------------------------- -Info 82 [00:02:07.000] Open files: -Info 82 [00:02:08.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 82 [00:02:09.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 82 [00:02:10.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts -Info 83 [00:02:11.000] event: +Info 50 [00:01:26.000] Running: /user/username/projects/myproject/src/tsconfig.json +Info 51 [00:01:27.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json +Info 52 [00:01:28.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 53 [00:01:29.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 54 [00:01:30.000] File '/package.json' does not exist according to earlier cached lookups. +Info 55 [00:01:31.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 56 [00:01:32.000] Found 'package.json' at '/user/username/projects/myproject/package.json'. +Info 57 [00:01:33.000] 'package.json' does not have a 'typesVersions' field. +Info 58 [00:01:34.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 59 [00:01:35.000] File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. +Info 60 [00:01:36.000] ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== +Info 61 [00:01:37.000] Module resolution kind is not specified, using 'Node16'. +Info 62 [00:01:38.000] Resolving in ESM mode with conditions 'node', 'import', 'types'. +Info 63 [00:01:39.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'TypeScript'. +Info 64 [00:01:40.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. +Info 65 [00:01:41.000] File '/user/username/projects/myproject/src/fileB.mts' exist - use it as a name resolution result. +Info 66 [00:01:42.000] ======== Module name './fileB.mjs' was successfully resolved to '/user/username/projects/myproject/src/fileB.mts'. ======== +Info 67 [00:01:43.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 68 [00:01:44.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 69 [00:01:45.000] File '/package.json' does not exist according to earlier cached lookups. +Info 70 [00:01:46.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 2 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms +Info 71 [00:01:47.000] Different program with same set of files +Info 72 [00:01:48.000] Running: *ensureProjectForOpenFiles* +Info 73 [00:01:49.000] Before ensureProjectForOpenFiles: +Info 74 [00:01:50.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 74 [00:01:51.000] Files (3) + +Info 74 [00:01:52.000] ----------------------------------------------- +Info 74 [00:01:53.000] Open files: +Info 74 [00:01:54.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 74 [00:01:55.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 74 [00:01:56.000] After ensureProjectForOpenFiles: +Info 75 [00:01:57.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 75 [00:01:58.000] Files (3) + +Info 75 [00:01:59.000] ----------------------------------------------- +Info 75 [00:02:00.000] Open files: +Info 75 [00:02:01.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 75 [00:02:02.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 75 [00:02:03.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts +Info 76 [00:02:04.000] event: {"seq":0,"type":"event","event":"projectsUpdatedInBackground","body":{"openFiles":["/user/username/projects/myproject/src/fileA.ts"]}} After running timeout callbacks @@ -313,7 +298,7 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 84 [00:02:12.000] request: +Info 77 [00:02:05.000] request: { "command": "geterr", "arguments": { @@ -373,7 +358,7 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 85 [00:02:13.000] response: +Info 78 [00:02:06.000] response: { "responseRequired": false } @@ -401,7 +386,7 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 86 [00:02:14.000] event: +Info 79 [00:02:07.000] event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} After checking timeout queue length (1) and running @@ -451,7 +436,7 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 87 [00:02:15.000] event: +Info 80 [00:02:08.000] event: {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} Before running immediate callbacks and checking length (1) @@ -501,9 +486,9 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 88 [00:02:16.000] event: +Info 81 [00:02:09.000] event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} -Info 89 [00:02:17.000] event: +Info 82 [00:02:10.000] event: {"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":1}} Before running immediate callbacks and checking length (1) @@ -529,12 +514,12 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 90 [00:02:18.000] Modify package json file to remove type module -Info 91 [00:02:22.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 92 [00:02:23.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 93 [00:02:24.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 94 [00:02:25.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file -Info 95 [00:02:26.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file +Info 83 [00:02:11.000] Modify package json file to remove type module +Info 84 [00:02:15.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 85 [00:02:16.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 86 [00:02:17.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 87 [00:02:18.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file +Info 88 [00:02:19.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 1:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file Before running timeout callbacks //// [/user/username/projects/myproject/package.json] {"name":"app","version":"1.0.0"} @@ -562,9 +547,9 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 96 [00:02:27.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 97 [00:02:28.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json -Info 98 [00:02:29.000] Scheduled: *ensureProjectForOpenFiles* +Info 89 [00:02:20.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 90 [00:02:21.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json +Info 91 [00:02:22.000] Scheduled: *ensureProjectForOpenFiles* After running timeout callbacks PolledWatches:: @@ -613,52 +598,47 @@ FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 99 [00:02:30.000] Running: /user/username/projects/myproject/src/tsconfig.json -Info 100 [00:02:31.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json -Info 101 [00:02:32.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 102 [00:02:33.000] File '/a/package.json' does not exist according to earlier cached lookups. -Info 103 [00:02:34.000] File '/package.json' does not exist according to earlier cached lookups. -Info 104 [00:02:35.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 105 [00:02:36.000] Found 'package.json' at '/user/username/projects/myproject/package.json'. -Info 106 [00:02:37.000] 'package.json' does not have a 'typesVersions' field. -Info 107 [00:02:38.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 108 [00:02:39.000] File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. -Info 109 [00:02:40.000] ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== -Info 110 [00:02:41.000] Module resolution kind is not specified, using 'Node16'. -Info 111 [00:02:42.000] Resolving in CJS mode with conditions 'node', 'require', 'types'. -Info 112 [00:02:43.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'TypeScript'. -Info 113 [00:02:44.000] File '/user/username/projects/myproject/src/fileB.mjs.ts' does not exist. -Info 114 [00:02:45.000] File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. -Info 115 [00:02:46.000] File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. -Info 116 [00:02:47.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. -Info 117 [00:02:48.000] File '/user/username/projects/myproject/src/fileB.mts' exist - use it as a name resolution result. -Info 118 [00:02:49.000] ======== Module name './fileB.mjs' was successfully resolved to '/user/username/projects/myproject/src/fileB.mts'. ======== -Info 119 [00:02:50.000] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src 0 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations -Info 120 [00:02:51.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src 0 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations -Info 121 [00:02:52.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 122 [00:02:53.000] File '/a/package.json' does not exist according to earlier cached lookups. -Info 123 [00:02:54.000] File '/package.json' does not exist according to earlier cached lookups. -Info 124 [00:02:55.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 3 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms -Info 125 [00:02:56.000] Different program with same set of files -Info 126 [00:02:57.000] Running: *ensureProjectForOpenFiles* -Info 127 [00:02:58.000] Before ensureProjectForOpenFiles: -Info 128 [00:02:59.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 128 [00:03:00.000] Files (3) - -Info 128 [00:03:01.000] ----------------------------------------------- -Info 128 [00:03:02.000] Open files: -Info 128 [00:03:03.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 128 [00:03:04.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 128 [00:03:05.000] After ensureProjectForOpenFiles: -Info 129 [00:03:06.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 129 [00:03:07.000] Files (3) - -Info 129 [00:03:08.000] ----------------------------------------------- -Info 129 [00:03:09.000] Open files: -Info 129 [00:03:10.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 129 [00:03:11.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 129 [00:03:12.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts -Info 130 [00:03:13.000] event: +Info 92 [00:02:23.000] Running: /user/username/projects/myproject/src/tsconfig.json +Info 93 [00:02:24.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json +Info 94 [00:02:25.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 95 [00:02:26.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 96 [00:02:27.000] File '/package.json' does not exist according to earlier cached lookups. +Info 97 [00:02:28.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 98 [00:02:29.000] Found 'package.json' at '/user/username/projects/myproject/package.json'. +Info 99 [00:02:30.000] 'package.json' does not have a 'typesVersions' field. +Info 100 [00:02:31.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 101 [00:02:32.000] File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. +Info 102 [00:02:33.000] ======== Resolving module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts'. ======== +Info 103 [00:02:34.000] Module resolution kind is not specified, using 'Node16'. +Info 104 [00:02:35.000] Resolving in CJS mode with conditions 'node', 'require', 'types'. +Info 105 [00:02:36.000] Loading module as file / folder, candidate module location '/user/username/projects/myproject/src/fileB.mjs', target file type 'TypeScript'. +Info 106 [00:02:37.000] File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. +Info 107 [00:02:38.000] File '/user/username/projects/myproject/src/fileB.mts' exist - use it as a name resolution result. +Info 108 [00:02:39.000] ======== Module name './fileB.mjs' was successfully resolved to '/user/username/projects/myproject/src/fileB.mts'. ======== +Info 109 [00:02:40.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 110 [00:02:41.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 111 [00:02:42.000] File '/package.json' does not exist according to earlier cached lookups. +Info 112 [00:02:43.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 3 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms +Info 113 [00:02:44.000] Different program with same set of files +Info 114 [00:02:45.000] Running: *ensureProjectForOpenFiles* +Info 115 [00:02:46.000] Before ensureProjectForOpenFiles: +Info 116 [00:02:47.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 116 [00:02:48.000] Files (3) + +Info 116 [00:02:49.000] ----------------------------------------------- +Info 116 [00:02:50.000] Open files: +Info 116 [00:02:51.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 116 [00:02:52.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 116 [00:02:53.000] After ensureProjectForOpenFiles: +Info 117 [00:02:54.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 117 [00:02:55.000] Files (3) + +Info 117 [00:02:56.000] ----------------------------------------------- +Info 117 [00:02:57.000] Open files: +Info 117 [00:02:58.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 117 [00:02:59.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 117 [00:03:00.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts +Info 118 [00:03:01.000] event: {"seq":0,"type":"event","event":"projectsUpdatedInBackground","body":{"openFiles":["/user/username/projects/myproject/src/fileA.ts"]}} After running timeout callbacks @@ -679,14 +659,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 131 [00:03:14.000] request: +Info 119 [00:03:02.000] request: { "command": "geterr", "arguments": { @@ -717,8 +695,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -743,14 +719,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 132 [00:03:15.000] response: +Info 120 [00:03:03.000] response: { "responseRequired": false } @@ -773,14 +747,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 133 [00:03:16.000] event: +Info 121 [00:03:04.000] event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} After checking timeout queue length (1) and running @@ -801,8 +773,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -827,14 +797,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 134 [00:03:17.000] event: +Info 122 [00:03:05.000] event: {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.\n To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `\"type\": \"module\"` to '/user/username/projects/myproject/package.json'.","code":1479,"category":"error"}]}} Before running immediate callbacks and checking length (1) @@ -855,8 +823,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -881,16 +847,14 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 135 [00:03:18.000] event: +Info 123 [00:03:06.000] event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} -Info 136 [00:03:19.000] event: +Info 124 [00:03:07.000] event: {"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":2}} Before running immediate callbacks and checking length (1) @@ -911,20 +875,18 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 137 [00:03:20.000] Delete package.json -Info 138 [00:03:22.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 139 [00:03:23.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 140 [00:03:24.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 141 [00:03:25.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file -Info 142 [00:03:26.000] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file -Info 143 [00:03:27.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file +Info 125 [00:03:08.000] Delete package.json +Info 126 [00:03:10.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 127 [00:03:11.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 128 [00:03:12.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 129 [00:03:13.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file +Info 130 [00:03:14.000] FileWatcher:: Close:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file +Info 131 [00:03:15.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 250 undefined WatchType: package.json file Before running timeout callbacks //// [/user/username/projects/myproject/package.json] deleted @@ -945,16 +907,14 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 144 [00:03:28.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 145 [00:03:29.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json -Info 146 [00:03:30.000] Scheduled: *ensureProjectForOpenFiles* +Info 132 [00:03:16.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 133 [00:03:17.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json +Info 134 [00:03:18.000] Scheduled: *ensureProjectForOpenFiles* After running timeout callbacks PolledWatches:: @@ -974,8 +934,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -1000,56 +958,54 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 147 [00:03:31.000] Running: /user/username/projects/myproject/src/tsconfig.json -Info 148 [00:03:32.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json -Info 149 [00:03:33.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 150 [00:03:34.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 135 [00:03:19.000] Running: /user/username/projects/myproject/src/tsconfig.json +Info 136 [00:03:20.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json +Info 137 [00:03:21.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 138 [00:03:22.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 139 [00:03:23.000] File '/package.json' does not exist according to earlier cached lookups. +Info 140 [00:03:24.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 141 [00:03:25.000] File '/user/username/projects/myproject/package.json' does not exist. +Info 142 [00:03:26.000] File '/user/username/projects/package.json' does not exist. +Info 143 [00:03:27.000] File '/user/username/package.json' does not exist. +Info 144 [00:03:28.000] File '/user/package.json' does not exist. +Info 145 [00:03:29.000] File '/package.json' does not exist according to earlier cached lookups. +Info 146 [00:03:30.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 147 [00:03:31.000] File '/user/username/projects/myproject/package.json' does not exist according to earlier cached lookups. +Info 148 [00:03:32.000] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. +Info 149 [00:03:33.000] File '/user/username/package.json' does not exist according to earlier cached lookups. +Info 150 [00:03:34.000] File '/user/package.json' does not exist according to earlier cached lookups. Info 151 [00:03:35.000] File '/package.json' does not exist according to earlier cached lookups. -Info 152 [00:03:36.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 153 [00:03:37.000] File '/user/username/projects/myproject/package.json' does not exist. -Info 154 [00:03:38.000] File '/user/username/projects/package.json' does not exist. -Info 155 [00:03:39.000] File '/user/username/package.json' does not exist. -Info 156 [00:03:40.000] File '/user/package.json' does not exist. -Info 157 [00:03:41.000] File '/package.json' does not exist according to earlier cached lookups. -Info 158 [00:03:42.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 159 [00:03:43.000] File '/user/username/projects/myproject/package.json' does not exist according to earlier cached lookups. -Info 160 [00:03:44.000] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. -Info 161 [00:03:45.000] File '/user/username/package.json' does not exist according to earlier cached lookups. -Info 162 [00:03:46.000] File '/user/package.json' does not exist according to earlier cached lookups. -Info 163 [00:03:47.000] File '/package.json' does not exist according to earlier cached lookups. -Info 164 [00:03:48.000] Reusing resolution of module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts' of old program, it was successfully resolved to '/user/username/projects/myproject/src/fileB.mts'. -Info 165 [00:03:49.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 166 [00:03:50.000] File '/a/package.json' does not exist according to earlier cached lookups. -Info 167 [00:03:51.000] File '/package.json' does not exist according to earlier cached lookups. -Info 168 [00:03:52.000] FileWatcher:: Added:: WatchInfo: /user/username/projects/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 169 [00:03:53.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 4 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms -Info 170 [00:03:54.000] Different program with same set of files -Info 171 [00:03:55.000] Running: *ensureProjectForOpenFiles* -Info 172 [00:03:56.000] Before ensureProjectForOpenFiles: -Info 173 [00:03:57.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 173 [00:03:58.000] Files (3) - -Info 173 [00:03:59.000] ----------------------------------------------- -Info 173 [00:04:00.000] Open files: -Info 173 [00:04:01.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 173 [00:04:02.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 173 [00:04:03.000] After ensureProjectForOpenFiles: -Info 174 [00:04:04.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 174 [00:04:05.000] Files (3) - -Info 174 [00:04:06.000] ----------------------------------------------- -Info 174 [00:04:07.000] Open files: -Info 174 [00:04:08.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 174 [00:04:09.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 174 [00:04:10.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts -Info 175 [00:04:11.000] event: +Info 152 [00:03:36.000] Reusing resolution of module './fileB.mjs' from '/user/username/projects/myproject/src/fileA.ts' of old program, it was successfully resolved to '/user/username/projects/myproject/src/fileB.mts'. +Info 153 [00:03:37.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 154 [00:03:38.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 155 [00:03:39.000] File '/package.json' does not exist according to earlier cached lookups. +Info 156 [00:03:40.000] FileWatcher:: Added:: WatchInfo: /user/username/projects/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 157 [00:03:41.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 4 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms +Info 158 [00:03:42.000] Different program with same set of files +Info 159 [00:03:43.000] Running: *ensureProjectForOpenFiles* +Info 160 [00:03:44.000] Before ensureProjectForOpenFiles: +Info 161 [00:03:45.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 161 [00:03:46.000] Files (3) + +Info 161 [00:03:47.000] ----------------------------------------------- +Info 161 [00:03:48.000] Open files: +Info 161 [00:03:49.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 161 [00:03:50.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 161 [00:03:51.000] After ensureProjectForOpenFiles: +Info 162 [00:03:52.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 162 [00:03:53.000] Files (3) + +Info 162 [00:03:54.000] ----------------------------------------------- +Info 162 [00:03:55.000] Open files: +Info 162 [00:03:56.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 162 [00:03:57.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 162 [00:03:58.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts +Info 163 [00:03:59.000] event: {"seq":0,"type":"event","event":"projectsUpdatedInBackground","body":{"openFiles":["/user/username/projects/myproject/src/fileA.ts"]}} After running timeout callbacks @@ -1072,14 +1028,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 176 [00:04:12.000] request: +Info 164 [00:04:00.000] request: { "command": "geterr", "arguments": { @@ -1112,8 +1066,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -1140,14 +1092,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 177 [00:04:13.000] response: +Info 165 [00:04:01.000] response: { "responseRequired": false } @@ -1172,14 +1122,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 178 [00:04:14.000] event: +Info 166 [00:04:02.000] event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} After checking timeout queue length (1) and running @@ -1202,8 +1150,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -1230,14 +1176,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 179 [00:04:15.000] event: +Info 167 [00:04:03.000] event: {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.\n To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","code":1479,"category":"error"}]}} Before running immediate callbacks and checking length (1) @@ -1260,8 +1204,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -1288,16 +1230,14 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 180 [00:04:16.000] event: +Info 168 [00:04:04.000] event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} -Info 181 [00:04:17.000] event: +Info 169 [00:04:05.000] event: {"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":3}} Before running immediate callbacks and checking length (1) @@ -1320,17 +1260,15 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 182 [00:04:18.000] Modify package json file to add type module -Info 183 [00:04:21.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 0:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 184 [00:04:22.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 185 [00:04:23.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 0:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 170 [00:04:06.000] Modify package json file to add type module +Info 171 [00:04:09.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 0:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 172 [00:04:10.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 173 [00:04:11.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 0:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution Before running timeout callbacks //// [/user/username/projects/myproject/package.json] {"name":"app","version":"1.0.0","type":"module"} @@ -1355,16 +1293,14 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 186 [00:04:24.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 187 [00:04:25.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json -Info 188 [00:04:26.000] Scheduled: *ensureProjectForOpenFiles* +Info 174 [00:04:12.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 175 [00:04:13.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json +Info 176 [00:04:14.000] Scheduled: *ensureProjectForOpenFiles* After running timeout callbacks PolledWatches:: @@ -1386,8 +1322,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -1414,48 +1348,46 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 189 [00:04:27.000] Running: /user/username/projects/myproject/src/tsconfig.json -Info 190 [00:04:28.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json -Info 191 [00:04:29.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 192 [00:04:30.000] File '/a/package.json' does not exist according to earlier cached lookups. -Info 193 [00:04:31.000] File '/package.json' does not exist according to earlier cached lookups. -Info 194 [00:04:32.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 195 [00:04:33.000] Found 'package.json' at '/user/username/projects/myproject/package.json'. -Info 196 [00:04:34.000] 'package.json' does not have a 'typesVersions' field. -Info 197 [00:04:35.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 198 [00:04:36.000] File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. -Info 199 [00:04:37.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 200 [00:04:38.000] File '/a/package.json' does not exist according to earlier cached lookups. -Info 201 [00:04:39.000] File '/package.json' does not exist according to earlier cached lookups. -Info 202 [00:04:40.000] FileWatcher:: Close:: WatchInfo: /user/username/projects/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 203 [00:04:41.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 5 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms -Info 204 [00:04:42.000] Different program with same set of files -Info 205 [00:04:43.000] Running: *ensureProjectForOpenFiles* -Info 206 [00:04:44.000] Before ensureProjectForOpenFiles: -Info 207 [00:04:45.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 207 [00:04:46.000] Files (3) - -Info 207 [00:04:47.000] ----------------------------------------------- -Info 207 [00:04:48.000] Open files: -Info 207 [00:04:49.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 207 [00:04:50.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 207 [00:04:51.000] After ensureProjectForOpenFiles: -Info 208 [00:04:52.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 208 [00:04:53.000] Files (3) - -Info 208 [00:04:54.000] ----------------------------------------------- -Info 208 [00:04:55.000] Open files: -Info 208 [00:04:56.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 208 [00:04:57.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 208 [00:04:58.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts -Info 209 [00:04:59.000] event: +Info 177 [00:04:15.000] Running: /user/username/projects/myproject/src/tsconfig.json +Info 178 [00:04:16.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json +Info 179 [00:04:17.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 180 [00:04:18.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 181 [00:04:19.000] File '/package.json' does not exist according to earlier cached lookups. +Info 182 [00:04:20.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 183 [00:04:21.000] Found 'package.json' at '/user/username/projects/myproject/package.json'. +Info 184 [00:04:22.000] 'package.json' does not have a 'typesVersions' field. +Info 185 [00:04:23.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 186 [00:04:24.000] File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. +Info 187 [00:04:25.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 188 [00:04:26.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 189 [00:04:27.000] File '/package.json' does not exist according to earlier cached lookups. +Info 190 [00:04:28.000] FileWatcher:: Close:: WatchInfo: /user/username/projects/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 191 [00:04:29.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 5 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms +Info 192 [00:04:30.000] Different program with same set of files +Info 193 [00:04:31.000] Running: *ensureProjectForOpenFiles* +Info 194 [00:04:32.000] Before ensureProjectForOpenFiles: +Info 195 [00:04:33.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 195 [00:04:34.000] Files (3) + +Info 195 [00:04:35.000] ----------------------------------------------- +Info 195 [00:04:36.000] Open files: +Info 195 [00:04:37.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 195 [00:04:38.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 195 [00:04:39.000] After ensureProjectForOpenFiles: +Info 196 [00:04:40.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 196 [00:04:41.000] Files (3) + +Info 196 [00:04:42.000] ----------------------------------------------- +Info 196 [00:04:43.000] Open files: +Info 196 [00:04:44.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 196 [00:04:45.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 196 [00:04:46.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts +Info 197 [00:04:47.000] event: {"seq":0,"type":"event","event":"projectsUpdatedInBackground","body":{"openFiles":["/user/username/projects/myproject/src/fileA.ts"]}} After running timeout callbacks @@ -1476,14 +1408,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 210 [00:05:00.000] request: +Info 198 [00:04:48.000] request: { "command": "geterr", "arguments": { @@ -1514,8 +1444,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -1540,14 +1468,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 211 [00:05:01.000] response: +Info 199 [00:04:49.000] response: { "responseRequired": false } @@ -1570,14 +1496,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 212 [00:05:02.000] event: +Info 200 [00:04:50.000] event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} After checking timeout queue length (1) and running @@ -1598,8 +1522,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -1624,14 +1546,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 213 [00:05:03.000] event: +Info 201 [00:04:51.000] event: {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} Before running immediate callbacks and checking length (1) @@ -1652,8 +1572,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -1678,16 +1596,14 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 214 [00:05:04.000] event: +Info 202 [00:04:52.000] event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} -Info 215 [00:05:05.000] event: +Info 203 [00:04:53.000] event: {"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":4}} Before running immediate callbacks and checking length (1) @@ -1708,17 +1624,15 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 216 [00:05:06.000] Delete package.json -Info 217 [00:05:08.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 218 [00:05:09.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 219 [00:05:10.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 204 [00:04:54.000] Delete package.json +Info 205 [00:04:56.000] FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 206 [00:04:57.000] Scheduled: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 207 [00:04:58.000] Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/package.json 2:: WatchInfo: /user/username/projects/myproject/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution Before running timeout callbacks //// [/user/username/projects/myproject/package.json] deleted @@ -1739,16 +1653,14 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 220 [00:05:11.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation -Info 221 [00:05:12.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json -Info 222 [00:05:13.000] Scheduled: *ensureProjectForOpenFiles* +Info 208 [00:04:59.000] Running: /user/username/projects/myproject/src/tsconfig.jsonFailedLookupInvalidation +Info 209 [00:05:00.000] Scheduled: /user/username/projects/myproject/src/tsconfig.json +Info 210 [00:05:01.000] Scheduled: *ensureProjectForOpenFiles* After running timeout callbacks PolledWatches:: @@ -1768,8 +1680,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -1794,55 +1704,53 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 223 [00:05:14.000] Running: /user/username/projects/myproject/src/tsconfig.json -Info 224 [00:05:15.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json -Info 225 [00:05:16.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 226 [00:05:17.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 211 [00:05:02.000] Running: /user/username/projects/myproject/src/tsconfig.json +Info 212 [00:05:03.000] Starting updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json +Info 213 [00:05:04.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 214 [00:05:05.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 215 [00:05:06.000] File '/package.json' does not exist according to earlier cached lookups. +Info 216 [00:05:07.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 217 [00:05:08.000] File '/user/username/projects/myproject/package.json' does not exist. +Info 218 [00:05:09.000] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. +Info 219 [00:05:10.000] File '/user/username/package.json' does not exist according to earlier cached lookups. +Info 220 [00:05:11.000] File '/user/package.json' does not exist according to earlier cached lookups. +Info 221 [00:05:12.000] File '/package.json' does not exist according to earlier cached lookups. +Info 222 [00:05:13.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. +Info 223 [00:05:14.000] File '/user/username/projects/myproject/package.json' does not exist according to earlier cached lookups. +Info 224 [00:05:15.000] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. +Info 225 [00:05:16.000] File '/user/username/package.json' does not exist according to earlier cached lookups. +Info 226 [00:05:17.000] File '/user/package.json' does not exist according to earlier cached lookups. Info 227 [00:05:18.000] File '/package.json' does not exist according to earlier cached lookups. -Info 228 [00:05:19.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 229 [00:05:20.000] File '/user/username/projects/myproject/package.json' does not exist. -Info 230 [00:05:21.000] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. -Info 231 [00:05:22.000] File '/user/username/package.json' does not exist according to earlier cached lookups. -Info 232 [00:05:23.000] File '/user/package.json' does not exist according to earlier cached lookups. -Info 233 [00:05:24.000] File '/package.json' does not exist according to earlier cached lookups. -Info 234 [00:05:25.000] File '/user/username/projects/myproject/src/package.json' does not exist according to earlier cached lookups. -Info 235 [00:05:26.000] File '/user/username/projects/myproject/package.json' does not exist according to earlier cached lookups. -Info 236 [00:05:27.000] File '/user/username/projects/package.json' does not exist according to earlier cached lookups. -Info 237 [00:05:28.000] File '/user/username/package.json' does not exist according to earlier cached lookups. -Info 238 [00:05:29.000] File '/user/package.json' does not exist according to earlier cached lookups. -Info 239 [00:05:30.000] File '/package.json' does not exist according to earlier cached lookups. -Info 240 [00:05:31.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. -Info 241 [00:05:32.000] File '/a/package.json' does not exist according to earlier cached lookups. -Info 242 [00:05:33.000] File '/package.json' does not exist according to earlier cached lookups. -Info 243 [00:05:34.000] FileWatcher:: Added:: WatchInfo: /user/username/projects/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution -Info 244 [00:05:35.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 6 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms -Info 245 [00:05:36.000] Different program with same set of files -Info 246 [00:05:37.000] Running: *ensureProjectForOpenFiles* -Info 247 [00:05:38.000] Before ensureProjectForOpenFiles: -Info 248 [00:05:39.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 248 [00:05:40.000] Files (3) - -Info 248 [00:05:41.000] ----------------------------------------------- -Info 248 [00:05:42.000] Open files: -Info 248 [00:05:43.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 248 [00:05:44.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 248 [00:05:45.000] After ensureProjectForOpenFiles: -Info 249 [00:05:46.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) -Info 249 [00:05:47.000] Files (3) - -Info 249 [00:05:48.000] ----------------------------------------------- -Info 249 [00:05:49.000] Open files: -Info 249 [00:05:50.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined -Info 249 [00:05:51.000] Projects: /user/username/projects/myproject/src/tsconfig.json -Info 249 [00:05:52.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts -Info 250 [00:05:53.000] event: +Info 228 [00:05:19.000] File '/a/lib/package.json' does not exist according to earlier cached lookups. +Info 229 [00:05:20.000] File '/a/package.json' does not exist according to earlier cached lookups. +Info 230 [00:05:21.000] File '/package.json' does not exist according to earlier cached lookups. +Info 231 [00:05:22.000] FileWatcher:: Added:: WatchInfo: /user/username/projects/package.json 2000 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: File location affecting resolution +Info 232 [00:05:23.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 6 structureChanged: true structureIsReused:: SafeModules Elapsed:: *ms +Info 233 [00:05:24.000] Different program with same set of files +Info 234 [00:05:25.000] Running: *ensureProjectForOpenFiles* +Info 235 [00:05:26.000] Before ensureProjectForOpenFiles: +Info 236 [00:05:27.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 236 [00:05:28.000] Files (3) + +Info 236 [00:05:29.000] ----------------------------------------------- +Info 236 [00:05:30.000] Open files: +Info 236 [00:05:31.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 236 [00:05:32.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 236 [00:05:33.000] After ensureProjectForOpenFiles: +Info 237 [00:05:34.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured) +Info 237 [00:05:35.000] Files (3) + +Info 237 [00:05:36.000] ----------------------------------------------- +Info 237 [00:05:37.000] Open files: +Info 237 [00:05:38.000] FileName: /user/username/projects/myproject/src/fileA.ts ProjectRootPath: undefined +Info 237 [00:05:39.000] Projects: /user/username/projects/myproject/src/tsconfig.json +Info 237 [00:05:40.000] got projects updated in background, updating diagnostics for /user/username/projects/myproject/src/fileA.ts +Info 238 [00:05:41.000] event: {"seq":0,"type":"event","event":"projectsUpdatedInBackground","body":{"openFiles":["/user/username/projects/myproject/src/fileA.ts"]}} After running timeout callbacks @@ -1865,14 +1773,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 251 [00:05:54.000] request: +Info 239 [00:05:42.000] request: { "command": "geterr", "arguments": { @@ -1905,8 +1811,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -1933,14 +1837,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 252 [00:05:55.000] response: +Info 240 [00:05:43.000] response: { "responseRequired": false } @@ -1965,14 +1867,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 253 [00:05:56.000] event: +Info 241 [00:05:44.000] event: {"seq":0,"type":"event","event":"syntaxDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} After checking timeout queue length (1) and running @@ -1995,8 +1895,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -2023,14 +1921,12 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 254 [00:05:57.000] event: +Info 242 [00:05:45.000] event: {"seq":0,"type":"event","event":"semanticDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[{"start":{"line":1,"offset":21},"end":{"line":1,"offset":34},"text":"The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"./fileB.mjs\")' call instead.\n To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ \"type\": \"module\" }`.","code":1479,"category":"error"}]}} Before running immediate callbacks and checking length (1) @@ -2053,8 +1949,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: @@ -2081,16 +1975,14 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: {} -Info 255 [00:05:58.000] event: +Info 243 [00:05:46.000] event: {"seq":0,"type":"event","event":"suggestionDiag","body":{"file":"/user/username/projects/myproject/src/fileA.ts","diagnostics":[]}} -Info 256 [00:05:59.000] event: +Info 244 [00:05:47.000] event: {"seq":0,"type":"event","event":"requestCompleted","body":{"request_seq":5}} Before running immediate callbacks and checking length (1) @@ -2113,8 +2005,6 @@ FsWatches:: {} /user/username/projects/myproject/package.json: {} -/user/username/projects/myproject/src: - {} FsWatchesRecursive:: /user/username/projects/myproject/src: diff --git a/tests/cases/conformance/moduleResolution/extensionLoadingPriority.ts b/tests/cases/conformance/moduleResolution/extensionLoadingPriority.ts new file mode 100644 index 0000000000000..e486baa1b58ea --- /dev/null +++ b/tests/cases/conformance/moduleResolution/extensionLoadingPriority.ts @@ -0,0 +1,13 @@ +// @moduleResolution: classic,node,node16,nodenext,hybrid +// @allowJs: true +// @checkJs: true +// @noEmit: true + +// @Filename: /project/a.js +export default "a.js"; + +// @Filename: /project/a.js.js +export default "a.js.js"; + +// @Filename: /project/b.ts +import a from "./a.js"; diff --git a/tests/cases/conformance/moduleResolution/hybrid/hybridImportTsExtensions.ts b/tests/cases/conformance/moduleResolution/hybrid/hybridImportTsExtensions.ts new file mode 100644 index 0000000000000..c68d2b7bf2b6b --- /dev/null +++ b/tests/cases/conformance/moduleResolution/hybrid/hybridImportTsExtensions.ts @@ -0,0 +1,60 @@ +// @moduleResolution: hybrid +// @outDir: dist +// @allowJs: true +// @checkJs: true +// @outDir: out +// @noEmit: true,false +// @allowImportingTsExtensions: true,false +// @traceResolution: true + +// @Filename: /project/a.ts +export {}; + +// @Filename: /project/b.ts +export {}; + +// @Filename: /project/b.js +export {}; + +// @Filename: /project/b.d.ts +export {}; + +// @Filename: /project/c.ts +export {}; + +// @Filename: /project/c.tsx +export {}; + +// @Filename: /project/d/index.ts +export {}; + +// @Filename: /project/e +WOMP WOMP BINARY DATA + +// @Filename: /project/e.ts +export {}; + +// @Filename: /project/main.ts +import {} from "./a"; +import {} from "./a.js"; +import {} from "./a.ts"; + +import {} from "./b"; +import {} from "./b.js"; +import {} from "./b.ts"; +import {} from "./b.d.ts"; +import type {} from "./b.d.ts"; + +import {} from "./c.ts"; +import {} from "./c.tsx"; + +import {} from "./d"; +import {} from "./d/index"; +import {} from "./d/index.ts"; + +import {} from "./e"; + +// @Filename: /project/types.d.ts +import {} from "./a.ts"; +import {} from "./a.d.ts"; +import type {} from "./a.d.ts"; \ No newline at end of file From 89bcd0174acbb9dffd4d388e4fb1ea2d5e5ff10a Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 16 Nov 2022 11:57:43 -0800 Subject: [PATCH 24/41] Update test to reflect the choice not to block on unrecognized extensions --- ...sextensions=false,noemit=false).errors.txt | 19 +++++++++++++++++++ ...portingtsextensions=false,noemit=false).js | 16 ++++++++++++++++ ...ngtsextensions=false,noemit=false).symbols | 8 ++++++++ ...sextensions=false,noemit=false).trace.json | 5 +++++ ...tingtsextensions=false,noemit=false).types | 8 ++++++++ ...tsextensions=false,noemit=true).errors.txt | 19 +++++++++++++++++++ ...ingtsextensions=false,noemit=true).symbols | 8 ++++++++ ...tsextensions=false,noemit=true).trace.json | 5 +++++ ...rtingtsextensions=false,noemit=true).types | 8 ++++++++ ...tsextensions=true,noemit=false).errors.txt | 19 +++++++++++++++++++ ...mportingtsextensions=true,noemit=false).js | 16 ++++++++++++++++ ...ingtsextensions=true,noemit=false).symbols | 8 ++++++++ ...tsextensions=true,noemit=false).trace.json | 5 +++++ ...rtingtsextensions=true,noemit=false).types | 8 ++++++++ ...gtsextensions=true,noemit=true).errors.txt | 19 +++++++++++++++++++ ...tingtsextensions=true,noemit=true).symbols | 8 ++++++++ ...gtsextensions=true,noemit=true).trace.json | 5 +++++ ...ortingtsextensions=true,noemit=true).types | 8 ++++++++ .../hybrid/hybridImportTsExtensions.ts | 13 +++++++++++++ 19 files changed, 205 insertions(+) diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt index b88b3f78bb7a3..e679c61f21d2e 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt @@ -1,5 +1,8 @@ error TS5056: Cannot write file 'out/b.js' because it would be overwritten by multiple input files. error TS5056: Cannot write file 'out/c.js' because it would be overwritten by multiple input files. +error TS6054: File '/project/e.txt' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. + The file is in the program because: + Root file specified for compilation /project/main.ts(3,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. /project/main.ts(7,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. /project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? @@ -13,6 +16,9 @@ error TS5056: Cannot write file 'out/c.js' because it would be overwritten by mu !!! error TS5056: Cannot write file 'out/b.js' because it would be overwritten by multiple input files. !!! error TS5056: Cannot write file 'out/c.js' because it would be overwritten by multiple input files. +!!! error TS6054: File '/project/e.txt' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. +!!! error TS6054: The file is in the program because: +!!! error TS6054: Root file specified for compilation ==== /project/a.ts (0 errors) ==== export {}; @@ -40,6 +46,15 @@ error TS5056: Cannot write file 'out/c.js' because it would be overwritten by mu ==== /project/e.ts (0 errors) ==== export {}; +==== /project/e.txt (0 errors) ==== + The letter e is for elephant + This poem is not about elephants + It is about the letter e + - Authored by GitHub Copilot, Nov 2022 + +==== /project/e.txt.ts (0 errors) ==== + export {}; + ==== /project/main.ts (7 errors) ==== import {} from "./a"; import {} from "./a.js"; @@ -72,7 +87,11 @@ error TS5056: Cannot write file 'out/c.js' because it would be overwritten by mu ~~~~~~~~~~~~~~ !!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + // These should not resolve, but preventing them has + // relatively little utility compared to the cost of + // the filesystem hits. import {} from "./e"; + import {} from "./e.txt"; ==== /project/types.d.ts (2 errors) ==== import {} from "./a.ts"; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).js b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).js index f946ec9557b55..82f75ee374412 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).js +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).js @@ -27,6 +27,15 @@ WOMP WOMP BINARY DATA //// [e.ts] export {}; +//// [e.txt] +The letter e is for elephant +This poem is not about elephants +It is about the letter e +- Authored by GitHub Copilot, Nov 2022 + +//// [e.txt.ts] +export {}; + //// [main.ts] import {} from "./a"; import {} from "./a.js"; @@ -45,7 +54,11 @@ import {} from "./d"; import {} from "./d/index"; import {} from "./d/index.ts"; +// These should not resolve, but preventing them has +// relatively little utility compared to the cost of +// the filesystem hits. import {} from "./e"; +import {} from "./e.txt"; //// [types.d.ts] import {} from "./a.ts"; @@ -61,6 +74,9 @@ exports.__esModule = true; //// [e.js] "use strict"; exports.__esModule = true; +//// [e.txt.js] +"use strict"; +exports.__esModule = true; //// [main.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).symbols b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).symbols index bcf03f8d9917e..3c1dc17c50c28 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).symbols +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).symbols @@ -30,6 +30,10 @@ export {}; export {}; +=== /project/e.txt.ts === + +export {}; + === /project/main.ts === import {} from "./a"; @@ -49,7 +53,11 @@ import {} from "./d"; import {} from "./d/index"; import {} from "./d/index.ts"; +// These should not resolve, but preventing them has +// relatively little utility compared to the cost of +// the filesystem hits. import {} from "./e"; +import {} from "./e.txt"; === /project/types.d.ts === diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json index 07d7414565e53..c248542bacc88 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json @@ -78,6 +78,11 @@ "Loading module as file / folder, candidate module location '/project/e', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/e.ts' exist - use it as a name resolution result.", "======== Module name './e' was successfully resolved to '/project/e.ts'. ========", + "======== Resolving module './e.txt' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/e.txt', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/project/e.txt.ts' exist - use it as a name resolution result.", + "======== Module name './e.txt' was successfully resolved to '/project/e.txt.ts'. ========", "======== Resolving module './a.ts' from '/project/types.d.ts'. ========", "Resolution for module './a.ts' was found in cache from location '/project'.", "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).types b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).types index bcf03f8d9917e..3c1dc17c50c28 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).types +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).types @@ -30,6 +30,10 @@ export {}; export {}; +=== /project/e.txt.ts === + +export {}; + === /project/main.ts === import {} from "./a"; @@ -49,7 +53,11 @@ import {} from "./d"; import {} from "./d/index"; import {} from "./d/index.ts"; +// These should not resolve, but preventing them has +// relatively little utility compared to the cost of +// the filesystem hits. import {} from "./e"; +import {} from "./e.txt"; === /project/types.d.ts === diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt index cc93517215702..a90647850052e 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt @@ -1,3 +1,6 @@ +error TS6054: File '/project/e.txt' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. + The file is in the program because: + Root file specified for compilation /project/main.ts(3,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. /project/main.ts(7,16): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. /project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? @@ -9,6 +12,9 @@ /project/types.d.ts(3,21): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. +!!! error TS6054: File '/project/e.txt' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. +!!! error TS6054: The file is in the program because: +!!! error TS6054: Root file specified for compilation ==== /project/a.ts (0 errors) ==== export {}; @@ -36,6 +42,15 @@ ==== /project/e.ts (0 errors) ==== export {}; +==== /project/e.txt (0 errors) ==== + The letter e is for elephant + This poem is not about elephants + It is about the letter e + - Authored by GitHub Copilot, Nov 2022 + +==== /project/e.txt.ts (0 errors) ==== + export {}; + ==== /project/main.ts (7 errors) ==== import {} from "./a"; import {} from "./a.js"; @@ -68,7 +83,11 @@ ~~~~~~~~~~~~~~ !!! error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. + // These should not resolve, but preventing them has + // relatively little utility compared to the cost of + // the filesystem hits. import {} from "./e"; + import {} from "./e.txt"; ==== /project/types.d.ts (2 errors) ==== import {} from "./a.ts"; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).symbols b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).symbols index bcf03f8d9917e..3c1dc17c50c28 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).symbols +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).symbols @@ -30,6 +30,10 @@ export {}; export {}; +=== /project/e.txt.ts === + +export {}; + === /project/main.ts === import {} from "./a"; @@ -49,7 +53,11 @@ import {} from "./d"; import {} from "./d/index"; import {} from "./d/index.ts"; +// These should not resolve, but preventing them has +// relatively little utility compared to the cost of +// the filesystem hits. import {} from "./e"; +import {} from "./e.txt"; === /project/types.d.ts === diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json index 07d7414565e53..c248542bacc88 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json @@ -78,6 +78,11 @@ "Loading module as file / folder, candidate module location '/project/e', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/e.ts' exist - use it as a name resolution result.", "======== Module name './e' was successfully resolved to '/project/e.ts'. ========", + "======== Resolving module './e.txt' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/e.txt', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/project/e.txt.ts' exist - use it as a name resolution result.", + "======== Module name './e.txt' was successfully resolved to '/project/e.txt.ts'. ========", "======== Resolving module './a.ts' from '/project/types.d.ts'. ========", "Resolution for module './a.ts' was found in cache from location '/project'.", "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).types b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).types index bcf03f8d9917e..3c1dc17c50c28 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).types +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).types @@ -30,6 +30,10 @@ export {}; export {}; +=== /project/e.txt.ts === + +export {}; + === /project/main.ts === import {} from "./a"; @@ -49,7 +53,11 @@ import {} from "./d"; import {} from "./d/index"; import {} from "./d/index.ts"; +// These should not resolve, but preventing them has +// relatively little utility compared to the cost of +// the filesystem hits. import {} from "./e"; +import {} from "./e.txt"; === /project/types.d.ts === diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt index 1e93929f4b534..d8c5a67083615 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt @@ -1,6 +1,9 @@ error TS5056: Cannot write file 'out/b.js' because it would be overwritten by multiple input files. error TS5056: Cannot write file 'out/c.js' because it would be overwritten by multiple input files. error TS5096: Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'hybrid' and either 'noEmit' or 'emitDeclarationOnly' is set. +error TS6054: File '/project/e.txt' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. + The file is in the program because: + Root file specified for compilation /project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? /project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. /project/types.d.ts(2,16): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. @@ -10,6 +13,9 @@ error TS5096: Option 'allowImportingTsExtensions' can only be used when 'moduleR !!! error TS5056: Cannot write file 'out/b.js' because it would be overwritten by multiple input files. !!! error TS5056: Cannot write file 'out/c.js' because it would be overwritten by multiple input files. !!! error TS5096: Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'hybrid' and either 'noEmit' or 'emitDeclarationOnly' is set. +!!! error TS6054: File '/project/e.txt' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. +!!! error TS6054: The file is in the program because: +!!! error TS6054: Root file specified for compilation ==== /project/a.ts (0 errors) ==== export {}; @@ -37,6 +43,15 @@ error TS5096: Option 'allowImportingTsExtensions' can only be used when 'moduleR ==== /project/e.ts (0 errors) ==== export {}; +==== /project/e.txt (0 errors) ==== + The letter e is for elephant + This poem is not about elephants + It is about the letter e + - Authored by GitHub Copilot, Nov 2022 + +==== /project/e.txt.ts (0 errors) ==== + export {}; + ==== /project/main.ts (2 errors) ==== import {} from "./a"; import {} from "./a.js"; @@ -59,7 +74,11 @@ error TS5096: Option 'allowImportingTsExtensions' can only be used when 'moduleR import {} from "./d/index"; import {} from "./d/index.ts"; + // These should not resolve, but preventing them has + // relatively little utility compared to the cost of + // the filesystem hits. import {} from "./e"; + import {} from "./e.txt"; ==== /project/types.d.ts (2 errors) ==== import {} from "./a.ts"; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).js b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).js index f946ec9557b55..82f75ee374412 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).js +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).js @@ -27,6 +27,15 @@ WOMP WOMP BINARY DATA //// [e.ts] export {}; +//// [e.txt] +The letter e is for elephant +This poem is not about elephants +It is about the letter e +- Authored by GitHub Copilot, Nov 2022 + +//// [e.txt.ts] +export {}; + //// [main.ts] import {} from "./a"; import {} from "./a.js"; @@ -45,7 +54,11 @@ import {} from "./d"; import {} from "./d/index"; import {} from "./d/index.ts"; +// These should not resolve, but preventing them has +// relatively little utility compared to the cost of +// the filesystem hits. import {} from "./e"; +import {} from "./e.txt"; //// [types.d.ts] import {} from "./a.ts"; @@ -61,6 +74,9 @@ exports.__esModule = true; //// [e.js] "use strict"; exports.__esModule = true; +//// [e.txt.js] +"use strict"; +exports.__esModule = true; //// [main.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).symbols b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).symbols index bcf03f8d9917e..3c1dc17c50c28 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).symbols +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).symbols @@ -30,6 +30,10 @@ export {}; export {}; +=== /project/e.txt.ts === + +export {}; + === /project/main.ts === import {} from "./a"; @@ -49,7 +53,11 @@ import {} from "./d"; import {} from "./d/index"; import {} from "./d/index.ts"; +// These should not resolve, but preventing them has +// relatively little utility compared to the cost of +// the filesystem hits. import {} from "./e"; +import {} from "./e.txt"; === /project/types.d.ts === diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json index 07d7414565e53..c248542bacc88 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json @@ -78,6 +78,11 @@ "Loading module as file / folder, candidate module location '/project/e', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/e.ts' exist - use it as a name resolution result.", "======== Module name './e' was successfully resolved to '/project/e.ts'. ========", + "======== Resolving module './e.txt' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/e.txt', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/project/e.txt.ts' exist - use it as a name resolution result.", + "======== Module name './e.txt' was successfully resolved to '/project/e.txt.ts'. ========", "======== Resolving module './a.ts' from '/project/types.d.ts'. ========", "Resolution for module './a.ts' was found in cache from location '/project'.", "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).types b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).types index bcf03f8d9917e..3c1dc17c50c28 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).types +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).types @@ -30,6 +30,10 @@ export {}; export {}; +=== /project/e.txt.ts === + +export {}; + === /project/main.ts === import {} from "./a"; @@ -49,7 +53,11 @@ import {} from "./d"; import {} from "./d/index"; import {} from "./d/index.ts"; +// These should not resolve, but preventing them has +// relatively little utility compared to the cost of +// the filesystem hits. import {} from "./e"; +import {} from "./e.txt"; === /project/types.d.ts === diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt index cdf02ebb53120..394208e16ad02 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt @@ -1,9 +1,15 @@ +error TS6054: File '/project/e.txt' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. + The file is in the program because: + Root file specified for compilation /project/main.ts(8,16): error TS2846: A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file './b' instead? /project/main.ts(12,16): error TS6142: Module './c.tsx' was resolved to '/project/c.tsx', but '--jsx' is not set. /project/types.d.ts(2,16): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. /project/types.d.ts(3,21): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './a' instead. +!!! error TS6054: File '/project/e.txt' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. +!!! error TS6054: The file is in the program because: +!!! error TS6054: Root file specified for compilation ==== /project/a.ts (0 errors) ==== export {}; @@ -31,6 +37,15 @@ ==== /project/e.ts (0 errors) ==== export {}; +==== /project/e.txt (0 errors) ==== + The letter e is for elephant + This poem is not about elephants + It is about the letter e + - Authored by GitHub Copilot, Nov 2022 + +==== /project/e.txt.ts (0 errors) ==== + export {}; + ==== /project/main.ts (2 errors) ==== import {} from "./a"; import {} from "./a.js"; @@ -53,7 +68,11 @@ import {} from "./d/index"; import {} from "./d/index.ts"; + // These should not resolve, but preventing them has + // relatively little utility compared to the cost of + // the filesystem hits. import {} from "./e"; + import {} from "./e.txt"; ==== /project/types.d.ts (2 errors) ==== import {} from "./a.ts"; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).symbols b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).symbols index bcf03f8d9917e..3c1dc17c50c28 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).symbols +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).symbols @@ -30,6 +30,10 @@ export {}; export {}; +=== /project/e.txt.ts === + +export {}; + === /project/main.ts === import {} from "./a"; @@ -49,7 +53,11 @@ import {} from "./d"; import {} from "./d/index"; import {} from "./d/index.ts"; +// These should not resolve, but preventing them has +// relatively little utility compared to the cost of +// the filesystem hits. import {} from "./e"; +import {} from "./e.txt"; === /project/types.d.ts === diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json index 07d7414565e53..c248542bacc88 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json @@ -78,6 +78,11 @@ "Loading module as file / folder, candidate module location '/project/e', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/e.ts' exist - use it as a name resolution result.", "======== Module name './e' was successfully resolved to '/project/e.ts'. ========", + "======== Resolving module './e.txt' from '/project/main.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "Loading module as file / folder, candidate module location '/project/e.txt', target file types: TypeScript, JavaScript, Declaration, JSON.", + "File '/project/e.txt.ts' exist - use it as a name resolution result.", + "======== Module name './e.txt' was successfully resolved to '/project/e.txt.ts'. ========", "======== Resolving module './a.ts' from '/project/types.d.ts'. ========", "Resolution for module './a.ts' was found in cache from location '/project'.", "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).types b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).types index bcf03f8d9917e..3c1dc17c50c28 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).types +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).types @@ -30,6 +30,10 @@ export {}; export {}; +=== /project/e.txt.ts === + +export {}; + === /project/main.ts === import {} from "./a"; @@ -49,7 +53,11 @@ import {} from "./d"; import {} from "./d/index"; import {} from "./d/index.ts"; +// These should not resolve, but preventing them has +// relatively little utility compared to the cost of +// the filesystem hits. import {} from "./e"; +import {} from "./e.txt"; === /project/types.d.ts === diff --git a/tests/cases/conformance/moduleResolution/hybrid/hybridImportTsExtensions.ts b/tests/cases/conformance/moduleResolution/hybrid/hybridImportTsExtensions.ts index c68d2b7bf2b6b..8cb7141e5c409 100644 --- a/tests/cases/conformance/moduleResolution/hybrid/hybridImportTsExtensions.ts +++ b/tests/cases/conformance/moduleResolution/hybrid/hybridImportTsExtensions.ts @@ -34,6 +34,15 @@ WOMP WOMP BINARY DATA // @Filename: /project/e.ts export {}; +// @Filename: /project/e.txt +The letter e is for elephant +This poem is not about elephants +It is about the letter e +- Authored by GitHub Copilot, Nov 2022 + +// @Filename: /project/e.txt.ts +export {}; + // @Filename: /project/main.ts import {} from "./a"; import {} from "./a.js"; @@ -52,7 +61,11 @@ import {} from "./d"; import {} from "./d/index"; import {} from "./d/index.ts"; +// These should not resolve, but preventing them has +// relatively little utility compared to the cost of +// the filesystem hits. import {} from "./e"; +import {} from "./e.txt"; // @Filename: /project/types.d.ts import {} from "./a.ts"; From 60746617661f78b640184b4186ae4066122fcbdb Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 16 Nov 2022 17:16:44 -0800 Subject: [PATCH 25/41] Add auto-imports and string completions tests --- src/compiler/moduleSpecifiers.ts | 3 +- src/services/stringCompletions.ts | 10 +++--- .../autoImportAllowTsExtensions1.baseline.md | 36 +++++++++++++++++++ .../autoImportAllowTsExtensions2.baseline.md | 36 +++++++++++++++++++ .../autoImportAllowTsExtensions3.baseline.md | 16 +++++++++ .../fourslash/autoImportAllowTsExtensions1.ts | 22 ++++++++++++ .../fourslash/autoImportAllowTsExtensions2.ts | 22 ++++++++++++ .../fourslash/autoImportAllowTsExtensions3.ts | 17 +++++++++ .../pathCompletionsAllowTsExtensions.ts | 34 ++++++++++++++++++ 9 files changed, 190 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/autoImportAllowTsExtensions1.baseline.md create mode 100644 tests/baselines/reference/autoImportAllowTsExtensions2.baseline.md create mode 100644 tests/baselines/reference/autoImportAllowTsExtensions3.baseline.md create mode 100644 tests/cases/fourslash/autoImportAllowTsExtensions1.ts create mode 100644 tests/cases/fourslash/autoImportAllowTsExtensions2.ts create mode 100644 tests/cases/fourslash/autoImportAllowTsExtensions3.ts create mode 100644 tests/cases/fourslash/pathCompletionsAllowTsExtensions.ts diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index 9218f31031fb3..4505f83bbfd8f 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -458,7 +458,8 @@ export function countPathComponents(path: string): number { return count; } -function usesExtensionsOnImports({ imports }: SourceFile): boolean { +/** @internal */ +export function usesExtensionsOnImports({ imports }: SourceFile): boolean { return firstDefined(imports, ({ text }) => pathIsRelative(text) ? (hasJSFileExtension(text) || hasTSFileExtension(text)) : undefined) || false; } diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index bedf79a2b19f8..70c9d6099001e 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -1,3 +1,4 @@ +import { usesExtensionsOnImports } from "../compiler/moduleSpecifiers"; import { addToSeen, altDirectorySeparator, arrayFrom, CallLikeExpression, CancellationToken, changeExtension, CharacterCodes, combinePaths, comparePaths, comparePatternKeys, compareStringsCaseSensitive, compareValues, Comparison, @@ -409,12 +410,11 @@ function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile: SourceFile : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, getIncludeExtensionOption(), typeChecker); function getIncludeExtensionOption() { - if (shouldAllowImportingTsExtension(compilerOptions)) { - return IncludeExtensionsOption.Include; - } const mode = isStringLiteralLike(node) ? getModeForUsageLocation(sourceFile, node) : undefined; - return preferences.importModuleSpecifierEnding === "js" || mode === ModuleKind.ESNext - ? IncludeExtensionsOption.ModuleSpecifierCompletion + return preferences.importModuleSpecifierEnding === "js" || mode === ModuleKind.ESNext || usesExtensionsOnImports(sourceFile) + ? shouldAllowImportingTsExtension(compilerOptions) + ? IncludeExtensionsOption.Include + : IncludeExtensionsOption.ModuleSpecifierCompletion : IncludeExtensionsOption.Exclude; } } diff --git a/tests/baselines/reference/autoImportAllowTsExtensions1.baseline.md b/tests/baselines/reference/autoImportAllowTsExtensions1.baseline.md new file mode 100644 index 0000000000000..0e3c27ce7e96a --- /dev/null +++ b/tests/baselines/reference/autoImportAllowTsExtensions1.baseline.md @@ -0,0 +1,36 @@ +```ts +// @Filename: /main.ts +/*|*/ +``` + +## From completions + +- `Component` from `"./Component"` +- `fromAtTypesFoo` from `"foo"` +- `fromBar` from `"bar"` +- `fromLocal` from `"./local"` + +```ts +import { Component } from "./Component"; + +Component +``` + +```ts +import { fromAtTypesFoo } from "foo"; + +fromAtTypesFoo +``` + +```ts +import { fromBar } from "bar"; + +fromBar +``` + +```ts +import { fromLocal } from "./local"; + +fromLocal +``` + diff --git a/tests/baselines/reference/autoImportAllowTsExtensions2.baseline.md b/tests/baselines/reference/autoImportAllowTsExtensions2.baseline.md new file mode 100644 index 0000000000000..1117148b1877d --- /dev/null +++ b/tests/baselines/reference/autoImportAllowTsExtensions2.baseline.md @@ -0,0 +1,36 @@ +```ts +// @Filename: /main.ts +/*|*/ +``` + +## From completions + +- `Component` from `"./Component.tsx"` +- `fromAtTypesFoo` from `"foo"` +- `fromBar` from `"bar"` +- `fromLocal` from `"./local.ts"` + +```ts +import { Component } from "./Component.tsx"; + +Component +``` + +```ts +import { fromAtTypesFoo } from "foo"; + +fromAtTypesFoo +``` + +```ts +import { fromBar } from "bar"; + +fromBar +``` + +```ts +import { fromLocal } from "./local.ts"; + +fromLocal +``` + diff --git a/tests/baselines/reference/autoImportAllowTsExtensions3.baseline.md b/tests/baselines/reference/autoImportAllowTsExtensions3.baseline.md new file mode 100644 index 0000000000000..77fea133b581f --- /dev/null +++ b/tests/baselines/reference/autoImportAllowTsExtensions3.baseline.md @@ -0,0 +1,16 @@ +```ts +// @Filename: /main.ts +import { Component } from "./Component.tsx"; +/*|*/ +``` + +## From completions + +- `fromLocal` from `"./local.ts"` + +```ts +import { Component } from "./Component.tsx"; +import { fromLocal } from "./local.ts"; +fromLocal +``` + diff --git a/tests/cases/fourslash/autoImportAllowTsExtensions1.ts b/tests/cases/fourslash/autoImportAllowTsExtensions1.ts new file mode 100644 index 0000000000000..882ab404669b9 --- /dev/null +++ b/tests/cases/fourslash/autoImportAllowTsExtensions1.ts @@ -0,0 +1,22 @@ +/// + +// @moduleResolution: hybrid +// @allowImportingTsExtensions: true +// @noEmit: true + +// @Filename: /node_modules/@types/foo/index.d.ts +//// export const fromAtTypesFoo: number; + +// @Filename: /node_modules/bar/index.d.ts +//// export const fromBar: number; + +// @Filename: /local.ts +//// export const fromLocal: number; + +// @Filename: /Component.tsx +//// export function Component() { return null; } + +// @Filename: /main.ts +//// /**/ + +verify.baselineAutoImports(""); diff --git a/tests/cases/fourslash/autoImportAllowTsExtensions2.ts b/tests/cases/fourslash/autoImportAllowTsExtensions2.ts new file mode 100644 index 0000000000000..84eda57047a35 --- /dev/null +++ b/tests/cases/fourslash/autoImportAllowTsExtensions2.ts @@ -0,0 +1,22 @@ +/// + +// @moduleResolution: hybrid +// @allowImportingTsExtensions: true +// @noEmit: true + +// @Filename: /node_modules/@types/foo/index.d.ts +//// export const fromAtTypesFoo: number; + +// @Filename: /node_modules/bar/index.d.ts +//// export const fromBar: number; + +// @Filename: /local.ts +//// export const fromLocal: number; + +// @Filename: /Component.tsx +//// export function Component() { return null; } + +// @Filename: /main.ts +//// /**/ + +verify.baselineAutoImports("", { importModuleSpecifierEnding: "js" }); diff --git a/tests/cases/fourslash/autoImportAllowTsExtensions3.ts b/tests/cases/fourslash/autoImportAllowTsExtensions3.ts new file mode 100644 index 0000000000000..9fcfbc53a0fbe --- /dev/null +++ b/tests/cases/fourslash/autoImportAllowTsExtensions3.ts @@ -0,0 +1,17 @@ +/// + +// @moduleResolution: hybrid +// @allowImportingTsExtensions: true +// @noEmit: true + +// @Filename: /local.ts +//// export const fromLocal: number; + +// @Filename: /Component.tsx +//// export function Component() { return null; } + +// @Filename: /main.ts +//// import { Component } from "./Component.tsx"; +//// /**/ + +verify.baselineAutoImports(""); diff --git a/tests/cases/fourslash/pathCompletionsAllowTsExtensions.ts b/tests/cases/fourslash/pathCompletionsAllowTsExtensions.ts new file mode 100644 index 0000000000000..f0dccd98e71b4 --- /dev/null +++ b/tests/cases/fourslash/pathCompletionsAllowTsExtensions.ts @@ -0,0 +1,34 @@ +/// + +// @moduleResolution: hybrid +// @allowImportingTsExtensions: true +// @noEmit: true + +// @Filename: /project/foo.ts +//// export const foo = 0; + +// @Filename: /project/main.ts +//// import {} from ".//**/" + +verify.completions({ + marker: "", + isNewIdentifierLocation: true, + exact: ["foo"], +}); + +verify.completions({ + marker: "", + isNewIdentifierLocation: true, + exact: ["foo.ts"], + preferences: { + importModuleSpecifierEnding: "js", + }, +}); + +edit.insert(`foo.ts"\nimport {} from "./`); + +verify.completions({ + marker: "", + isNewIdentifierLocation: true, + exact: ["foo.ts"], +}); From fa188b1d3b57fdf038a7092f9193e585c29ec154 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 18 Nov 2022 13:34:49 -0800 Subject: [PATCH 26/41] Revamp string completions ending preferences --- src/compiler/moduleSpecifiers.ts | 109 ++++++++++-------------------- src/compiler/utilities.ts | 88 +++++++++++++++++++++++- src/services/stringCompletions.ts | 96 +++++++++++++++----------- 3 files changed, 179 insertions(+), 114 deletions(-) diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index 9218f31031fb3..440c03ccbc691 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -4,7 +4,7 @@ import { containsPath, createGetCanonicalFileName, Debug, directorySeparator, emptyArray, endsWith, ensurePathIsNonModuleName, ensureTrailingDirectorySeparator, every, ExportAssignment, Extension, extensionFromPath, fileExtensionIsOneOf, FileIncludeKind, firstDefined, flatMap, flatten, forEach, forEachAncestorDirectory, - GetCanonicalFileName, getDirectoryPath, getEmitModuleResolutionKind, getImpliedNodeFormatForFile, + GetCanonicalFileName, getDirectoryPath, getEmitModuleResolutionKind, getModeForResolutionAtIndex, getModuleNameStringLiteralAt, getNodeModulePathParts, getNormalizedAbsolutePath, getOwnKeys, getPackageJsonTypesVersionsPaths, getPackageNameFromTypesPackageName, getPathsBasePath, getRelativePathFromDirectory, getRelativePathToDirectoryOrUrl, getSourceFileOfModule, getSupportedExtensions, @@ -12,18 +12,16 @@ import { isAmbientModule, isApplicableVersionedTypesKey, isExternalModuleAugmentation, isExternalModuleNameRelative, isModuleBlock, isModuleDeclaration, isNonGlobalAmbientModule, isRootedDiskPath, isSourceFile, isString, JsxEmit, map, mapDefined, MapLike, matchPatternOrExact, min, ModuleDeclaration, ModuleKind, ModulePath, - ModuleResolutionHost, ModuleResolutionKind, ModuleSpecifierCache, ModuleSpecifierOptions, + ModuleResolutionKind, ModuleSpecifierCache, ModuleSpecifierOptions, ModuleSpecifierResolutionHost, NodeFlags, NodeModulePathParts, normalizePath, Path, pathContainsNodeModules, pathIsBareSpecifier, pathIsRelative, PropertyAccessExpression, removeFileExtension, removeSuffix, resolvePath, ScriptKind, some, SourceFile, startsWith, startsWithDirectory, stringContains, StringLiteral, Symbol, SymbolFlags, - toPath, tryGetExtensionFromPath, tryParsePatterns, TypeChecker, UserPreferences, shouldAllowImportingTsExtension, ResolutionMode, + toPath, tryGetExtensionFromPath, tryParsePatterns, TypeChecker, UserPreferences, shouldAllowImportingTsExtension, ResolutionMode, ModuleSpecifierEnding, getModuleSpecifierEndingPreference, } from "./_namespaces/ts"; // Used by importFixes, getEditsForFileRename, and declaration emit to synthesize import module specifiers. const enum RelativePreference { Relative, NonRelative, Shortest, ExternalNonRelative } -// See UserPreferences#importPathEnding -const enum Ending { Minimal, Index, JsExtension, TsExtension } // Processed preferences interface Preferences { @@ -31,11 +29,10 @@ interface Preferences { /** * @param syntaxImpliedNodeFormat Used when the import syntax implies ESM or CJS irrespective of the mode of the file. */ - getAllowedEndingsInPrefererredOrder(syntaxImpliedNodeFormat?: SourceFile["impliedNodeFormat"]): Ending[]; + getAllowedEndingsInPrefererredOrder(syntaxImpliedNodeFormat?: SourceFile["impliedNodeFormat"]): ModuleSpecifierEnding[]; } function getPreferences( - host: ModuleSpecifierResolutionHost, { importModuleSpecifierPreference, importModuleSpecifierEnding }: UserPreferences, compilerOptions: CompilerOptions, importingSourceFile: SourceFile, @@ -52,66 +49,38 @@ function getPreferences( importModuleSpecifierPreference === "project-relative" ? RelativePreference.ExternalNonRelative : RelativePreference.Shortest, getAllowedEndingsInPrefererredOrder: syntaxImpliedNodeFormat => { - if (syntaxImpliedNodeFormat === ModuleKind.ESNext || isFormatRequiringExtensions()) { + if (syntaxImpliedNodeFormat === ModuleKind.ESNext || (syntaxImpliedNodeFormat ?? importingSourceFile.impliedNodeFormat) === ModuleKind.ESNext) { if (shouldAllowImportingTsExtension(compilerOptions, importingSourceFile.fileName)) { - return [Ending.TsExtension, Ending.JsExtension]; + return [ModuleSpecifierEnding.TsExtension, ModuleSpecifierEnding.JsExtension]; } - return [Ending.JsExtension]; + return [ModuleSpecifierEnding.JsExtension]; } if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Classic) { - return [Ending.Index, Ending.JsExtension]; + return [ModuleSpecifierEnding.Index, ModuleSpecifierEnding.JsExtension]; } switch (preferredEnding) { - case Ending.JsExtension: return [Ending.JsExtension, Ending.Minimal, Ending.Index]; - case Ending.TsExtension: return [Ending.TsExtension, Ending.TsExtension, Ending.Minimal, Ending.Index]; - case Ending.Index: return [Ending.Index, Ending.Minimal, Ending.JsExtension]; - case Ending.Minimal: return [Ending.Minimal, Ending.Index, Ending.JsExtension]; + case ModuleSpecifierEnding.JsExtension: return [ModuleSpecifierEnding.JsExtension, ModuleSpecifierEnding.Minimal, ModuleSpecifierEnding.Index]; + case ModuleSpecifierEnding.TsExtension: return [ModuleSpecifierEnding.TsExtension, ModuleSpecifierEnding.TsExtension, ModuleSpecifierEnding.Minimal, ModuleSpecifierEnding.Index]; + case ModuleSpecifierEnding.Index: return [ModuleSpecifierEnding.Index, ModuleSpecifierEnding.Minimal, ModuleSpecifierEnding.JsExtension]; + case ModuleSpecifierEnding.Minimal: return [ModuleSpecifierEnding.Minimal, ModuleSpecifierEnding.Index, ModuleSpecifierEnding.JsExtension]; default: Debug.assertNever(preferredEnding); } }, }; - function getPreferredEnding(): Ending { + function getPreferredEnding(): ModuleSpecifierEnding { if (oldImportSpecifier !== undefined) { - if (hasJSFileExtension(oldImportSpecifier)) return Ending.JsExtension; - if (endsWith(oldImportSpecifier, "/index")) return Ending.Index; - } - switch (importModuleSpecifierEnding) { - case "minimal": return Ending.Minimal; - case "index": return Ending.Index; - case "js": return shouldAllowImportingTsExtension(compilerOptions) ? Ending.TsExtension : Ending.JsExtension; - default: return usesExtensionsOnImports(importingSourceFile) - ? shouldAllowImportingTsExtension(compilerOptions) ? Ending.TsExtension : Ending.JsExtension - : Ending.Minimal; - } - } - - function isFormatRequiringExtensions() { - switch (getEmitModuleResolutionKind(compilerOptions)) { - case ModuleResolutionKind.Node16: - case ModuleResolutionKind.NodeNext: - return getImpliedNodeFormatForFile( - importingSourceFile.path, - host.getPackageJsonInfoCache?.(), - getModuleResolutionHost(host), compilerOptions, - ) !== ModuleKind.CommonJS; - default: - return false; + if (hasJSFileExtension(oldImportSpecifier)) return ModuleSpecifierEnding.JsExtension; + if (endsWith(oldImportSpecifier, "/index")) return ModuleSpecifierEnding.Index; } + return getModuleSpecifierEndingPreference( + importModuleSpecifierEnding, + importingSourceFile.impliedNodeFormat, + compilerOptions, + importingSourceFile); } } -function getModuleResolutionHost(host: ModuleSpecifierResolutionHost): ModuleResolutionHost { - return { - fileExists: host.fileExists, - readFile: Debug.checkDefined(host.readFile), - directoryExists: host.directoryExists, - getCurrentDirectory: host.getCurrentDirectory, - realpath: host.realpath, - useCaseSensitiveFileNames: host.useCaseSensitiveFileNames?.(), - }; -} - // `importingSourceFile` and `importingSourceFileName`? Why not just use `importingSourceFile.path`? // Because when this is called by the file renamer, `importingSourceFile` is the file being renamed, // while `importingSourceFileName` its *new* name. We need a source file just to get its @@ -126,7 +95,7 @@ export function updateModuleSpecifier( oldImportSpecifier: string, options: ModuleSpecifierOptions = {}, ): string | undefined { - const res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile, oldImportSpecifier), {}, options); + const res = getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferences({}, compilerOptions, importingSourceFile, oldImportSpecifier), {}, options); if (res === oldImportSpecifier) return undefined; return res; } @@ -146,7 +115,7 @@ export function getModuleSpecifier( host: ModuleSpecifierResolutionHost, options: ModuleSpecifierOptions = {}, ): string { - return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferences(host, {}, compilerOptions, importingSourceFile), {}, options); + return getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, getPreferences({}, compilerOptions, importingSourceFile), {}, options); } /** @internal */ @@ -279,7 +248,7 @@ function computeModuleSpecifiers( options: ModuleSpecifierOptions = {}, ): readonly string[] { const info = getInfo(importingSourceFile.path, host); - const preferences = getPreferences(host, userPreferences, compilerOptions, importingSourceFile); + const preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); const existingSpecifier = forEach(modulePaths, modulePath => forEach( host.getFileIncludeReasons().get(toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)), reason => { @@ -458,10 +427,6 @@ export function countPathComponents(path: string): number { return count; } -function usesExtensionsOnImports({ imports }: SourceFile): boolean { - return firstDefined(imports, ({ text }) => pathIsRelative(text) ? (hasJSFileExtension(text) || hasTSFileExtension(text)) : undefined) || false; -} - function comparePathsByRedirectAndNumberOfDirectorySeparators(a: ModulePath, b: ModulePath) { return compareBooleans(b.isRedirect, a.isRedirect) || compareNumberOfDirectorySeparators(a.path, b.path); } @@ -648,7 +613,7 @@ function tryGetModuleNameFromAmbientModule(moduleSymbol: Symbol, checker: TypeCh } } -function tryGetModuleNameFromPaths(relativeToBaseUrl: string, paths: MapLike, allowedEndings: Ending[], host: ModuleSpecifierResolutionHost, compilerOptions: CompilerOptions): string | undefined { +function tryGetModuleNameFromPaths(relativeToBaseUrl: string, paths: MapLike, allowedEndings: ModuleSpecifierEnding[], host: ModuleSpecifierResolutionHost, compilerOptions: CompilerOptions): string | undefined { for (const key in paths) { for (const patternText of paths[key]) { const pattern = normalizePath(patternText); @@ -689,7 +654,7 @@ function tryGetModuleNameFromPaths(relativeToBaseUrl: string, paths: MapLike ({ + const candidates: { ending: ModuleSpecifierEnding | undefined, value: string }[] = allowedEndings.map(ending => ({ ending, value: processEnding(relativeToBaseUrl, ending, compilerOptions) })); @@ -712,23 +677,23 @@ function tryGetModuleNameFromPaths(relativeToBaseUrl: string, paths: MapLike c.ending !== Ending.Minimal && pattern === c.value) || - some(candidates, c => c.ending === Ending.Minimal && pattern === c.value && validateEnding(c)) + some(candidates, c => c.ending !== ModuleSpecifierEnding.Minimal && pattern === c.value) || + some(candidates, c => c.ending === ModuleSpecifierEnding.Minimal && pattern === c.value && validateEnding(c)) ) { return key; } } } - function validateEnding({ ending, value }: { ending: Ending | undefined, value: string }) { + function validateEnding({ ending, value }: { ending: ModuleSpecifierEnding | undefined, value: string }) { // Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename // is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only // here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls), // do we check that the host-validated result is consistent with the answer we got before. If it's not, it falls back to the - // `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is + // `ModuleSpecifierEnding.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is // that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally // everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.) - return ending !== Ending.Minimal || value === processEnding(relativeToBaseUrl, ending, compilerOptions, host); + return ending !== ModuleSpecifierEnding.Minimal || value === processEnding(relativeToBaseUrl, ending, compilerOptions, host); } } @@ -803,7 +768,7 @@ function tryGetModuleNameFromExports(options: CompilerOptions, targetFilePath: s return undefined; } -function tryGetModuleNameFromRootDirs(rootDirs: readonly string[], moduleFileName: string, sourceDirectory: string, getCanonicalFileName: (file: string) => string, ending: Ending, compilerOptions: CompilerOptions): string | undefined { +function tryGetModuleNameFromRootDirs(rootDirs: readonly string[], moduleFileName: string, sourceDirectory: string, getCanonicalFileName: (file: string) => string, ending: ModuleSpecifierEnding, compilerOptions: CompilerOptions): string | undefined { const normalizedTargetPaths = getPathsRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); if (normalizedTargetPaths === undefined) { return undefined; @@ -831,7 +796,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }: ModulePath, { getCan // Simplify the full file path to something that can be resolved by Node. - const preferences = getPreferences(host, userPreferences, options, importingSourceFile); + const preferences = getPreferences(userPreferences, options, importingSourceFile); const allowedEndings = preferences.getAllowedEndingsInPrefererredOrder(); let moduleSpecifier = path; let isPackageRootPath = false; @@ -972,13 +937,13 @@ function getPathsRelativeToRootDirs(path: string, rootDirs: readonly string[], g }); } -function processEnding(fileName: string, ending: Ending, options: CompilerOptions, host?: ModuleSpecifierResolutionHost): string { +function processEnding(fileName: string, ending: ModuleSpecifierEnding, options: CompilerOptions, host?: ModuleSpecifierResolutionHost): string { if (fileExtensionIsOneOf(fileName, [Extension.Json, Extension.Mjs, Extension.Cjs])) return fileName; const noExtension = removeFileExtension(fileName); if (fileName === noExtension) return fileName; if (fileExtensionIsOneOf(fileName, [Extension.Dmts, Extension.Mts, Extension.Dcts, Extension.Cts])) return noExtension + getJSExtensionForFile(fileName, options); switch (ending) { - case Ending.Minimal: + case ModuleSpecifierEnding.Minimal: const withoutIndex = removeSuffix(noExtension, "/index"); if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) { // Can't remove index if there's a file by the same name as the directory. @@ -986,11 +951,11 @@ function processEnding(fileName: string, ending: Ending, options: CompilerOption return noExtension; } return withoutIndex; - case Ending.Index: + case ModuleSpecifierEnding.Index: return noExtension; - case Ending.JsExtension: + case ModuleSpecifierEnding.JsExtension: return noExtension + getJSExtensionForFile(fileName, options); - case Ending.TsExtension: + case ModuleSpecifierEnding.TsExtension: return fileName; default: return Debug.assertNever(ending); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 32656e7970400..5c8e2691c3286 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -90,7 +90,7 @@ import { TypePredicate, TypePredicateKind, TypeReferenceNode, unescapeLeadingUnderscores, UnionOrIntersectionTypeNode, ValidImportTypeNode, VariableDeclaration, VariableDeclarationInitializedTo, VariableDeclarationList, VariableLikeDeclaration, VariableStatement, version, WhileStatement, WithStatement, WriteFileCallback, - WriteFileCallbackData, YieldExpression, ResolutionMode, + WriteFileCallbackData, YieldExpression, ResolutionMode, append, shouldAllowImportingTsExtension, UserPreferences, } from "./_namespaces/ts"; /** @internal */ @@ -7831,6 +7831,92 @@ export function hasTSFileExtension(fileName: string): boolean { return some(supportedTSExtensionsFlat, extension => fileExtensionIs(fileName, extension)); } +/** + * @internal + * Corresponds to UserPreferences#importPathEnding + */ +export const enum ModuleSpecifierEnding { + Minimal, + Index, + JsExtension, + TsExtension, +} + +/** @internal */ +export function usesExtensionsOnImports({ imports }: SourceFile, hasExtension: (text: string) => boolean = or(hasJSFileExtension, hasTSFileExtension)): boolean { + return firstDefined(imports, ({ text }) => pathIsRelative(text) ? hasExtension(text) : undefined) || false; +} + +/** @internal */ +export function getModuleSpecifierEndingPreference(preference: UserPreferences["importModuleSpecifierEnding"], resolutionMode: ResolutionMode, compilerOptions: CompilerOptions, sourceFile: SourceFile): ModuleSpecifierEnding { + if (preference === "js" || resolutionMode === ModuleKind.ESNext) { + // Extensions are explicitly requested or required. Now choose between .js and .ts. + if (!shouldAllowImportingTsExtension(compilerOptions)) { + return ModuleSpecifierEnding.JsExtension; + } + // `allowImportingTsExtensions` is a strong signal, so use .ts unless the file + // already uses .js extensions and no .ts extensions. + return inferPreference() !== ModuleSpecifierEnding.JsExtension + ? ModuleSpecifierEnding.TsExtension + : ModuleSpecifierEnding.JsExtension; + } + if (preference === "minimal") { + return ModuleSpecifierEnding.Minimal; + } + if (preference === "index") { + return ModuleSpecifierEnding.Index; + } + + // No preference was specified. + // Look at imports and/or requires to guess whether .js, .ts, or extensionless imports are preferred. + // N.B. that `Index` detection is not supported since it would require file system probing to do + // accurately, and more importantly, literally nobody wants `Index` and its existence is a mystery. + if (!shouldAllowImportingTsExtension(compilerOptions)) { + // If .ts imports are not valid, we only need to see one .js import to go with that. + return usesExtensionsOnImports(sourceFile) ? ModuleSpecifierEnding.JsExtension : ModuleSpecifierEnding.Minimal; + } + + return inferPreference(); + + function inferPreference() { + let usesJsExtensions = false; + const specifiers = sourceFile.imports.length ? sourceFile.imports.map(i => i.text) : + isSourceFileJS(sourceFile) ? getRequiresAtTopOfFile(sourceFile).map(r => r.arguments[0].text) : + emptyArray; + for (const specifier of specifiers) { + if (pathIsRelative(specifier)) { + if (hasTSFileExtension(specifier)) { + return ModuleSpecifierEnding.TsExtension; + } + if (hasJSFileExtension(specifier)) { + usesJsExtensions = true; + } + } + } + return usesJsExtensions ? ModuleSpecifierEnding.JsExtension : ModuleSpecifierEnding.Minimal; + } +} + +function getRequiresAtTopOfFile(sourceFile: SourceFile): readonly RequireOrImportCall[] { + let nonRequireStatementCount = 0; + let requires: RequireOrImportCall[] | undefined; + for (const statement of sourceFile.statements) { + if (nonRequireStatementCount > 3) { + break; + } + if (isRequireVariableStatement(statement)) { + requires = concatenate(requires, statement.declarationList.declarations.map(d => d.initializer)); + } + else if (isExpressionStatement(statement) && isRequireCall(statement.expression, /*requireStringLiteralLikeArgument*/ true)) { + requires = append(requires, statement.expression); + } + else { + nonRequireStatementCount++; + } + } + return requires || emptyArray; +} + /** @internal */ export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]) { if (!fileName) return false; diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index e7958ae0f9311..c4f7844098fd0 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -10,21 +10,22 @@ import { getLeadingCommentRanges, getModeForUsageLocation, getOwnKeys, getPackageJsonTypesVersionsPaths, getPathComponents, getReplacementSpanForContextToken, getSupportedExtensions, getSupportedExtensionsWithJsonIfResolveJsonModule, getTokenAtPosition, hasIndexSignature, hasProperty, hasTrailingDirectorySeparator, hostGetCanonicalFileName, - IndexedAccessTypeNode, isApplicableVersionedTypesKey, isArray, isCallExpression, isIdentifier, isIdentifierText, + IndexedAccessTypeNode, getModuleSpecifierEndingPreference, isApplicableVersionedTypesKey, isArray, isCallExpression, isIdentifier, isIdentifierText, isImportCall, isInReferenceComment, isInString, isJsxAttribute, isJsxOpeningLikeElement, isLiteralTypeNode, isObjectLiteralExpression, isPatternMatch, isPrivateIdentifierClassElementDeclaration, isRootedDiskPath, isString, isStringLiteral, isStringLiteralLike, isTypeReferenceNode, isUrl, JsxAttribute, LanguageServiceHost, length, LiteralExpression, LiteralTypeNode, mapDefined, MapLike, ModuleKind, moduleResolutionRespectsExports, moduleResolutionUsesNodeModules, + ModuleSpecifierEnding, moduleSpecifiers, Node, normalizePath, normalizeSlashes, ObjectLiteralExpression, Path, Program, PropertyAssignment, rangeContainsPosition, readJson, removeFileExtension, removePrefix, removeTrailingDirectorySeparator, ResolutionMode, resolvePath, - ScriptElementKind, ScriptElementKindModifier, ScriptTarget, shouldAllowImportingTsExtension, Signature, signatureHasRestParameter, SignatureHelp, + ScriptElementKind, ScriptElementKindModifier, ScriptTarget, Signature, signatureHasRestParameter, SignatureHelp, singleElementArray, skipConstraint, skipParentheses, SourceFile, startsWith, stringContains, StringLiteralLike, StringLiteralType, stripQuotes, Symbol, SyntaxKind, textPart, TextSpan, tryAndIgnoreErrors, tryDirectoryExists, tryFileExists, tryGetDirectories, tryGetExtensionFromPath, tryParsePattern, tryReadDirectory, tryRemoveDirectoryPrefix, tryRemovePrefix, Type, TypeChecker, TypeFlags, UnionTypeNode, unmangleScopedPackageName, - UserPreferences, walkUpParenthesizedExpressions, walkUpParenthesizedTypes, + UserPreferences, walkUpParenthesizedExpressions, walkUpParenthesizedTypes, supportedTSImplementationExtensions, } from "./_namespaces/ts"; import { CompletionKind, createCompletionDetails, createCompletionDetailsForSymbol, getCompletionEntriesFromSymbols, @@ -404,31 +405,31 @@ function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile: SourceFile const scriptPath = sourceFile.path; const scriptDirectory = getDirectoryPath(scriptPath); + const extensionOptions = getExtensionOptions(compilerOptions, ReferenceKind.ModuleSpecifier, sourceFile, preferences, mode); return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (isRootedDiskPath(literalValue) || isUrl(literalValue)) - ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, getIncludeExtensionOption()) - : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, getIncludeExtensionOption(), typeChecker); - - function getIncludeExtensionOption() { - if (shouldAllowImportingTsExtension(compilerOptions)) { - return IncludeExtensionsOption.Include; - } - const mode = isStringLiteralLike(node) ? getModeForUsageLocation(sourceFile, node) : undefined; - return preferences.importModuleSpecifierEnding === "js" || mode === ModuleKind.ESNext - ? IncludeExtensionsOption.ModuleSpecifierCompletion - : IncludeExtensionsOption.Exclude; - } + ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, extensionOptions) + : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, extensionOptions, typeChecker); } interface ExtensionOptions { - readonly extensions: readonly Extension[]; - readonly includeExtensionsOption: IncludeExtensionsOption; + readonly extensionsToSearch: readonly Extension[]; + readonly referenceKind: ReferenceKind; + readonly importingSourceFile: SourceFile; + readonly endingPreference?: UserPreferences["importModuleSpecifierEnding"]; + readonly resolutionMode?: ResolutionMode; } -function getExtensionOptions(compilerOptions: CompilerOptions, includeExtensionsOption = IncludeExtensionsOption.Exclude): ExtensionOptions { - return { extensions: flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), includeExtensionsOption }; + +function getExtensionOptions(compilerOptions: CompilerOptions, referenceKind: ReferenceKind, importingSourceFile: SourceFile, preferences?: UserPreferences, resolutionMode?: ResolutionMode): ExtensionOptions { +return { + extensionsToSearch: flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), + referenceKind, + importingSourceFile, + endingPreference: preferences?.importModuleSpecifierEnding, + resolutionMode, + }; } -function getCompletionEntriesForRelativeModules(literalValue: string, scriptDirectory: string, compilerOptions: CompilerOptions, host: LanguageServiceHost, scriptPath: Path, includeExtensions: IncludeExtensionsOption) { - const extensionOptions = getExtensionOptions(compilerOptions, includeExtensions); +function getCompletionEntriesForRelativeModules(literalValue: string, scriptDirectory: string, compilerOptions: CompilerOptions, host: LanguageServiceHost, scriptPath: Path, extensionOptions: ExtensionOptions) { if (compilerOptions.rootDirs) { return getCompletionEntriesForDirectoryFragmentWithRootDirs( compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); @@ -472,10 +473,9 @@ function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[] return flatMap(baseDirectories, baseDirectory => arrayFrom(getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, /*moduleSpecifierIsRelative*/ true, exclude).values())); } -const enum IncludeExtensionsOption { - Exclude, - Include, - ModuleSpecifierCompletion, +const enum ReferenceKind { + Filename, + ModuleSpecifier, } /** * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. @@ -537,7 +537,7 @@ function getCompletionEntriesForDirectoryFragment( if (!tryDirectoryExists(host, baseDirectory)) return result; // Enumerate the available files if possible - const files = tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + const files = tryReadDirectory(host, baseDirectory, extensionOptions.extensionsToSearch, /*exclude*/ undefined, /*include*/ ["./*"]); if (files) { for (let filePath of files) { @@ -546,7 +546,7 @@ function getCompletionEntriesForDirectoryFragment( continue; } - const { name, extension } = getFilenameWithExtensionOption(getBaseFileName(filePath), host.getCompilationSettings(), extensionOptions.includeExtensionsOption); + const { name, extension } = getFilenameWithExtensionOption(getBaseFileName(filePath), host.getCompilationSettings(), extensionOptions); result.add(nameAndKind(name, ScriptElementKind.scriptElement, extension)); } } @@ -566,17 +566,32 @@ function getCompletionEntriesForDirectoryFragment( return result; } -function getFilenameWithExtensionOption(name: string, compilerOptions: CompilerOptions, includeExtensionsOption: IncludeExtensionsOption): { name: string, extension: Extension | undefined } { - const outputExtension = moduleSpecifiers.tryGetJSExtensionForFile(name, compilerOptions); - if (includeExtensionsOption === IncludeExtensionsOption.Exclude && !fileExtensionIsOneOf(name, [Extension.Json, Extension.Mts, Extension.Cts, Extension.Dmts, Extension.Dcts, Extension.Mjs, Extension.Cjs])) { - return { name: removeFileExtension(name), extension: tryGetExtensionFromPath(name) }; +function getFilenameWithExtensionOption(name: string, compilerOptions: CompilerOptions, extensionOptions: ExtensionOptions): { name: string, extension: Extension | undefined } { + if (extensionOptions.referenceKind === ReferenceKind.Filename) { + return { name, extension: tryGetExtensionFromPath(name) }; } - else if ((fileExtensionIsOneOf(name, [Extension.Mts, Extension.Cts, Extension.Dmts, Extension.Dcts, Extension.Mjs, Extension.Cjs]) || includeExtensionsOption === IncludeExtensionsOption.ModuleSpecifierCompletion) && outputExtension) { - return { name: changeExtension(name, outputExtension), extension: outputExtension }; + + const endingPreference = getModuleSpecifierEndingPreference(extensionOptions.endingPreference, extensionOptions.resolutionMode, compilerOptions, extensionOptions.importingSourceFile); + if (endingPreference === ModuleSpecifierEnding.TsExtension) { + if (fileExtensionIsOneOf(name, supportedTSImplementationExtensions)) { + return { name, extension: tryGetExtensionFromPath(name) }; + } + const outputExtension = moduleSpecifiers.tryGetJSExtensionForFile(name, compilerOptions); + return outputExtension + ? { name: changeExtension(name, outputExtension), extension: outputExtension } + : { name, extension: tryGetExtensionFromPath(name) }; } - else { - return { name, extension: tryGetExtensionFromPath(name) }; + + if ((endingPreference === ModuleSpecifierEnding.Minimal || endingPreference === ModuleSpecifierEnding.Index) && + fileExtensionIsOneOf(name, [Extension.Js, Extension.Jsx, Extension.Ts, Extension.Tsx, Extension.Dts]) + ) { + return { name: removeFileExtension(name), extension: tryGetExtensionFromPath(name) }; } + + const outputExtension = moduleSpecifiers.tryGetJSExtensionForFile(name, compilerOptions); + return outputExtension + ? { name: changeExtension(name, outputExtension), extension: outputExtension } + : { name, extension: tryGetExtensionFromPath(name) }; } /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */ @@ -663,14 +678,13 @@ function getCompletionEntriesForNonRelativeModules( mode: ResolutionMode, compilerOptions: CompilerOptions, host: LanguageServiceHost, - includeExtensionsOption: IncludeExtensionsOption, + extensionOptions: ExtensionOptions, typeChecker: TypeChecker, ): readonly NameAndKind[] { const { baseUrl, paths } = compilerOptions; const result = createNameAndKindSet(); const moduleResolution = getEmitModuleResolutionKind(compilerOptions); - const extensionOptions = getExtensionOptions(compilerOptions, includeExtensionsOption); if (baseUrl) { const projectDir = compilerOptions.project || host.getCurrentDirectory(); const absolute = normalizePath(combinePaths(projectDir, baseUrl)); @@ -845,13 +859,13 @@ function getModulesForPathsPattern( // done. const includeGlob = normalizedSuffix ? "**/*" + normalizedSuffix : "./*"; - const matches = mapDefined(tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, [includeGlob]), match => { + const matches = mapDefined(tryReadDirectory(host, baseDirectory, extensionOptions.extensionsToSearch, /*exclude*/ undefined, [includeGlob]), match => { const trimmedWithPattern = trimPrefixAndSuffix(match); if (trimmedWithPattern) { if (containsSlash(trimmedWithPattern)) { return directoryResult(getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]); } - const { name, extension } = getFilenameWithExtensionOption(trimmedWithPattern, host.getCompilationSettings(), extensionOptions.includeExtensionsOption); + const { name, extension } = getFilenameWithExtensionOption(trimmedWithPattern, host.getCompilationSettings(), extensionOptions); return nameAndKind(name, ScriptElementKind.scriptElement, extension); } }); @@ -908,8 +922,8 @@ function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: num const [, prefix, kind, toComplete] = match; const scriptPath = getDirectoryPath(sourceFile.path); - const names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, IncludeExtensionsOption.Include), host, /*moduleSpecifierIsRelative*/ true, sourceFile.path) - : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions)) + const names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, ReferenceKind.Filename, sourceFile), host, /*moduleSpecifierIsRelative*/ true, sourceFile.path) + : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions, ReferenceKind.ModuleSpecifier, sourceFile)) : Debug.fail(); return addReplacementSpans(toComplete, range.pos + prefix.length, arrayFrom(names.values())); } From c4320a2fb2352fad550b872673ad817dcaf1cf1b Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 18 Nov 2022 13:35:04 -0800 Subject: [PATCH 27/41] Comment test --- tests/cases/fourslash/pathCompletionsAllowTsExtensions.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/cases/fourslash/pathCompletionsAllowTsExtensions.ts b/tests/cases/fourslash/pathCompletionsAllowTsExtensions.ts index f0dccd98e71b4..32b566f0839e6 100644 --- a/tests/cases/fourslash/pathCompletionsAllowTsExtensions.ts +++ b/tests/cases/fourslash/pathCompletionsAllowTsExtensions.ts @@ -10,12 +10,14 @@ // @Filename: /project/main.ts //// import {} from ".//**/" +// Extensionless by default verify.completions({ marker: "", isNewIdentifierLocation: true, exact: ["foo"], }); +// .ts extension when allowImportingTsExtensions is true and setting is js... verify.completions({ marker: "", isNewIdentifierLocation: true, @@ -25,8 +27,8 @@ verify.completions({ }, }); +// ...or when another import uses .ts extension edit.insert(`foo.ts"\nimport {} from "./`); - verify.completions({ marker: "", isNewIdentifierLocation: true, From f04f1b5ce2eae4355f4a775de4e6899de910c153 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 17 Nov 2022 16:29:08 -0800 Subject: [PATCH 28/41] Auto-imports of declaration files cannot use .ts extension --- src/compiler/moduleSpecifiers.ts | 29 +++++++++++++------ .../autoImportAllowTsExtensions3.baseline.md | 7 +++++ .../autoImportAllowTsExtensions4.baseline.md | 22 ++++++++++++++ .../fourslash/autoImportAllowTsExtensions3.ts | 3 ++ .../fourslash/autoImportAllowTsExtensions4.ts | 20 +++++++++++++ 5 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 tests/baselines/reference/autoImportAllowTsExtensions4.baseline.md create mode 100644 tests/cases/fourslash/autoImportAllowTsExtensions4.ts diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index d7aabf497ce85..ab9dc8bc0cdb1 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -16,7 +16,7 @@ import { ModuleSpecifierResolutionHost, NodeFlags, NodeModulePathParts, normalizePath, Path, pathContainsNodeModules, pathIsBareSpecifier, pathIsRelative, PropertyAccessExpression, removeFileExtension, removeSuffix, resolvePath, ScriptKind, some, SourceFile, startsWith, startsWithDirectory, stringContains, StringLiteral, Symbol, SymbolFlags, - toPath, tryGetExtensionFromPath, tryParsePatterns, TypeChecker, UserPreferences, shouldAllowImportingTsExtension, ResolutionMode, ModuleSpecifierEnding, getModuleSpecifierEndingPreference, + toPath, tryGetExtensionFromPath, tryParsePatterns, TypeChecker, UserPreferences, shouldAllowImportingTsExtension, ResolutionMode, ModuleSpecifierEnding, getModuleSpecifierEndingPreference, isDeclarationFileName, } from "./_namespaces/ts"; // Used by importFixes, getEditsForFileRename, and declaration emit to synthesize import module specifiers. @@ -74,10 +74,10 @@ function getPreferences( if (endsWith(oldImportSpecifier, "/index")) return ModuleSpecifierEnding.Index; } return getModuleSpecifierEndingPreference( - importModuleSpecifierEnding, - importingSourceFile.impliedNodeFormat, - compilerOptions, - importingSourceFile); + importModuleSpecifierEnding, + importingSourceFile.impliedNodeFormat, + compilerOptions, + importingSourceFile); } } @@ -937,10 +937,19 @@ function getPathsRelativeToRootDirs(path: string, rootDirs: readonly string[], g } function processEnding(fileName: string, ending: ModuleSpecifierEnding, options: CompilerOptions, host?: ModuleSpecifierResolutionHost): string { - if (fileExtensionIsOneOf(fileName, [Extension.Json, Extension.Mjs, Extension.Cjs])) return fileName; + if (fileExtensionIsOneOf(fileName, [Extension.Json, Extension.Mjs, Extension.Cjs])) { + return fileName; + } + const noExtension = removeFileExtension(fileName); - if (fileName === noExtension) return fileName; - if (fileExtensionIsOneOf(fileName, [Extension.Dmts, Extension.Mts, Extension.Dcts, Extension.Cts])) return noExtension + getJSExtensionForFile(fileName, options); + if (fileName === noExtension) { + return fileName; + } + + if (fileExtensionIsOneOf(fileName, [Extension.Dmts, Extension.Mts, Extension.Dcts, Extension.Cts])) { + return noExtension + getJSExtensionForFile(fileName, options); + } + switch (ending) { case ModuleSpecifierEnding.Minimal: const withoutIndex = removeSuffix(noExtension, "/index"); @@ -955,7 +964,9 @@ function processEnding(fileName: string, ending: ModuleSpecifierEnding, options: case ModuleSpecifierEnding.JsExtension: return noExtension + getJSExtensionForFile(fileName, options); case ModuleSpecifierEnding.TsExtension: - return fileName; + // For now, we don't know if this import is going to be type-only, which means we don't + // know if a .d.ts extension is valid, so use the .js extension. + return isDeclarationFileName(fileName) ? noExtension + getJSExtensionForFile(fileName, options) : fileName; default: return Debug.assertNever(ending); } diff --git a/tests/baselines/reference/autoImportAllowTsExtensions3.baseline.md b/tests/baselines/reference/autoImportAllowTsExtensions3.baseline.md index 77fea133b581f..0a2ced8c8ffd1 100644 --- a/tests/baselines/reference/autoImportAllowTsExtensions3.baseline.md +++ b/tests/baselines/reference/autoImportAllowTsExtensions3.baseline.md @@ -6,8 +6,15 @@ import { Component } from "./Component.tsx"; ## From completions +- `fromDecl` from `"./decl.js"` - `fromLocal` from `"./local.ts"` +```ts +import { Component } from "./Component.tsx"; +import { fromDecl } from "./decl.js"; +fromDecl +``` + ```ts import { Component } from "./Component.tsx"; import { fromLocal } from "./local.ts"; diff --git a/tests/baselines/reference/autoImportAllowTsExtensions4.baseline.md b/tests/baselines/reference/autoImportAllowTsExtensions4.baseline.md new file mode 100644 index 0000000000000..cdae3c5eaa40b --- /dev/null +++ b/tests/baselines/reference/autoImportAllowTsExtensions4.baseline.md @@ -0,0 +1,22 @@ +```ts +// @Filename: /main.ts +import { Component } from "./local.js"; +/*|*/ +``` + +## From completions + +- `fromDecl` from `"./decl.js"` +- `fromLocal` from `"./local.js"` + +```ts +import { fromDecl } from "./decl.js"; +import { Component } from "./local.js"; +fromDecl +``` + +```ts +import { Component, fromLocal } from "./local.js"; +fromLocal +``` + diff --git a/tests/cases/fourslash/autoImportAllowTsExtensions3.ts b/tests/cases/fourslash/autoImportAllowTsExtensions3.ts index 9fcfbc53a0fbe..f46128644c6bd 100644 --- a/tests/cases/fourslash/autoImportAllowTsExtensions3.ts +++ b/tests/cases/fourslash/autoImportAllowTsExtensions3.ts @@ -7,6 +7,9 @@ // @Filename: /local.ts //// export const fromLocal: number; +// @Filename: /decl.d.ts +//// export const fromDecl: number; + // @Filename: /Component.tsx //// export function Component() { return null; } diff --git a/tests/cases/fourslash/autoImportAllowTsExtensions4.ts b/tests/cases/fourslash/autoImportAllowTsExtensions4.ts new file mode 100644 index 0000000000000..bc6235658c2bc --- /dev/null +++ b/tests/cases/fourslash/autoImportAllowTsExtensions4.ts @@ -0,0 +1,20 @@ +/// + +// @moduleResolution: hybrid +// @allowImportingTsExtensions: true +// @noEmit: true + +// @Filename: /local.ts +//// export const fromLocal: number; + +// @Filename: /decl.d.ts +//// export const fromDecl: number; + +// @Filename: /Component.tsx +//// export function Component() { return null; } + +// @Filename: /main.ts +//// import { Component } from "./local.js"; +//// /**/ + +verify.baselineAutoImports(""); From 29039dec4e8eb101e09070a33d6fe2b45111b248 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 17 Nov 2022 16:49:40 -0800 Subject: [PATCH 29/41] Have declaration file auto imports default to extensionless instead --- src/compiler/moduleSpecifiers.ts | 31 ++++++++++++------- .../autoImportAllowTsExtensions3.baseline.md | 4 +-- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index ab9dc8bc0cdb1..66ec3a24deb39 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -60,7 +60,7 @@ function getPreferences( } switch (preferredEnding) { case ModuleSpecifierEnding.JsExtension: return [ModuleSpecifierEnding.JsExtension, ModuleSpecifierEnding.Minimal, ModuleSpecifierEnding.Index]; - case ModuleSpecifierEnding.TsExtension: return [ModuleSpecifierEnding.TsExtension, ModuleSpecifierEnding.TsExtension, ModuleSpecifierEnding.Minimal, ModuleSpecifierEnding.Index]; + case ModuleSpecifierEnding.TsExtension: return [ModuleSpecifierEnding.TsExtension, ModuleSpecifierEnding.Minimal, ModuleSpecifierEnding.JsExtension, ModuleSpecifierEnding.Index]; case ModuleSpecifierEnding.Index: return [ModuleSpecifierEnding.Index, ModuleSpecifierEnding.Minimal, ModuleSpecifierEnding.JsExtension]; case ModuleSpecifierEnding.Minimal: return [ModuleSpecifierEnding.Minimal, ModuleSpecifierEnding.Index, ModuleSpecifierEnding.JsExtension]; default: Debug.assertNever(preferredEnding); @@ -367,7 +367,7 @@ function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOpt return fromPaths; } - const maybeNonRelative = fromPaths === undefined && baseUrl !== undefined ? processEnding(relativeToBaseUrl, ending, compilerOptions) : fromPaths; + const maybeNonRelative = fromPaths === undefined && baseUrl !== undefined ? processEnding(relativeToBaseUrl, allowedEndings, compilerOptions) : fromPaths; if (!maybeNonRelative) { return relativePath; } @@ -655,7 +655,7 @@ function tryGetModuleNameFromPaths(relativeToBaseUrl: string, paths: MapLike ({ ending, - value: processEnding(relativeToBaseUrl, ending, compilerOptions) + value: processEnding(relativeToBaseUrl, [ending], compilerOptions) })); if (tryGetExtensionFromPath(pattern)) { candidates.push({ ending: undefined, value: relativeToBaseUrl }); @@ -692,7 +692,7 @@ function tryGetModuleNameFromPaths(relativeToBaseUrl: string, paths: MapLike string, ending: ModuleSpecifierEnding, compilerOptions: CompilerOptions): string | undefined { +function tryGetModuleNameFromRootDirs(rootDirs: readonly string[], moduleFileName: string, sourceDirectory: string, getCanonicalFileName: (file: string) => string, allowedEndings: readonly ModuleSpecifierEnding[], compilerOptions: CompilerOptions): string | undefined { const normalizedTargetPaths = getPathsRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName); if (normalizedTargetPaths === undefined) { return undefined; @@ -781,7 +781,7 @@ function tryGetModuleNameFromRootDirs(rootDirs: readonly string[], moduleFileNam if (!shortest) { return undefined; } - return processEnding(shortest, ending, compilerOptions); + return processEnding(shortest, allowedEndings, compilerOptions); } function tryGetModuleNameAsNodeModule({ path, isRedirect }: ModulePath, { getCanonicalFileName, sourceDirectory }: Info, importingSourceFile: SourceFile, host: ModuleSpecifierResolutionHost, options: CompilerOptions, userPreferences: UserPreferences, packageNameOnly?: boolean, overrideMode?: ResolutionMode): string | undefined { @@ -823,7 +823,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }: ModulePath, { getCan // try with next level of directory packageRootIndex = path.indexOf(directorySeparator, packageRootIndex + 1); if (packageRootIndex === -1) { - moduleSpecifier = processEnding(moduleFileName, allowedEndings[0], options, host); + moduleSpecifier = processEnding(moduleFileName, allowedEndings, options, host); break; } } @@ -936,7 +936,7 @@ function getPathsRelativeToRootDirs(path: string, rootDirs: readonly string[], g }); } -function processEnding(fileName: string, ending: ModuleSpecifierEnding, options: CompilerOptions, host?: ModuleSpecifierResolutionHost): string { +function processEnding(fileName: string, allowedEndings: readonly ModuleSpecifierEnding[], options: CompilerOptions, host?: ModuleSpecifierResolutionHost): string { if (fileExtensionIsOneOf(fileName, [Extension.Json, Extension.Mjs, Extension.Cjs])) { return fileName; } @@ -950,7 +950,7 @@ function processEnding(fileName: string, ending: ModuleSpecifierEnding, options: return noExtension + getJSExtensionForFile(fileName, options); } - switch (ending) { + switch (allowedEndings[0]) { case ModuleSpecifierEnding.Minimal: const withoutIndex = removeSuffix(noExtension, "/index"); if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) { @@ -965,10 +965,17 @@ function processEnding(fileName: string, ending: ModuleSpecifierEnding, options: return noExtension + getJSExtensionForFile(fileName, options); case ModuleSpecifierEnding.TsExtension: // For now, we don't know if this import is going to be type-only, which means we don't - // know if a .d.ts extension is valid, so use the .js extension. - return isDeclarationFileName(fileName) ? noExtension + getJSExtensionForFile(fileName, options) : fileName; + // know if a .d.ts extension is valid, so use no extension or a .js extension + if (isDeclarationFileName(fileName)) { + const extensionlessPriority = allowedEndings.findIndex(e => e === ModuleSpecifierEnding.Minimal || e === ModuleSpecifierEnding.Index); + const jsPriority = allowedEndings.indexOf(ModuleSpecifierEnding.JsExtension); + return extensionlessPriority !== -1 && extensionlessPriority < jsPriority + ? noExtension + : noExtension + getJSExtensionForFile(fileName, options); + } + return fileName; default: - return Debug.assertNever(ending); + return Debug.assertNever(allowedEndings[0]); } } diff --git a/tests/baselines/reference/autoImportAllowTsExtensions3.baseline.md b/tests/baselines/reference/autoImportAllowTsExtensions3.baseline.md index 0a2ced8c8ffd1..551ff404a6a33 100644 --- a/tests/baselines/reference/autoImportAllowTsExtensions3.baseline.md +++ b/tests/baselines/reference/autoImportAllowTsExtensions3.baseline.md @@ -6,12 +6,12 @@ import { Component } from "./Component.tsx"; ## From completions -- `fromDecl` from `"./decl.js"` +- `fromDecl` from `"./decl"` - `fromLocal` from `"./local.ts"` ```ts import { Component } from "./Component.tsx"; -import { fromDecl } from "./decl.js"; +import { fromDecl } from "./decl"; fromDecl ``` From f98730abf6c94327ea86e9e68fad17a16b1aa878 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 18 Nov 2022 15:16:55 -0800 Subject: [PATCH 30/41] Add test for custom conditions --- src/compiler/moduleNameResolver.ts | 2 +- src/testRunner/compilerRunner.ts | 2 ++ ...itions(resolvepackagejsonexports=false).js | 33 +++++++++++++++++++ ...s(resolvepackagejsonexports=false).symbols | 25 ++++++++++++++ ...esolvepackagejsonexports=false).trace.json | 22 +++++++++++++ ...ons(resolvepackagejsonexports=false).types | 25 ++++++++++++++ ...ditions(resolvepackagejsonexports=true).js | 33 +++++++++++++++++++ ...ns(resolvepackagejsonexports=true).symbols | 25 ++++++++++++++ ...resolvepackagejsonexports=true).trace.json | 17 ++++++++++ ...ions(resolvepackagejsonexports=true).types | 25 ++++++++++++++ .../moduleResolution/customConditions.ts | 31 +++++++++++++++++ 11 files changed, 239 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/customConditions(resolvepackagejsonexports=false).js create mode 100644 tests/baselines/reference/customConditions(resolvepackagejsonexports=false).symbols create mode 100644 tests/baselines/reference/customConditions(resolvepackagejsonexports=false).trace.json create mode 100644 tests/baselines/reference/customConditions(resolvepackagejsonexports=false).types create mode 100644 tests/baselines/reference/customConditions(resolvepackagejsonexports=true).js create mode 100644 tests/baselines/reference/customConditions(resolvepackagejsonexports=true).symbols create mode 100644 tests/baselines/reference/customConditions(resolvepackagejsonexports=true).trace.json create mode 100644 tests/baselines/reference/customConditions(resolvepackagejsonexports=true).types create mode 100644 tests/cases/conformance/moduleResolution/customConditions.ts diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index c393baf01af3b..1ba764947bff7 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1524,7 +1524,7 @@ export function hybridModuleNameResolver(moduleName: string, containingFile: str if (getResolveJsonModule(compilerOptions)) { extensions |= Extensions.Json; } - return nodeModuleNameResolverWorker(NodeResolutionFeatures.HybridDefault, moduleName, containingDirectory, compilerOptions, host, cache, extensions, /*isConfigLookup*/ false, redirectedReference); + return nodeModuleNameResolverWorker(getNodeResolutionFeatures(compilerOptions), moduleName, containingDirectory, compilerOptions, host, cache, extensions, /*isConfigLookup*/ false, redirectedReference); } export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; diff --git a/src/testRunner/compilerRunner.ts b/src/testRunner/compilerRunner.ts index 8bd62f4f62e64..33d01f4c24953 100644 --- a/src/testRunner/compilerRunner.ts +++ b/src/testRunner/compilerRunner.ts @@ -163,6 +163,8 @@ class CompilerTest { "useUnknownInCatchVariables", "noUncheckedIndexedAccess", "noPropertyAccessFromIndexSignature", + "resolvePackageJsonExports", + "resolvePackageJsonImports", ]; private fileName: string; private justName: string; diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).js b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).js new file mode 100644 index 0000000000000..8f831b27639a6 --- /dev/null +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).js @@ -0,0 +1,33 @@ +//// [tests/cases/conformance/moduleResolution/customConditions.ts] //// + +//// [package.json] +{ + "name": "lodash", + "version": "1.0.0", + "main": "index.js", + "exports": { + "browser": "./browser.js", + "webpack": "./webpack.js", + "default": "./index.js" + } +} + +//// [index.d.ts] +declare const _: "index"; +export = _; + +//// [browser.d.ts] +declare const _: "browser"; +export default _; + +//// [webpack.d.ts] +declare const _: "webpack"; +export = _; + +//// [index.ts] +import _ from "lodash"; + + +//// [index.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).symbols b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).symbols new file mode 100644 index 0000000000000..2b8cae85a8c11 --- /dev/null +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).symbols @@ -0,0 +1,25 @@ +=== /node_modules/lodash/index.d.ts === +declare const _: "index"; +>_ : Symbol(_, Decl(index.d.ts, 0, 13)) + +export = _; +>_ : Symbol(_, Decl(index.d.ts, 0, 13)) + +=== /node_modules/lodash/browser.d.ts === +declare const _: "browser"; +>_ : Symbol(_, Decl(browser.d.ts, 0, 13)) + +export default _; +>_ : Symbol(_, Decl(browser.d.ts, 0, 13)) + +=== /node_modules/lodash/webpack.d.ts === +declare const _: "webpack"; +>_ : Symbol(_, Decl(webpack.d.ts, 0, 13)) + +export = _; +>_ : Symbol(_, Decl(webpack.d.ts, 0, 13)) + +=== /index.ts === +import _ from "lodash"; +>_ : Symbol(_, Decl(index.ts, 0, 6)) + diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).trace.json b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).trace.json new file mode 100644 index 0000000000000..922234fe125a0 --- /dev/null +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).trace.json @@ -0,0 +1,22 @@ +[ + "======== Resolving module 'lodash' from '/index.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "File '/package.json' does not exist.", + "Loading module 'lodash' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Found 'package.json' at '/node_modules/lodash/package.json'.", + "'package.json' does not have a 'typesVersions' field.", + "File '/node_modules/lodash.ts' does not exist.", + "File '/node_modules/lodash.tsx' does not exist.", + "File '/node_modules/lodash.d.ts' does not exist.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'index.js' that references '/node_modules/lodash/index.js'.", + "File '/node_modules/lodash/index.js' does not exist.", + "Loading module as file / folder, candidate module location '/node_modules/lodash/index.js', target file types: TypeScript, Declaration.", + "File name '/node_modules/lodash/index.js' has a '.js' extension - stripping it.", + "File '/node_modules/lodash/index.ts' does not exist.", + "File '/node_modules/lodash/index.tsx' does not exist.", + "File '/node_modules/lodash/index.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/lodash/index.d.ts', result '/node_modules/lodash/index.d.ts'.", + "======== Module name 'lodash' was successfully resolved to '/node_modules/lodash/index.d.ts' with Package ID 'lodash/index.d.ts@1.0.0'. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).types b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).types new file mode 100644 index 0000000000000..fd913f77aaf75 --- /dev/null +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).types @@ -0,0 +1,25 @@ +=== /node_modules/lodash/index.d.ts === +declare const _: "index"; +>_ : "index" + +export = _; +>_ : "index" + +=== /node_modules/lodash/browser.d.ts === +declare const _: "browser"; +>_ : "browser" + +export default _; +>_ : "browser" + +=== /node_modules/lodash/webpack.d.ts === +declare const _: "webpack"; +>_ : "webpack" + +export = _; +>_ : "webpack" + +=== /index.ts === +import _ from "lodash"; +>_ : "index" + diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).js b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).js new file mode 100644 index 0000000000000..8f831b27639a6 --- /dev/null +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).js @@ -0,0 +1,33 @@ +//// [tests/cases/conformance/moduleResolution/customConditions.ts] //// + +//// [package.json] +{ + "name": "lodash", + "version": "1.0.0", + "main": "index.js", + "exports": { + "browser": "./browser.js", + "webpack": "./webpack.js", + "default": "./index.js" + } +} + +//// [index.d.ts] +declare const _: "index"; +export = _; + +//// [browser.d.ts] +declare const _: "browser"; +export default _; + +//// [webpack.d.ts] +declare const _: "webpack"; +export = _; + +//// [index.ts] +import _ from "lodash"; + + +//// [index.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).symbols b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).symbols new file mode 100644 index 0000000000000..2b8cae85a8c11 --- /dev/null +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).symbols @@ -0,0 +1,25 @@ +=== /node_modules/lodash/index.d.ts === +declare const _: "index"; +>_ : Symbol(_, Decl(index.d.ts, 0, 13)) + +export = _; +>_ : Symbol(_, Decl(index.d.ts, 0, 13)) + +=== /node_modules/lodash/browser.d.ts === +declare const _: "browser"; +>_ : Symbol(_, Decl(browser.d.ts, 0, 13)) + +export default _; +>_ : Symbol(_, Decl(browser.d.ts, 0, 13)) + +=== /node_modules/lodash/webpack.d.ts === +declare const _: "webpack"; +>_ : Symbol(_, Decl(webpack.d.ts, 0, 13)) + +export = _; +>_ : Symbol(_, Decl(webpack.d.ts, 0, 13)) + +=== /index.ts === +import _ from "lodash"; +>_ : Symbol(_, Decl(index.ts, 0, 6)) + diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).trace.json b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).trace.json new file mode 100644 index 0000000000000..dd46403892a5a --- /dev/null +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).trace.json @@ -0,0 +1,17 @@ +[ + "======== Resolving module 'lodash' from '/index.ts'. ========", + "Explicitly specified module resolution kind: 'Hybrid'.", + "File '/package.json' does not exist.", + "Loading module 'lodash' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", + "Found 'package.json' at '/node_modules/lodash/package.json'.", + "'package.json' does not have a 'typesVersions' field.", + "Saw non-matching condition 'browser'.", + "Matched 'exports' condition 'webpack'.", + "Using 'exports' subpath '.' with target './webpack.js'.", + "File name '/node_modules/lodash/webpack.js' has a '.js' extension - stripping it.", + "File '/node_modules/lodash/webpack.ts' does not exist.", + "File '/node_modules/lodash/webpack.tsx' does not exist.", + "File '/node_modules/lodash/webpack.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/lodash/webpack.d.ts', result '/node_modules/lodash/webpack.d.ts'.", + "======== Module name 'lodash' was successfully resolved to '/node_modules/lodash/webpack.d.ts' with Package ID 'lodash/webpack.d.ts@1.0.0'. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).types b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).types new file mode 100644 index 0000000000000..4ab420533b366 --- /dev/null +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).types @@ -0,0 +1,25 @@ +=== /node_modules/lodash/index.d.ts === +declare const _: "index"; +>_ : "index" + +export = _; +>_ : "index" + +=== /node_modules/lodash/browser.d.ts === +declare const _: "browser"; +>_ : "browser" + +export default _; +>_ : "browser" + +=== /node_modules/lodash/webpack.d.ts === +declare const _: "webpack"; +>_ : "webpack" + +export = _; +>_ : "webpack" + +=== /index.ts === +import _ from "lodash"; +>_ : "webpack" + diff --git a/tests/cases/conformance/moduleResolution/customConditions.ts b/tests/cases/conformance/moduleResolution/customConditions.ts new file mode 100644 index 0000000000000..1205a9860f07d --- /dev/null +++ b/tests/cases/conformance/moduleResolution/customConditions.ts @@ -0,0 +1,31 @@ +// @moduleResolution: hybrid +// @customConditions: webpack, browser +// @resolvePackageJsonExports: true, false +// @traceResolution: true + +// @Filename: /node_modules/lodash/package.json +{ + "name": "lodash", + "version": "1.0.0", + "main": "index.js", + "exports": { + "browser": "./browser.js", + "webpack": "./webpack.js", + "default": "./index.js" + } +} + +// @Filename: /node_modules/lodash/index.d.ts +declare const _: "index"; +export = _; + +// @Filename: /node_modules/lodash/browser.d.ts +declare const _: "browser"; +export default _; + +// @Filename: /node_modules/lodash/webpack.d.ts +declare const _: "webpack"; +export = _; + +// @Filename: /index.ts +import _ from "lodash"; From 5a01dd66206638122beff7dbf232d2293dfa103a Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 18 Nov 2022 15:25:52 -0800 Subject: [PATCH 31/41] Fix indentation --- src/compiler/commandLineParser.ts | 54 +++++++++++++++--------------- src/compiler/moduleNameResolver.ts | 6 ++-- src/compiler/moduleSpecifiers.ts | 18 +++++----- src/services/stringCompletions.ts | 2 +- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index aca25bb08babe..b4b98453ea204 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1088,34 +1088,34 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [ category: Diagnostics.Modules, description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_hybrid_and_either_noEmit_or_emitDeclarationOnly_to_be_set, defaultValueDescription: false, + }, + { + name: "resolvePackageJsonExports", + type: "boolean", + affectsModuleResolution: true, + category: Diagnostics.Modules, + description: Diagnostics.Use_the_package_json_exports_field_when_resolving_package_imports, + defaultValueDescription: Diagnostics.true_when_moduleResolution_is_node16_nodenext_or_hybrid_otherwise_false, + }, + { + name: "resolvePackageJsonImports", + type: "boolean", + affectsModuleResolution: true, + category: Diagnostics.Modules, + description: Diagnostics.Use_the_package_json_imports_field_when_resolving_imports, + defaultValueDescription: Diagnostics.true_when_moduleResolution_is_node16_nodenext_or_hybrid_otherwise_false, + }, + { + name: "customConditions", + type: "list", + element: { + name: "condition", + type: "string", }, - { - name: "resolvePackageJsonExports", - type: "boolean", - affectsModuleResolution: true, - category: Diagnostics.Modules, - description: Diagnostics.Use_the_package_json_exports_field_when_resolving_package_imports, - defaultValueDescription: Diagnostics.true_when_moduleResolution_is_node16_nodenext_or_hybrid_otherwise_false, - }, - { - name: "resolvePackageJsonImports", - type: "boolean", - affectsModuleResolution: true, - category: Diagnostics.Modules, - description: Diagnostics.Use_the_package_json_imports_field_when_resolving_imports, - defaultValueDescription: Diagnostics.true_when_moduleResolution_is_node16_nodenext_or_hybrid_otherwise_false, - }, - { - name: "customConditions", - type: "list", - element: { - name: "condition", - type: "string", - }, - affectsModuleResolution: true, - category: Diagnostics.Modules, - description: Diagnostics.Conditions_to_set_in_addition_to_the_resolver_specific_defaults_when_resolving_imports, - }, + affectsModuleResolution: true, + category: Diagnostics.Modules, + description: Diagnostics.Conditions_to_set_in_addition_to_the_resolver_specific_defaults_when_resolving_imports, + }, // Source Maps { diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 1ba764947bff7..3f9b892752af2 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -612,12 +612,12 @@ function getNodeResolutionFeatures(options: CompilerOptions) { switch (getEmitModuleResolutionKind(options)) { case ModuleResolutionKind.Node16: features = NodeResolutionFeatures.Node16Default; - break; + break; case ModuleResolutionKind.NodeNext: features = NodeResolutionFeatures.NodeNextDefault; break; case ModuleResolutionKind.Hybrid: - features = NodeResolutionFeatures.HybridDefault; + features = NodeResolutionFeatures.HybridDefault; break; } if (options.resolvePackageJsonExports) { @@ -2036,7 +2036,7 @@ export interface PackageJsonInfoContents { * * @internal */ - export function getPackageScopeForPath(fileName: string, state: ModuleResolutionState): PackageJsonInfo | undefined { +export function getPackageScopeForPath(fileName: string, state: ModuleResolutionState): PackageJsonInfo | undefined { const parts = getPathComponents(fileName); parts.pop(); while (parts.length > 0) { diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index 460da22cfc5dc..db509d2c74ce3 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -860,16 +860,16 @@ function tryGetModuleNameFromRootDirs(rootDirs: readonly string[], moduleFileNam return undefined; } - const normalizedSourcePaths = getPathsRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); - const relativePaths = flatMap(normalizedSourcePaths, sourcePath => { - return map(normalizedTargetPaths, targetPath => ensurePathIsNonModuleName(getRelativePathFromDirectory(sourcePath, targetPath, getCanonicalFileName))); - }); - const shortest = min(relativePaths, compareNumberOfDirectorySeparators); - if (!shortest) { - return undefined; - } - return processEnding(shortest, allowedEndings, compilerOptions); + const normalizedSourcePaths = getPathsRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName); + const relativePaths = flatMap(normalizedSourcePaths, sourcePath => { + return map(normalizedTargetPaths, targetPath => ensurePathIsNonModuleName(getRelativePathFromDirectory(sourcePath, targetPath, getCanonicalFileName))); + }); + const shortest = min(relativePaths, compareNumberOfDirectorySeparators); + if (!shortest) { + return undefined; } + return processEnding(shortest, allowedEndings, compilerOptions); +} function tryGetModuleNameAsNodeModule({ path, isRedirect }: ModulePath, { getCanonicalFileName, sourceDirectory }: Info, importingSourceFile: SourceFile, host: ModuleSpecifierResolutionHost, options: CompilerOptions, userPreferences: UserPreferences, packageNameOnly?: boolean, overrideMode?: ResolutionMode): string | undefined { if (!host.fileExists || !host.readFile) { diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index 867aa0648d1a7..18f8e17750e2c 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -545,7 +545,7 @@ interface ExtensionOptions { } function getExtensionOptions(compilerOptions: CompilerOptions, referenceKind: ReferenceKind, importingSourceFile: SourceFile, preferences?: UserPreferences, resolutionMode?: ResolutionMode): ExtensionOptions { -return { + return { extensionsToSearch: flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), referenceKind, importingSourceFile, From 4dd6d01831ad961270b933022e849e63abc1cc04 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 18 Nov 2022 15:29:56 -0800 Subject: [PATCH 32/41] Add baseline showing resolvePackageJsonImports/Exports compatibility --- src/compiler/program.ts | 2 +- ...portsOptionCompat(moduleresolution=classic).errors.txt | 8 ++++++++ ...sExportsOptionCompat(moduleresolution=node).errors.txt | 8 ++++++++ .../packageJsonImportsExportsOptionCompat.ts | 7 +++++++ 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=classic).errors.txt create mode 100644 tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=node).errors.txt create mode 100644 tests/cases/conformance/moduleResolution/packageJsonImportsExportsOptionCompat.ts diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 69ade50ce9ec2..974525793519c 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -4123,7 +4123,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg createOptionValueDiagnostic("resolvePackageJsonExports", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_hybrid, "resolvePackageJsonExports"); } if (options.resolvePackageJsonImports && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) { - createOptionValueDiagnostic("resolvePackageJsonImports", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_hybrid, "resolvePackageJsonExports"); + createOptionValueDiagnostic("resolvePackageJsonImports", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_hybrid, "resolvePackageJsonImports"); } if (options.customConditions && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) { createOptionValueDiagnostic("customConditions", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_hybrid, "customConditions"); diff --git a/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=classic).errors.txt b/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=classic).errors.txt new file mode 100644 index 0000000000000..023c4dc8610ad --- /dev/null +++ b/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=classic).errors.txt @@ -0,0 +1,8 @@ +error TS5098: Option 'resolvePackageJsonExports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'. +error TS5098: Option 'resolvePackageJsonImports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'. + + +!!! error TS5098: Option 'resolvePackageJsonExports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'. +!!! error TS5098: Option 'resolvePackageJsonImports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'. +==== tests/cases/conformance/moduleResolution/index.ts (0 errors) ==== + \ No newline at end of file diff --git a/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=node).errors.txt b/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=node).errors.txt new file mode 100644 index 0000000000000..023c4dc8610ad --- /dev/null +++ b/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=node).errors.txt @@ -0,0 +1,8 @@ +error TS5098: Option 'resolvePackageJsonExports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'. +error TS5098: Option 'resolvePackageJsonImports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'. + + +!!! error TS5098: Option 'resolvePackageJsonExports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'. +!!! error TS5098: Option 'resolvePackageJsonImports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'. +==== tests/cases/conformance/moduleResolution/index.ts (0 errors) ==== + \ No newline at end of file diff --git a/tests/cases/conformance/moduleResolution/packageJsonImportsExportsOptionCompat.ts b/tests/cases/conformance/moduleResolution/packageJsonImportsExportsOptionCompat.ts new file mode 100644 index 0000000000000..db00495c4ed8d --- /dev/null +++ b/tests/cases/conformance/moduleResolution/packageJsonImportsExportsOptionCompat.ts @@ -0,0 +1,7 @@ +// @moduleResolution: classic, node, node16, nodenext, hybrid +// @resolvePackageJsonImports: true +// @resolvePackageJsonExports: true +// @noTypesAndSymbols: true +// @noEmit: true + +// @Filename: index.ts \ No newline at end of file From f6fa5f33ad78e1105af595f73faa9563f38695fc Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 28 Nov 2022 12:57:03 -0800 Subject: [PATCH 33/41] Fix test and prevent CJS require from resolving --- src/compiler/binder.ts | 3 ++ src/compiler/checker.ts | 5 +-- src/compiler/program.ts | 7 ++-- .../hybridSyntaxRestrictions.errors.txt | 23 ++++++++----- .../reference/hybridSyntaxRestrictions.js | 16 ++++++++-- .../hybridSyntaxRestrictions.symbols | 26 +++++++++++---- .../reference/hybridSyntaxRestrictions.types | 32 +++++++++++++++---- .../hybrid/hybridSyntaxRestrictions.ts | 8 +++-- 8 files changed, 88 insertions(+), 32 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 64fbdbce0e572..222eaff741dbd 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -82,6 +82,7 @@ import { getContainingClass, getEffectiveContainerForJSDocTemplateTag, getElementOrPropertyAccessName, + getEmitModuleResolutionKind, getEmitScriptTarget, getEnclosingBlockScopeContainer, getErrorSpanForNode, @@ -227,6 +228,7 @@ import { ModifierFlags, ModuleBlock, ModuleDeclaration, + ModuleResolutionKind, Mutable, NamespaceExportDeclaration, Node, @@ -3583,6 +3585,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { if (!isBindingPattern(node.name)) { const possibleVariableDecl = node.kind === SyntaxKind.VariableDeclaration ? node : node.parent.parent; if (isInJSFile(node) && + getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Hybrid && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & ModifierFlags.Export) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 46db8246f0f13..1b0e1fa1b4753 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4505,6 +4505,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if ( namespace.valueDeclaration && isInJSFile(namespace.valueDeclaration) && + getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Hybrid && isVariableDeclaration(namespace.valueDeclaration) && namespace.valueDeclaration.initializer && isCommonJsRequire(namespace.valueDeclaration.initializer) @@ -33373,7 +33374,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } // In JavaScript files, calls to any identifier 'require' are treated as external module imports - if (isInJSFile(node) && isCommonJsRequire(node)) { + if (isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Hybrid && isCommonJsRequire(node)) { return resolveExternalModuleTypeByLiteral(node.arguments![0] as StringLiteral); } @@ -44099,7 +44100,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // 4). type A = import("./f/*gotToDefinitionHere*/oo") 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) && isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || isImportCall(node.parent)) || + ((isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Hybrid && isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ 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/src/compiler/program.ts b/src/compiler/program.ts index 974525793519c..749e35451a532 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -3065,7 +3065,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg for (const node of file.statements) { collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & NodeFlags.PossiblyContainsDynamicImport) || isJavaScriptFile) { + + // `require` has no special meaning in `--moduleResolution hybrid` + const shouldProcessRequires = isJavaScriptFile && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Hybrid; + if ((file.flags & NodeFlags.PossiblyContainsDynamicImport) || shouldProcessRequires) { collectDynamicImportOrRequireCalls(file); } @@ -3127,7 +3130,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 (isJavaScriptFile && isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { + if (shouldProcessRequires && isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ 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/tests/baselines/reference/hybridSyntaxRestrictions.errors.txt b/tests/baselines/reference/hybridSyntaxRestrictions.errors.txt index 0a3970e0fc647..e058049f3cd67 100644 --- a/tests/baselines/reference/hybridSyntaxRestrictions.errors.txt +++ b/tests/baselines/reference/hybridSyntaxRestrictions.errors.txt @@ -1,7 +1,21 @@ +error TS2468: Cannot find global value 'Promise'. /main.ts(2,1): error TS5099: Import assignment is not allowed when 'moduleResolution' is set to 'hybrid'. 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 TS5100: Export assignment cannot be used when 'moduleResolution' is set to 'hybrid'. 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; + +==== /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"); // No resolution + _.a; // any + ==== /main.ts (2 errors) ==== import {} from "./a"; import _ = require("./a"); // Error @@ -12,13 +26,6 @@ !!! error TS5100: Export assignment cannot be used when 'moduleResolution' is set to 'hybrid'. Consider using 'export default' or another module format instead. export {}; -==== /node_modules/@types/node/index.d.ts (0 errors) ==== - declare var require: (...args: any[]) => any; - ==== /a.ts (0 errors) ==== - export {}; - -==== /mainJs.js (0 errors) ==== - import {} from "./a"; - const _ = require("./a"); // No resolution + export const a = "a"; \ No newline at end of file diff --git a/tests/baselines/reference/hybridSyntaxRestrictions.js b/tests/baselines/reference/hybridSyntaxRestrictions.js index 7776065ee35f2..95ac57e551973 100644 --- a/tests/baselines/reference/hybridSyntaxRestrictions.js +++ b/tests/baselines/reference/hybridSyntaxRestrictions.js @@ -3,12 +3,11 @@ //// [index.d.ts] declare var require: (...args: any[]) => any; -//// [a.ts] -export {}; - //// [mainJs.js] import {} from "./a"; +import("./a"); const _ = require("./a"); // No resolution +_.a; // any //// [main.ts] import {} from "./a"; @@ -16,10 +15,21 @@ import _ = require("./a"); // Error export = {}; // Error export {}; +//// [a.ts] +export const a = "a"; + //// [a.js] "use strict"; exports.__esModule = true; +exports.a = void 0; +exports.a = "a"; +//// [mainJs.js] +"use strict"; +exports.__esModule = true; +Promise.resolve().then(function () { return require("./a"); }); +var _ = require("./a"); // No resolution +_.a; // any //// [main.js] "use strict"; module.exports = {}; diff --git a/tests/baselines/reference/hybridSyntaxRestrictions.symbols b/tests/baselines/reference/hybridSyntaxRestrictions.symbols index 5f06564f2a083..e48386d570bec 100644 --- a/tests/baselines/reference/hybridSyntaxRestrictions.symbols +++ b/tests/baselines/reference/hybridSyntaxRestrictions.symbols @@ -1,3 +1,20 @@ +=== /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)) + +=== /mainJs.js === +import {} from "./a"; +import("./a"); +>"./a" : Symbol("/a", 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 +>_ : Symbol(_, Decl(mainJs.js, 2, 5)) + === /main.ts === import {} from "./a"; import _ = require("./a"); // Error @@ -6,12 +23,7 @@ import _ = require("./a"); // Error export = {}; // Error export {}; -=== /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)) - === /a.ts === - -export {}; +export const a = "a"; +>a : Symbol(a, Decl(a.ts, 0, 12)) diff --git a/tests/baselines/reference/hybridSyntaxRestrictions.types b/tests/baselines/reference/hybridSyntaxRestrictions.types index 82fbd016666b3..ce832fdb57aa5 100644 --- a/tests/baselines/reference/hybridSyntaxRestrictions.types +++ b/tests/baselines/reference/hybridSyntaxRestrictions.types @@ -1,3 +1,25 @@ +=== /node_modules/@types/node/index.d.ts === +declare var require: (...args: any[]) => any; +>require : (...args: any[]) => any +>args : any[] + +=== /mainJs.js === +import {} from "./a"; +import("./a"); +>import("./a") : Promise +>"./a" : "./a" + +const _ = require("./a"); // No resolution +>_ : any +>require("./a") : any +>require : (...args: any[]) => any +>"./a" : "./a" + +_.a; // any +>_.a : any +>_ : any +>a : any + === /main.ts === import {} from "./a"; import _ = require("./a"); // Error @@ -8,12 +30,8 @@ export = {}; // Error export {}; -=== /node_modules/@types/node/index.d.ts === -declare var require: (...args: any[]) => any; ->require : (...args: any[]) => any ->args : any[] - === /a.ts === - -export {}; +export const a = "a"; +>a : "a" +>"a" : "a" diff --git a/tests/cases/conformance/moduleResolution/hybrid/hybridSyntaxRestrictions.ts b/tests/cases/conformance/moduleResolution/hybrid/hybridSyntaxRestrictions.ts index 123c0c6348402..b4b50b6b910f6 100644 --- a/tests/cases/conformance/moduleResolution/hybrid/hybridSyntaxRestrictions.ts +++ b/tests/cases/conformance/moduleResolution/hybrid/hybridSyntaxRestrictions.ts @@ -6,15 +6,17 @@ // @Filename: /node_modules/@types/node/index.d.ts declare var require: (...args: any[]) => any; -// @Filename: /a.ts -export {}; - // @Filename: /mainJs.js import {} from "./a"; +import("./a"); const _ = require("./a"); // No resolution +_.a; // any // @Filename: /main.ts import {} from "./a"; import _ = require("./a"); // Error export = {}; // Error export {}; + +// @Filename: /a.ts +export const a = "a"; From aeb23be7ccfc8edfa4d4e5283753b111c37da519 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 28 Nov 2022 13:03:32 -0800 Subject: [PATCH 34/41] Update unit test baselines --- ...ule-resolutions-from-non-modified-files.js | 40 +++++++++---------- ...ge-affects-a-single-module-of-a-package.js | 8 ++-- .../change-affects-imports.js | 2 +- .../change-affects-type-directives.js | 4 +- .../fetches-imports-after-npm-install.js | 2 +- .../missing-file-is-created.js | 4 +- .../missing-files-remain-missing.js | 4 +- .../module-kind-changes.js | 2 +- .../redirect-no-change.js | 16 ++++---- .../redirect-previous-duplicate-packages.js | 16 ++++---- .../redirect-target-changes.js | 16 ++++---- .../redirect-underlying-changes.js | 16 ++++---- ...rect-with-getSourceFileByPath-no-change.js | 16 ++++---- ...eFileByPath-previous-duplicate-packages.js | 16 ++++---- ...with-getSourceFileByPath-target-changes.js | 16 ++++---- ...-getSourceFileByPath-underlying-changes.js | 16 ++++---- .../resolution-cache-follows-imports.js | 6 +-- ...-an-ambient-external-module-declaration.js | 4 +- .../works-with-updated-SourceFiles.js | 4 +- 19 files changed, 104 insertions(+), 104 deletions(-) diff --git a/tests/baselines/reference/reuseProgramStructure/can-reuse-module-resolutions-from-non-modified-files.js b/tests/baselines/reference/reuseProgramStructure/can-reuse-module-resolutions-from-non-modified-files.js index c95483abd21a8..011755317b6e9 100644 --- a/tests/baselines/reference/reuseProgramStructure/can-reuse-module-resolutions-from-non-modified-files.js +++ b/tests/baselines/reference/reuseProgramStructure/can-reuse-module-resolutions-from-non-modified-files.js @@ -49,7 +49,7 @@ import { B } from './b1'; export let BB = B; declare module './b1' { interface B { y: string; } } resolvedModules: -./b1: {"resolvedFileName":"b1.ts","extension":".ts","isExternalLibraryImport":false} +./b1: {"resolvedFileName":"b1.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: typerefs1: {"primary":true,"resolvedFileName":"node_modules/@types/typerefs1/index.d.ts","isExternalLibraryImport":false} @@ -60,8 +60,8 @@ import { B } from './b2'; import { BB } from './f1'; (new BB).x; (new BB).y; resolvedModules: -./b2: {"resolvedFileName":"b2.ts","extension":".ts","isExternalLibraryImport":false} -./f1: {"resolvedFileName":"f1.ts","extension":".ts","isExternalLibraryImport":false} +./b2: {"resolvedFileName":"b2.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} +./f1: {"resolvedFileName":"f1.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: typerefs2: {"primary":true,"resolvedFileName":"node_modules/@types/typerefs2/index.d.ts","isExternalLibraryImport":false} @@ -147,7 +147,7 @@ import { B } from './b1'; export let BB = B; declare module './b1' { interface B { y: string; } } resolvedModules: -./b1: {"resolvedFileName":"b1.ts","extension":".ts","isExternalLibraryImport":false} +./b1: {"resolvedFileName":"b1.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: typerefs1: {"primary":true,"resolvedFileName":"node_modules/@types/typerefs1/index.d.ts","isExternalLibraryImport":false} @@ -158,8 +158,8 @@ import { B } from './b2'; import { BB } from './f1'; (new BB).x; (new BB).y; resolvedModules: -./b2: {"resolvedFileName":"b2.ts","extension":".ts","isExternalLibraryImport":false} -./f1: {"resolvedFileName":"f1.ts","extension":".ts","isExternalLibraryImport":false} +./b2: {"resolvedFileName":"b2.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} +./f1: {"resolvedFileName":"f1.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: typerefs2: {"primary":true,"resolvedFileName":"node_modules/@types/typerefs2/index.d.ts","isExternalLibraryImport":false} @@ -234,7 +234,7 @@ import { B } from './b1'; export let BB = B; declare module './b1' { interface B { y: string; } } resolvedModules: -./b1: {"resolvedFileName":"b1.ts","extension":".ts","isExternalLibraryImport":false} +./b1: {"resolvedFileName":"b1.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: f2.ts @@ -244,8 +244,8 @@ import { B } from './b2'; import { BB } from './f1'; (new BB).x; (new BB).y; resolvedModules: -./b2: {"resolvedFileName":"b2.ts","extension":".ts","isExternalLibraryImport":false} -./f1: {"resolvedFileName":"f1.ts","extension":".ts","isExternalLibraryImport":false} +./b2: {"resolvedFileName":"b2.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} +./f1: {"resolvedFileName":"f1.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: typerefs2: {"primary":true,"resolvedFileName":"node_modules/@types/typerefs2/index.d.ts","isExternalLibraryImport":false} @@ -315,7 +315,7 @@ import { B } from './b1'; export let BB = B; declare module './b1' { interface B { y: string; } } resolvedModules: -./b1: {"resolvedFileName":"b1.ts","extension":".ts","isExternalLibraryImport":false} +./b1: {"resolvedFileName":"b1.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: f2.ts @@ -325,8 +325,8 @@ import { B } from './b2'; import { BB } from './f1'; (new BB).x; (new BB).y; resolvedModules: -./b2: {"resolvedFileName":"b2.ts","extension":".ts","isExternalLibraryImport":false} -./f1: {"resolvedFileName":"f1.ts","extension":".ts","isExternalLibraryImport":false} +./b2: {"resolvedFileName":"b2.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} +./f1: {"resolvedFileName":"f1.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: typerefs2: {"primary":true,"resolvedFileName":"node_modules/@types/typerefs2/index.d.ts","isExternalLibraryImport":false} @@ -395,7 +395,7 @@ File: f1.ts import { B } from './b1'; declare module './b1' { interface B { y: string; } } resolvedModules: -./b1: {"resolvedFileName":"b1.ts","extension":".ts","isExternalLibraryImport":false} +./b1: {"resolvedFileName":"b1.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: f2.ts @@ -405,8 +405,8 @@ import { B } from './b2'; import { BB } from './f1'; (new BB).x; (new BB).y; resolvedModules: -./b2: {"resolvedFileName":"b2.ts","extension":".ts","isExternalLibraryImport":false} -./f1: {"resolvedFileName":"f1.ts","extension":".ts","isExternalLibraryImport":false} +./b2: {"resolvedFileName":"b2.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} +./f1: {"resolvedFileName":"f1.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: typerefs2: {"primary":true,"resolvedFileName":"node_modules/@types/typerefs2/index.d.ts","isExternalLibraryImport":false} @@ -473,7 +473,7 @@ File: f1.ts import { B } from './b1'; resolvedModules: -./b1: {"resolvedFileName":"b1.ts","extension":".ts","isExternalLibraryImport":false} +./b1: {"resolvedFileName":"b1.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: f2.ts @@ -483,8 +483,8 @@ import { B } from './b2'; import { BB } from './f1'; (new BB).x; (new BB).y; resolvedModules: -./b2: {"resolvedFileName":"b2.ts","extension":".ts","isExternalLibraryImport":false} -./f1: {"resolvedFileName":"f1.ts","extension":".ts","isExternalLibraryImport":false} +./b2: {"resolvedFileName":"b2.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} +./f1: {"resolvedFileName":"f1.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: typerefs2: {"primary":true,"resolvedFileName":"node_modules/@types/typerefs2/index.d.ts","isExternalLibraryImport":false} @@ -563,8 +563,8 @@ import { B } from './b2'; import { BB } from './f1'; (new BB).x; (new BB).y; resolvedModules: -./b2: {"resolvedFileName":"b2.ts","extension":".ts","isExternalLibraryImport":false} -./f1: {"resolvedFileName":"f1.ts","extension":".ts","isExternalLibraryImport":false} +./b2: {"resolvedFileName":"b2.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} +./f1: {"resolvedFileName":"f1.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: typerefs2: {"primary":true,"resolvedFileName":"node_modules/@types/typerefs2/index.d.ts","isExternalLibraryImport":false} diff --git a/tests/baselines/reference/reuseProgramStructure/change-affects-a-single-module-of-a-package.js b/tests/baselines/reference/reuseProgramStructure/change-affects-a-single-module-of-a-package.js index ecb55554d89ec..c0c2394346d11 100644 --- a/tests/baselines/reference/reuseProgramStructure/change-affects-a-single-module-of-a-package.js +++ b/tests/baselines/reference/reuseProgramStructure/change-affects-a-single-module-of-a-package.js @@ -11,7 +11,7 @@ File: /node_modules/b/index.d.ts export * from './internal'; resolvedModules: -./internal: {"resolvedFileName":"/node_modules/b/internal.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"b","subModuleName":"internal.d.ts","version":"1.2.3"}} +./internal: {"resolvedFileName":"/node_modules/b/internal.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"b","subModuleName":"internal.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -19,7 +19,7 @@ File: /a.ts import {b} from 'b' var a = b; resolvedModules: -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"b","subModuleName":"index.d.ts","version":"1.2.3"}} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"b","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined @@ -41,7 +41,7 @@ File: /node_modules/b/index.d.ts export * from './internal'; resolvedModules: -./internal: {"resolvedFileName":"/node_modules/b/internal.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"b","subModuleName":"internal.d.ts","version":"1.2.3"}} +./internal: {"resolvedFileName":"/node_modules/b/internal.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"b","subModuleName":"internal.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -49,7 +49,7 @@ File: /a.ts import {b} from 'b' var a = b; resolvedModules: -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"b","subModuleName":"index.d.ts","version":"1.2.3"}} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"b","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/change-affects-imports.js b/tests/baselines/reference/reuseProgramStructure/change-affects-imports.js index aba311c73193e..9889197003a90 100644 --- a/tests/baselines/reference/reuseProgramStructure/change-affects-imports.js +++ b/tests/baselines/reference/reuseProgramStructure/change-affects-imports.js @@ -34,7 +34,7 @@ File: c.ts import x from 'b' var z = 1; resolvedModules: -b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false} +b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: b.ts diff --git a/tests/baselines/reference/reuseProgramStructure/change-affects-type-directives.js b/tests/baselines/reference/reuseProgramStructure/change-affects-type-directives.js index 957a0402604ce..e1e02a76b843d 100644 --- a/tests/baselines/reference/reuseProgramStructure/change-affects-type-directives.js +++ b/tests/baselines/reference/reuseProgramStructure/change-affects-type-directives.js @@ -4,7 +4,7 @@ File: c.ts import x from 'b' var z = 1; resolvedModules: -b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false} +b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: b.ts @@ -36,7 +36,7 @@ File: c.ts import x from 'b' var z = 1; resolvedModules: -b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false} +b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: b.ts diff --git a/tests/baselines/reference/reuseProgramStructure/fetches-imports-after-npm-install.js b/tests/baselines/reference/reuseProgramStructure/fetches-imports-after-npm-install.js index 44ee08b080c8d..2f3079e4935cb 100644 --- a/tests/baselines/reference/reuseProgramStructure/fetches-imports-after-npm-install.js +++ b/tests/baselines/reference/reuseProgramStructure/fetches-imports-after-npm-install.js @@ -54,7 +54,7 @@ File: file1.ts import * as a from "a"; const myX: number = a.x; resolvedModules: -a: {"resolvedFileName":"node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: file2.ts diff --git a/tests/baselines/reference/reuseProgramStructure/missing-file-is-created.js b/tests/baselines/reference/reuseProgramStructure/missing-file-is-created.js index 9a80ac1e97245..2097558fb7a76 100644 --- a/tests/baselines/reference/reuseProgramStructure/missing-file-is-created.js +++ b/tests/baselines/reference/reuseProgramStructure/missing-file-is-created.js @@ -4,7 +4,7 @@ File: c.ts import x from 'b' var z = 1; resolvedModules: -b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false} +b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: b.ts @@ -40,7 +40,7 @@ File: c.ts import x from 'b' var z = 1; resolvedModules: -b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false} +b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: b.ts diff --git a/tests/baselines/reference/reuseProgramStructure/missing-files-remain-missing.js b/tests/baselines/reference/reuseProgramStructure/missing-files-remain-missing.js index 6218d9c271c29..76fb2a6068089 100644 --- a/tests/baselines/reference/reuseProgramStructure/missing-files-remain-missing.js +++ b/tests/baselines/reference/reuseProgramStructure/missing-files-remain-missing.js @@ -4,7 +4,7 @@ File: c.ts import x from 'b' var z = 1; resolvedModules: -b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false} +b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: b.ts @@ -40,7 +40,7 @@ File: c.ts import x from 'b' var z = 1; resolvedModules: -b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false} +b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: b.ts diff --git a/tests/baselines/reference/reuseProgramStructure/module-kind-changes.js b/tests/baselines/reference/reuseProgramStructure/module-kind-changes.js index a281816fc3046..a92dfe99966f0 100644 --- a/tests/baselines/reference/reuseProgramStructure/module-kind-changes.js +++ b/tests/baselines/reference/reuseProgramStructure/module-kind-changes.js @@ -40,7 +40,7 @@ File: c.ts import x from 'b' var z = 1; resolvedModules: -b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false} +b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: b.ts diff --git a/tests/baselines/reference/reuseProgramStructure/redirect-no-change.js b/tests/baselines/reference/reuseProgramStructure/redirect-no-change.js index 51c155c3206b6..8a8faaea55cbb 100644 --- a/tests/baselines/reference/reuseProgramStructure/redirect-no-change.js +++ b/tests/baselines/reference/reuseProgramStructure/redirect-no-change.js @@ -11,7 +11,7 @@ File: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; resolvedModules: -x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /node_modules/b/node_modules/x/index.d.ts @@ -26,7 +26,7 @@ File: /node_modules/b/index.d.ts import X from "x"; export const b: X; resolvedModules: -x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -34,8 +34,8 @@ File: /a.ts import { a } from "a"; import { b } from "b"; a(b) resolvedModules: -a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined @@ -57,7 +57,7 @@ File: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; resolvedModules: -x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /node_modules/b/node_modules/x/index.d.ts @@ -72,7 +72,7 @@ File: /node_modules/b/index.d.ts import X from "x"; export const b: X; resolvedModules: -x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -80,8 +80,8 @@ File: /a.ts import { a } from "a"; import { b } from "b"; const x = 1; resolvedModules: -a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/redirect-previous-duplicate-packages.js b/tests/baselines/reference/reuseProgramStructure/redirect-previous-duplicate-packages.js index 2add0fb7bdc7a..a1d3a30d2dbb8 100644 --- a/tests/baselines/reference/reuseProgramStructure/redirect-previous-duplicate-packages.js +++ b/tests/baselines/reference/reuseProgramStructure/redirect-previous-duplicate-packages.js @@ -11,7 +11,7 @@ File: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; resolvedModules: -x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /node_modules/b/node_modules/x/index.d.ts @@ -26,7 +26,7 @@ File: /node_modules/b/index.d.ts import X from "x"; export const b: X; resolvedModules: -x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.4"}} +x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.4"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -34,8 +34,8 @@ File: /a.ts import { a } from "a"; import { b } from "b"; a(b) resolvedModules: -a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined @@ -59,7 +59,7 @@ File: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; resolvedModules: -x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /node_modules/b/node_modules/x/index.d.ts @@ -74,7 +74,7 @@ File: /node_modules/b/index.d.ts import X from "x"; export const b: X; resolvedModules: -x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -82,8 +82,8 @@ File: /a.ts import { a } from "a"; import { b } from "b"; a(b) resolvedModules: -a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/redirect-target-changes.js b/tests/baselines/reference/reuseProgramStructure/redirect-target-changes.js index b5092c7bd3668..ba88adf1b9d73 100644 --- a/tests/baselines/reference/reuseProgramStructure/redirect-target-changes.js +++ b/tests/baselines/reference/reuseProgramStructure/redirect-target-changes.js @@ -11,7 +11,7 @@ File: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; resolvedModules: -x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /node_modules/b/node_modules/x/index.d.ts @@ -26,7 +26,7 @@ File: /node_modules/b/index.d.ts import X from "x"; export const b: X; resolvedModules: -x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -34,8 +34,8 @@ File: /a.ts import { a } from "a"; import { b } from "b"; a(b) resolvedModules: -a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined @@ -57,7 +57,7 @@ File: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; resolvedModules: -x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /node_modules/b/node_modules/x/index.d.ts @@ -72,7 +72,7 @@ File: /node_modules/b/index.d.ts import X from "x"; export const b: X; resolvedModules: -x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -80,8 +80,8 @@ File: /a.ts import { a } from "a"; import { b } from "b"; a(b) resolvedModules: -a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/redirect-underlying-changes.js b/tests/baselines/reference/reuseProgramStructure/redirect-underlying-changes.js index 862191f70b6cf..31adae0658bca 100644 --- a/tests/baselines/reference/reuseProgramStructure/redirect-underlying-changes.js +++ b/tests/baselines/reference/reuseProgramStructure/redirect-underlying-changes.js @@ -11,7 +11,7 @@ File: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; resolvedModules: -x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /node_modules/b/node_modules/x/index.d.ts @@ -26,7 +26,7 @@ File: /node_modules/b/index.d.ts import X from "x"; export const b: X; resolvedModules: -x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -34,8 +34,8 @@ File: /a.ts import { a } from "a"; import { b } from "b"; a(b) resolvedModules: -a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined @@ -57,7 +57,7 @@ File: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; resolvedModules: -x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /node_modules/b/node_modules/x/index.d.ts @@ -72,7 +72,7 @@ File: /node_modules/b/index.d.ts import X from "x"; export const b: X; resolvedModules: -x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.4"}} +x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.4"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -80,8 +80,8 @@ File: /a.ts import { a } from "a"; import { b } from "b"; a(b) resolvedModules: -a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-no-change.js b/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-no-change.js index 51c155c3206b6..8a8faaea55cbb 100644 --- a/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-no-change.js +++ b/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-no-change.js @@ -11,7 +11,7 @@ File: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; resolvedModules: -x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /node_modules/b/node_modules/x/index.d.ts @@ -26,7 +26,7 @@ File: /node_modules/b/index.d.ts import X from "x"; export const b: X; resolvedModules: -x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -34,8 +34,8 @@ File: /a.ts import { a } from "a"; import { b } from "b"; a(b) resolvedModules: -a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined @@ -57,7 +57,7 @@ File: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; resolvedModules: -x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /node_modules/b/node_modules/x/index.d.ts @@ -72,7 +72,7 @@ File: /node_modules/b/index.d.ts import X from "x"; export const b: X; resolvedModules: -x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -80,8 +80,8 @@ File: /a.ts import { a } from "a"; import { b } from "b"; const x = 1; resolvedModules: -a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-previous-duplicate-packages.js b/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-previous-duplicate-packages.js index 2add0fb7bdc7a..a1d3a30d2dbb8 100644 --- a/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-previous-duplicate-packages.js +++ b/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-previous-duplicate-packages.js @@ -11,7 +11,7 @@ File: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; resolvedModules: -x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /node_modules/b/node_modules/x/index.d.ts @@ -26,7 +26,7 @@ File: /node_modules/b/index.d.ts import X from "x"; export const b: X; resolvedModules: -x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.4"}} +x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.4"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -34,8 +34,8 @@ File: /a.ts import { a } from "a"; import { b } from "b"; a(b) resolvedModules: -a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined @@ -59,7 +59,7 @@ File: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; resolvedModules: -x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /node_modules/b/node_modules/x/index.d.ts @@ -74,7 +74,7 @@ File: /node_modules/b/index.d.ts import X from "x"; export const b: X; resolvedModules: -x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -82,8 +82,8 @@ File: /a.ts import { a } from "a"; import { b } from "b"; a(b) resolvedModules: -a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-target-changes.js b/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-target-changes.js index b5092c7bd3668..ba88adf1b9d73 100644 --- a/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-target-changes.js +++ b/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-target-changes.js @@ -11,7 +11,7 @@ File: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; resolvedModules: -x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /node_modules/b/node_modules/x/index.d.ts @@ -26,7 +26,7 @@ File: /node_modules/b/index.d.ts import X from "x"; export const b: X; resolvedModules: -x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -34,8 +34,8 @@ File: /a.ts import { a } from "a"; import { b } from "b"; a(b) resolvedModules: -a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined @@ -57,7 +57,7 @@ File: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; resolvedModules: -x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /node_modules/b/node_modules/x/index.d.ts @@ -72,7 +72,7 @@ File: /node_modules/b/index.d.ts import X from "x"; export const b: X; resolvedModules: -x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -80,8 +80,8 @@ File: /a.ts import { a } from "a"; import { b } from "b"; a(b) resolvedModules: -a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-underlying-changes.js b/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-underlying-changes.js index 862191f70b6cf..31adae0658bca 100644 --- a/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-underlying-changes.js +++ b/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-underlying-changes.js @@ -11,7 +11,7 @@ File: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; resolvedModules: -x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /node_modules/b/node_modules/x/index.d.ts @@ -26,7 +26,7 @@ File: /node_modules/b/index.d.ts import X from "x"; export const b: X; resolvedModules: -x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -34,8 +34,8 @@ File: /a.ts import { a } from "a"; import { b } from "b"; a(b) resolvedModules: -a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined @@ -57,7 +57,7 @@ File: /node_modules/a/index.d.ts import X from "x"; export function a(x: X): void; resolvedModules: -x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"}} +x: {"resolvedFileName":"/node_modules/a/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.3"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /node_modules/b/node_modules/x/index.d.ts @@ -72,7 +72,7 @@ File: /node_modules/b/index.d.ts import X from "x"; export const b: X; resolvedModules: -x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.4"}} +x: {"resolvedFileName":"/node_modules/b/node_modules/x/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"packageId":{"name":"x","subModuleName":"index.d.ts","version":"1.2.4"},"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined File: /a.ts @@ -80,8 +80,8 @@ File: /a.ts import { a } from "a"; import { b } from "b"; a(b) resolvedModules: -a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} -b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true} +a: {"resolvedFileName":"/node_modules/a/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} +b: {"resolvedFileName":"/node_modules/b/index.d.ts","extension":".d.ts","isExternalLibraryImport":true,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/resolution-cache-follows-imports.js b/tests/baselines/reference/reuseProgramStructure/resolution-cache-follows-imports.js index 97252926f9a76..0222d6a4a125c 100644 --- a/tests/baselines/reference/reuseProgramStructure/resolution-cache-follows-imports.js +++ b/tests/baselines/reference/reuseProgramStructure/resolution-cache-follows-imports.js @@ -11,7 +11,7 @@ File: a.ts import {_} from 'b' var x = 1 resolvedModules: -b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false} +b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined @@ -34,7 +34,7 @@ File: a.ts import {_} from 'b' var x = 2 resolvedModules: -b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false} +b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined @@ -73,7 +73,7 @@ import x from 'b' var x = 2 resolvedModules: -b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false} +b: {"resolvedFileName":"b.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} c: undefined resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/resolvedImports-after-re-using-an-ambient-external-module-declaration.js b/tests/baselines/reference/reuseProgramStructure/resolvedImports-after-re-using-an-ambient-external-module-declaration.js index 7c19c1adf675b..9188752a800fc 100644 --- a/tests/baselines/reference/reuseProgramStructure/resolvedImports-after-re-using-an-ambient-external-module-declaration.js +++ b/tests/baselines/reference/reuseProgramStructure/resolvedImports-after-re-using-an-ambient-external-module-declaration.js @@ -4,7 +4,7 @@ File: /a.ts import * as a from "a"; resolvedModules: -a: {"resolvedFileName":"/a.ts","extension":".ts","isExternalLibraryImport":false} +a: {"resolvedFileName":"/a.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined @@ -19,7 +19,7 @@ File: /a.ts import * as aa from "a"; resolvedModules: -a: {"resolvedFileName":"/a.ts","extension":".ts","isExternalLibraryImport":false} +a: {"resolvedFileName":"/a.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/works-with-updated-SourceFiles.js b/tests/baselines/reference/reuseProgramStructure/works-with-updated-SourceFiles.js index 266d6122b5389..2940ddfc64487 100644 --- a/tests/baselines/reference/reuseProgramStructure/works-with-updated-SourceFiles.js +++ b/tests/baselines/reference/reuseProgramStructure/works-with-updated-SourceFiles.js @@ -4,7 +4,7 @@ File: /a.ts import * as a from "a";a; resolvedModules: -a: {"resolvedFileName":"/a.ts","extension":".ts","isExternalLibraryImport":false} +a: {"resolvedFileName":"/a.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined @@ -20,7 +20,7 @@ File: /a.ts import * as a from "a";a; resolvedModules: -a: {"resolvedFileName":"/a.ts","extension":".ts","isExternalLibraryImport":false} +a: {"resolvedFileName":"/a.ts","extension":".ts","isExternalLibraryImport":false,"resolvedUsingTsExtension":false} resolvedTypeReferenceDirectiveNames: undefined From f9414aa23dcdc5672763e1a40ca09982822e2275 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 5 Dec 2022 11:25:15 -0800 Subject: [PATCH 35/41] Fix bad merge conflict resolution --- src/compiler/moduleNameResolver.ts | 2 - ...esolvepackagejsonexports=false).trace.json | 2 +- ...resolvepackagejsonexports=true).trace.json | 1 - ...sextensions=false,noemit=false).trace.json | 2 - ...tsextensions=false,noemit=true).trace.json | 2 - ...tsextensions=true,noemit=false).trace.json | 2 - ...gtsextensions=true,noemit=true).trace.json | 2 - .../reference/hybridNodeModules1.trace.json | 1 - ...seUrl-without-path-mappings-or-rootDirs.js | 36 ++++++---- .../classic-baseUrl-path-mappings.js | 12 ++-- .../moduleResolution/classic-baseUrl.js | 12 ++-- .../moduleResolution/classic-rootDirs.js | 9 ++- .../moduleResolution/nested-node-module.js | 6 +- .../node-baseUrl-path-mappings.js | 42 +++++++---- .../moduleResolution/node-baseUrl.js | 24 ++++--- .../moduleResolution/node-rootDirs.js | 18 +++-- .../non-relative-module-name-as-directory.js | 6 +- ...module-name-as-file-ts-files-not-loaded.js | 6 +- .../non-relative-module-name-as-file.js | 6 +- .../non-relative-preserveSymlinks.js | 6 +- ...ive-preserves-originalPath-on-cache-hit.js | 6 +- ...-relative-uses-originalPath-for-caching.js | 6 +- ...ive-module-name-as-directory-load-index.js | 6 +- ...-name-as-directory-with-invalid-typings.js | 30 +++++--- .../relative-module-name-as-directory.js | 24 ++++--- .../relative-module-name-as-file.js | 72 ++++++++++++------- ...utionWithExtensions_unexpected2.trace.json | 4 -- ...lutionWithSuffixes_one_jsModule.trace.json | 4 -- .../reference/packageJsonMain.trace.json | 4 -- ...en-package-json-with-type-module-exists.js | 16 ----- .../package-json-file-is-edited.js | 20 ------ 31 files changed, 219 insertions(+), 170 deletions(-) diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 500eddd9f773e..3381bd7e839e0 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1755,8 +1755,6 @@ function loadModuleFromFile(extensions: Extensions, candidate: string, onlyRecor return resolvedByAddingExtension; } } - - return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state); } function loadModuleFromFileNoImplicitExtensions(extensions: Extensions, candidate: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined { diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).trace.json b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).trace.json index 922234fe125a0..49c7146ff7ee8 100644 --- a/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).trace.json +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).trace.json @@ -4,10 +4,10 @@ "File '/package.json' does not exist.", "Loading module 'lodash' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "Found 'package.json' at '/node_modules/lodash/package.json'.", - "'package.json' does not have a 'typesVersions' field.", "File '/node_modules/lodash.ts' does not exist.", "File '/node_modules/lodash.tsx' does not exist.", "File '/node_modules/lodash.d.ts' does not exist.", + "'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 'index.js' that references '/node_modules/lodash/index.js'.", diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).trace.json b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).trace.json index dd46403892a5a..8289b5cf1eab2 100644 --- a/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).trace.json +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).trace.json @@ -4,7 +4,6 @@ "File '/package.json' does not exist.", "Loading module 'lodash' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "Found 'package.json' at '/node_modules/lodash/package.json'.", - "'package.json' does not have a 'typesVersions' field.", "Saw non-matching condition 'browser'.", "Matched 'exports' condition 'webpack'.", "Using 'exports' subpath '.' with target './webpack.js'.", diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json index c248542bacc88..2ebe4e7c42081 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json @@ -96,8 +96,6 @@ "File '/project/a.d.ts.d.ts' does not exist.", "File '/project/a.d.ts.js' does not exist.", "File '/project/a.d.ts.jsx' does not exist.", - "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/a.d.ts' does not exist.", "Directory '/project/a.d.ts' does not exist, skipping all lookups in it.", "======== Module name './a.d.ts' was not resolved. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json index c248542bacc88..2ebe4e7c42081 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json @@ -96,8 +96,6 @@ "File '/project/a.d.ts.d.ts' does not exist.", "File '/project/a.d.ts.js' does not exist.", "File '/project/a.d.ts.jsx' does not exist.", - "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/a.d.ts' does not exist.", "Directory '/project/a.d.ts' does not exist, skipping all lookups in it.", "======== Module name './a.d.ts' was not resolved. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json index c248542bacc88..2ebe4e7c42081 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json @@ -96,8 +96,6 @@ "File '/project/a.d.ts.d.ts' does not exist.", "File '/project/a.d.ts.js' does not exist.", "File '/project/a.d.ts.jsx' does not exist.", - "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/a.d.ts' does not exist.", "Directory '/project/a.d.ts' does not exist, skipping all lookups in it.", "======== Module name './a.d.ts' was not resolved. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json index c248542bacc88..2ebe4e7c42081 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json @@ -96,8 +96,6 @@ "File '/project/a.d.ts.d.ts' does not exist.", "File '/project/a.d.ts.js' does not exist.", "File '/project/a.d.ts.jsx' does not exist.", - "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", - "File '/project/a.d.ts' does not exist.", "Directory '/project/a.d.ts' does not exist, skipping all lookups in it.", "======== Module name './a.d.ts' was not resolved. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/hybridNodeModules1.trace.json b/tests/baselines/reference/hybridNodeModules1.trace.json index 894b3616c2ee8..bcd13bb309acb 100644 --- a/tests/baselines/reference/hybridNodeModules1.trace.json +++ b/tests/baselines/reference/hybridNodeModules1.trace.json @@ -4,7 +4,6 @@ "File '/package.json' does not exist.", "Loading module 'dual' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "Found 'package.json' at '/node_modules/dual/package.json'.", - "'package.json' does not have a 'typesVersions' field.", "Matched 'exports' condition 'import'.", "Using 'exports' subpath '.' with target './index.js'.", "File name '/node_modules/dual/index.js' has a '.js' extension - stripping it.", diff --git a/tests/baselines/reference/moduleResolution/baseUrl-without-path-mappings-or-rootDirs.js b/tests/baselines/reference/moduleResolution/baseUrl-without-path-mappings-or-rootDirs.js index 520a6a54583f9..14ef468557a78 100644 --- a/tests/baselines/reference/moduleResolution/baseUrl-without-path-mappings-or-rootDirs.js +++ b/tests/baselines/reference/moduleResolution/baseUrl-without-path-mappings-or-rootDirs.js @@ -12,7 +12,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder2/file2.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -24,7 +25,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder2/file3.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -36,7 +38,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -48,7 +51,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder2/file2.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -60,7 +64,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder2/file3.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -72,7 +77,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -93,7 +99,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder2/file2.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -105,7 +112,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder2/file3.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -117,7 +125,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -129,7 +138,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder2/file2.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -141,7 +151,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder2/file3.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -153,7 +164,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], diff --git a/tests/baselines/reference/moduleResolution/classic-baseUrl-path-mappings.js b/tests/baselines/reference/moduleResolution/classic-baseUrl-path-mappings.js index 67446c13fdfe3..0fe5e46fd6887 100644 --- a/tests/baselines/reference/moduleResolution/classic-baseUrl-path-mappings.js +++ b/tests/baselines/reference/moduleResolution/classic-baseUrl-path-mappings.js @@ -12,7 +12,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -24,7 +25,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/generated/folder1/file2.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/folder1/file2.ts", @@ -40,7 +42,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/generated/folder1/file2.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -52,7 +55,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/folder1/file3.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/folder1/file3.ts", diff --git a/tests/baselines/reference/moduleResolution/classic-baseUrl.js b/tests/baselines/reference/moduleResolution/classic-baseUrl.js index ac6b67c8bb104..7cfbf4d21c7ba 100644 --- a/tests/baselines/reference/moduleResolution/classic-baseUrl.js +++ b/tests/baselines/reference/moduleResolution/classic-baseUrl.js @@ -12,7 +12,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/x/m1.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -24,7 +25,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/m2.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/x/m2.ts", @@ -58,7 +60,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/x/m1.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -70,7 +73,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/m2.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/x/m2.ts", diff --git a/tests/baselines/reference/moduleResolution/classic-rootDirs.js b/tests/baselines/reference/moduleResolution/classic-rootDirs.js index 40cb12c8eab55..830d01b1d344c 100644 --- a/tests/baselines/reference/moduleResolution/classic-rootDirs.js +++ b/tests/baselines/reference/moduleResolution/classic-rootDirs.js @@ -15,7 +15,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/generated/folder1/file2.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/folder1/file2.ts", @@ -31,7 +32,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/generated/folder1/file1.ts", @@ -47,7 +49,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/folder1/file1_1.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/generated/folder2/folder1/file1_1.ts", diff --git a/tests/baselines/reference/moduleResolution/nested-node-module.js b/tests/baselines/reference/moduleResolution/nested-node-module.js index ba9c0a1480782..e1b43964b8003 100644 --- a/tests/baselines/reference/moduleResolution/nested-node-module.js +++ b/tests/baselines/reference/moduleResolution/nested-node-module.js @@ -12,7 +12,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/src/libs/guid/dist/guid.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/src/libs/guid.ts", @@ -39,7 +40,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/src/libs/guid/dist/guid.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/src/libs/guid.ts", diff --git a/tests/baselines/reference/moduleResolution/node-baseUrl-path-mappings.js b/tests/baselines/reference/moduleResolution/node-baseUrl-path-mappings.js index d28fcbea219c2..c433eeddbcc24 100644 --- a/tests/baselines/reference/moduleResolution/node-baseUrl-path-mappings.js +++ b/tests/baselines/reference/moduleResolution/node-baseUrl-path-mappings.js @@ -24,7 +24,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -36,7 +37,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/generated/folder1/file2.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/folder1/file2.ts", @@ -56,7 +58,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/generated/folder1/file2.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -68,7 +71,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/generated/folder2/file3/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/folder2/file3.ts", @@ -94,7 +98,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/generated/folder2/file4/dist/types.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/folder2/file4.ts", @@ -119,7 +124,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/someanotherfolder/file5/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/someanotherfolder/file5.ts", @@ -138,7 +144,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/node_modules/file6.ts", "extension": ".ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/file6.ts", @@ -197,7 +204,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -209,7 +217,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/generated/folder1/file2.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/folder1/file2.ts", @@ -229,7 +238,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/generated/folder1/file2.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -241,7 +251,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/generated/folder2/file3/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/folder2/file3.ts", @@ -267,7 +278,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/generated/folder2/file4/dist/types.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/folder2/file4.ts", @@ -292,7 +304,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/someanotherfolder/file5/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/someanotherfolder/file5.ts", @@ -311,7 +324,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/node_modules/file6.ts", "extension": ".ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/file6.ts", diff --git a/tests/baselines/reference/moduleResolution/node-baseUrl.js b/tests/baselines/reference/moduleResolution/node-baseUrl.js index 9b786b1bb6e91..f560859620abf 100644 --- a/tests/baselines/reference/moduleResolution/node-baseUrl.js +++ b/tests/baselines/reference/moduleResolution/node-baseUrl.js @@ -21,7 +21,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/m1.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -33,7 +34,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/m2/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/m2.ts", @@ -52,7 +54,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/m3/dist/typings.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/m3.ts", @@ -70,7 +73,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/node_modules/m4.ts", "extension": ".ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/m4.ts", @@ -129,7 +133,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/m1.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -141,7 +146,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/m2/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/m2.ts", @@ -160,7 +166,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/m3/dist/typings.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/m3.ts", @@ -178,7 +185,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/node_modules/m4.ts", "extension": ".ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/m4.ts", diff --git a/tests/baselines/reference/moduleResolution/node-rootDirs.js b/tests/baselines/reference/moduleResolution/node-rootDirs.js index 49fd78c947f3b..94aefdea91f5a 100644 --- a/tests/baselines/reference/moduleResolution/node-rootDirs.js +++ b/tests/baselines/reference/moduleResolution/node-rootDirs.js @@ -15,7 +15,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/generated/folder1/file2.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/folder1/file2.ts", @@ -35,7 +36,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/generated/folder1/file1.ts", @@ -55,7 +57,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder1/file1_1/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/generated/folder1/file1_1.ts", @@ -93,7 +96,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/generated/folder1/file2.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/folder1/file2.ts", @@ -113,7 +117,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/generated/folder1/file1.ts", @@ -133,7 +138,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/root/folder1/file1_1/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/root/generated/folder1/file1_1.ts", diff --git a/tests/baselines/reference/moduleResolution/non-relative-module-name-as-directory.js b/tests/baselines/reference/moduleResolution/non-relative-module-name-as-directory.js index 8ca68184a2e98..44223b1d0149b 100644 --- a/tests/baselines/reference/moduleResolution/non-relative-module-name-as-directory.js +++ b/tests/baselines/reference/moduleResolution/non-relative-module-name-as-directory.js @@ -9,7 +9,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/a/node_modules/foo/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json", @@ -64,7 +65,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/a/node_modules/foo/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json", diff --git a/tests/baselines/reference/moduleResolution/non-relative-module-name-as-file-ts-files-not-loaded.js b/tests/baselines/reference/moduleResolution/non-relative-module-name-as-file-ts-files-not-loaded.js index da517407b2b34..5b0027cc014ef 100644 --- a/tests/baselines/reference/moduleResolution/non-relative-module-name-as-file-ts-files-not-loaded.js +++ b/tests/baselines/reference/moduleResolution/non-relative-module-name-as-file-ts-files-not-loaded.js @@ -9,7 +9,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/a/b/node_modules/foo.ts", "extension": ".ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/b/c/d/node_modules/foo/package.json", @@ -49,7 +50,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/a/b/node_modules/foo.ts", "extension": ".ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/b/c/d/node_modules/foo/package.json", diff --git a/tests/baselines/reference/moduleResolution/non-relative-module-name-as-file.js b/tests/baselines/reference/moduleResolution/non-relative-module-name-as-file.js index 25338e92e477a..3d87342150dfd 100644 --- a/tests/baselines/reference/moduleResolution/non-relative-module-name-as-file.js +++ b/tests/baselines/reference/moduleResolution/non-relative-module-name-as-file.js @@ -9,7 +9,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/a/b/node_modules/foo.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/b/c/d/node_modules/foo/package.json", @@ -51,7 +52,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/a/b/node_modules/foo.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/b/c/d/node_modules/foo/package.json", diff --git a/tests/baselines/reference/moduleResolution/non-relative-preserveSymlinks.js b/tests/baselines/reference/moduleResolution/non-relative-preserveSymlinks.js index ef68b82c1edb7..1076d7b29b92e 100644 --- a/tests/baselines/reference/moduleResolution/non-relative-preserveSymlinks.js +++ b/tests/baselines/reference/moduleResolution/non-relative-preserveSymlinks.js @@ -12,7 +12,8 @@ Resolution:: { "resolvedFileName": "/linked/index.d.ts", "originalPath": "/app/node_modules/linked/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/app/node_modules/linked.ts", @@ -41,7 +42,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/app/node_modules/linked/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/app/node_modules/linked.ts", diff --git a/tests/baselines/reference/moduleResolution/non-relative-preserves-originalPath-on-cache-hit.js b/tests/baselines/reference/moduleResolution/non-relative-preserves-originalPath-on-cache-hit.js index 6c209264fec47..022b020197157 100644 --- a/tests/baselines/reference/moduleResolution/non-relative-preserves-originalPath-on-cache-hit.js +++ b/tests/baselines/reference/moduleResolution/non-relative-preserves-originalPath-on-cache-hit.js @@ -12,7 +12,8 @@ Resolution:: { "resolvedFileName": "/linked/index.d.ts", "originalPath": "/app/node_modules/linked/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/app/src/node_modules/linked/package.json", @@ -44,7 +45,8 @@ Resolution:: { "resolvedFileName": "/linked/index.d.ts", "originalPath": "/app/node_modules/linked/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/app/src/node_modules/linked/package.json", diff --git a/tests/baselines/reference/moduleResolution/non-relative-uses-originalPath-for-caching.js b/tests/baselines/reference/moduleResolution/non-relative-uses-originalPath-for-caching.js index 905354c32cd1a..0a4603155c860 100644 --- a/tests/baselines/reference/moduleResolution/non-relative-uses-originalPath-for-caching.js +++ b/tests/baselines/reference/moduleResolution/non-relative-uses-originalPath-for-caching.js @@ -12,7 +12,8 @@ Resolution:: { "resolvedFileName": "/modules/a.ts", "originalPath": "/sub/node_modules/a/index.ts", "extension": ".ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/sub/dir/node_modules/a/package.json", @@ -42,7 +43,8 @@ Resolution:: { "resolvedFileName": "/modules/a.ts", "originalPath": "/sub/node_modules/a/index.ts", "extension": ".ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/sub/dir/node_modules/a/package.json", diff --git a/tests/baselines/reference/moduleResolution/relative-module-name-as-directory-load-index.js b/tests/baselines/reference/moduleResolution/relative-module-name-as-directory-load-index.js index 441de892edc81..f856d9262444d 100644 --- a/tests/baselines/reference/moduleResolution/relative-module-name-as-directory-load-index.js +++ b/tests/baselines/reference/moduleResolution/relative-module-name-as-directory-load-index.js @@ -12,7 +12,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/a/b/foo/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/b/foo.ts", @@ -48,7 +49,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/a/b/foo/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/b/foo.ts", diff --git a/tests/baselines/reference/moduleResolution/relative-module-name-as-directory-with-invalid-typings.js b/tests/baselines/reference/moduleResolution/relative-module-name-as-directory-with-invalid-typings.js index 1313664721b83..b9dc765e8f64a 100644 --- a/tests/baselines/reference/moduleResolution/relative-module-name-as-directory-with-invalid-typings.js +++ b/tests/baselines/reference/moduleResolution/relative-module-name-as-directory-with-invalid-typings.js @@ -15,7 +15,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/node_modules/b/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/node_modules/b/package.json", @@ -57,7 +58,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/node_modules/b/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/node_modules/b/package.json", @@ -99,7 +101,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/node_modules/b/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/node_modules/b/package.json", @@ -141,7 +144,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/node_modules/b/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/node_modules/b/package.json", @@ -183,7 +187,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/node_modules/b/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/node_modules/b/package.json", @@ -225,7 +230,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/node_modules/b/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/node_modules/b/package.json", @@ -267,7 +273,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/node_modules/b/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/node_modules/b/package.json", @@ -309,7 +316,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/node_modules/b/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/node_modules/b/package.json", @@ -351,7 +359,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/node_modules/b/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/node_modules/b/package.json", @@ -393,7 +402,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/node_modules/b/index.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": true + "isExternalLibraryImport": true, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/node_modules/b/package.json", diff --git a/tests/baselines/reference/moduleResolution/relative-module-name-as-directory.js b/tests/baselines/reference/moduleResolution/relative-module-name-as-directory.js index 2c8937052e702..ae6aa592c9de0 100644 --- a/tests/baselines/reference/moduleResolution/relative-module-name-as-directory.js +++ b/tests/baselines/reference/moduleResolution/relative-module-name-as-directory.js @@ -12,7 +12,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/a/b/c/bar/c/d/e.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/b/c/bar.ts", @@ -39,7 +40,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/a/b/c/bar/c/d/e.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/b/c/bar.ts", @@ -66,7 +68,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/a/bar/e.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/bar.ts", @@ -93,7 +96,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/a/bar/e.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/a/bar.ts", @@ -120,7 +124,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/bar/e.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/bar.ts", @@ -147,7 +152,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/bar/e.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/bar.ts", @@ -174,7 +180,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "c:/bar/e.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "c:/bar.ts", @@ -201,7 +208,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "c:/bar/e.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "c:/bar.ts", diff --git a/tests/baselines/reference/moduleResolution/relative-module-name-as-file.js b/tests/baselines/reference/moduleResolution/relative-module-name-as-file.js index f39c056c2b07a..529c3b057f304 100644 --- a/tests/baselines/reference/moduleResolution/relative-module-name-as-file.js +++ b/tests/baselines/reference/moduleResolution/relative-module-name-as-file.js @@ -10,7 +10,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo/bar/foo.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -28,7 +29,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo/bar/foo.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -46,7 +48,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo/bar/foo.tsx", "extension": ".tsx", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/foo/bar/foo.ts" @@ -66,7 +69,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo/bar/foo.tsx", "extension": ".tsx", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/foo/bar/foo.ts" @@ -86,7 +90,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo/bar/foo.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/foo/bar/foo.ts", @@ -107,7 +112,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo/bar/foo.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/foo/bar/foo.ts", @@ -130,7 +136,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo/foo.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -148,7 +155,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo/foo.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -166,7 +174,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo/foo.tsx", "extension": ".tsx", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/foo/foo.ts" @@ -186,7 +195,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo/foo.tsx", "extension": ".tsx", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/foo/foo.ts" @@ -206,7 +216,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo/foo.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/foo/foo.ts", @@ -227,7 +238,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo/foo.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/foo/foo.ts", @@ -250,7 +262,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -268,7 +281,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -286,7 +300,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo.tsx", "extension": ".tsx", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/foo.ts" @@ -306,7 +321,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo.tsx", "extension": ".tsx", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/foo.ts" @@ -326,7 +342,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/foo.ts", @@ -347,7 +364,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "/foo.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "/foo.ts", @@ -370,7 +388,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "c:/foo.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -388,7 +407,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "c:/foo.ts", "extension": ".ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [], "affectingLocations": [], @@ -406,7 +426,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "c:/foo.tsx", "extension": ".tsx", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "c:/foo.ts" @@ -426,7 +447,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "c:/foo.tsx", "extension": ".tsx", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "c:/foo.ts" @@ -446,7 +468,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "c:/foo.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "c:/foo.ts", @@ -467,7 +490,8 @@ Resolution:: { "resolvedModule": { "resolvedFileName": "c:/foo.d.ts", "extension": ".d.ts", - "isExternalLibraryImport": false + "isExternalLibraryImport": false, + "resolvedUsingTsExtension": false }, "failedLookupLocations": [ "c:/foo.ts", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json index cc002fa3d6f25..a2521c7f7395f 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json @@ -19,10 +19,6 @@ "File '/node_modules/foo/foo.js.ts' does not exist.", "File '/node_modules/foo/foo.js.tsx' does not exist.", "File '/node_modules/foo/foo.js.d.ts' does not exist.", - "File name '/node_modules/foo/foo.js' has a '.js' extension - stripping it.", - "File '/node_modules/foo/foo.ts' does not exist.", - "File '/node_modules/foo/foo.tsx' does not exist.", - "File '/node_modules/foo/foo.d.ts' does not exist.", "Directory '/node_modules/foo/foo.js' does not exist, skipping all lookups in it.", "File '/node_modules/foo/index.ts' does not exist.", "File '/node_modules/foo/index.tsx' does not exist.", diff --git a/tests/baselines/reference/moduleResolutionWithSuffixes_one_jsModule.trace.json b/tests/baselines/reference/moduleResolutionWithSuffixes_one_jsModule.trace.json index a63b584c81558..f1472c7f4c459 100644 --- a/tests/baselines/reference/moduleResolutionWithSuffixes_one_jsModule.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSuffixes_one_jsModule.trace.json @@ -9,10 +9,6 @@ "File '/foo.js.ios.ts' does not exist.", "File '/foo.js.ios.tsx' does not exist.", "File '/foo.js.ios.d.ts' does not exist.", - "File name '/foo.js' has a '.js' extension - stripping it.", - "File '/foo.ios.ts' does not exist.", - "File '/foo.ios.tsx' does not exist.", - "File '/foo.ios.d.ts' does not exist.", "Directory '/foo.js' does not exist, skipping all lookups in it.", "Loading module as file / folder, candidate module location '/foo.js', target file types: JavaScript.", "File name '/foo.js' has a '.js' extension - stripping it.", diff --git a/tests/baselines/reference/packageJsonMain.trace.json b/tests/baselines/reference/packageJsonMain.trace.json index ad862538465f5..0b4ae83be9631 100644 --- a/tests/baselines/reference/packageJsonMain.trace.json +++ b/tests/baselines/reference/packageJsonMain.trace.json @@ -51,10 +51,6 @@ "File '/node_modules/bar/rab.js.ts' does not exist.", "File '/node_modules/bar/rab.js.tsx' does not exist.", "File '/node_modules/bar/rab.js.d.ts' does not exist.", - "File name '/node_modules/bar/rab.js' has a '.js' extension - stripping it.", - "File '/node_modules/bar/rab.ts' does not exist.", - "File '/node_modules/bar/rab.tsx' does not exist.", - "File '/node_modules/bar/rab.d.ts' does not exist.", "Directory '/node_modules/bar/rab.js' does not exist, skipping all lookups in it.", "File '/node_modules/bar/index.ts' does not exist.", "File '/node_modules/bar/index.tsx' does not exist.", diff --git a/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js b/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js index af4b7b9ece81c..3d8b1ff5b569d 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited-when-package-json-with-type-module-exists.js @@ -50,10 +50,6 @@ File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extensi File '/user/username/projects/myproject/src/fileB.mts' does not exist. File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. File '/user/username/projects/myproject/src/fileB.mjs' does not exist. -File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. -File '/user/username/projects/myproject/src/fileB.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. ======== Module name './fileB.mjs' was not resolved. ======== DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src 0 undefined Failed Lookup Locations @@ -169,10 +165,6 @@ File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. File '/user/username/projects/myproject/src/fileB.mjs.js' does not exist. File '/user/username/projects/myproject/src/fileB.mjs.jsx' does not exist. -File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. -File '/user/username/projects/myproject/src/fileB.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. ======== Module name './fileB.mjs' was not resolved. ======== DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/fileB.mjs 1 undefined Failed Lookup Locations @@ -276,10 +268,6 @@ File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extensi File '/user/username/projects/myproject/src/fileB.mts' does not exist. File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. File '/user/username/projects/myproject/src/fileB.mjs' does not exist. -File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. -File '/user/username/projects/myproject/src/fileB.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. ======== Module name './fileB.mjs' was not resolved. ======== File '/a/lib/package.json' does not exist according to earlier cached lookups. @@ -390,10 +378,6 @@ File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. File '/user/username/projects/myproject/src/fileB.mjs.js' does not exist. File '/user/username/projects/myproject/src/fileB.mjs.jsx' does not exist. -File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. -File '/user/username/projects/myproject/src/fileB.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. ======== Module name './fileB.mjs' was not resolved. ======== DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/fileB.mjs 1 undefined Failed Lookup Locations diff --git a/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited.js b/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited.js index 1e5a35c06ecfc..688ac828dc9f7 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/package-json-file-is-edited.js @@ -55,10 +55,6 @@ File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. File '/user/username/projects/myproject/src/fileB.mjs.js' does not exist. File '/user/username/projects/myproject/src/fileB.mjs.jsx' does not exist. -File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. -File '/user/username/projects/myproject/src/fileB.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. ======== Module name './fileB.mjs' was not resolved. ======== DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/fileB.mjs 1 undefined Failed Lookup Locations @@ -175,10 +171,6 @@ File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extensi File '/user/username/projects/myproject/src/fileB.mts' does not exist. File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. File '/user/username/projects/myproject/src/fileB.mjs' does not exist. -File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. -File '/user/username/projects/myproject/src/fileB.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. ======== Module name './fileB.mjs' was not resolved. ======== File '/a/lib/package.json' does not exist according to earlier cached lookups. @@ -283,10 +275,6 @@ File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. File '/user/username/projects/myproject/src/fileB.mjs.js' does not exist. File '/user/username/projects/myproject/src/fileB.mjs.jsx' does not exist. -File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. -File '/user/username/projects/myproject/src/fileB.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. ======== Module name './fileB.mjs' was not resolved. ======== DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/fileB.mjs 1 undefined Failed Lookup Locations @@ -482,10 +470,6 @@ File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extensi File '/user/username/projects/myproject/src/fileB.mts' does not exist. File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. File '/user/username/projects/myproject/src/fileB.mjs' does not exist. -File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. -File '/user/username/projects/myproject/src/fileB.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. ======== Module name './fileB.mjs' was not resolved. ======== File '/a/lib/package.json' does not exist according to earlier cached lookups. @@ -597,10 +581,6 @@ File '/user/username/projects/myproject/src/fileB.mjs.tsx' does not exist. File '/user/username/projects/myproject/src/fileB.mjs.d.ts' does not exist. File '/user/username/projects/myproject/src/fileB.mjs.js' does not exist. File '/user/username/projects/myproject/src/fileB.mjs.jsx' does not exist. -File name '/user/username/projects/myproject/src/fileB.mjs' has a '.mjs' extension - stripping it. -File '/user/username/projects/myproject/src/fileB.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.d.mts' does not exist. -File '/user/username/projects/myproject/src/fileB.mjs' does not exist. Directory '/user/username/projects/myproject/src/fileB.mjs' does not exist, skipping all lookups in it. ======== Module name './fileB.mjs' was not resolved. ======== DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/fileB.mjs 1 undefined Failed Lookup Locations From dadc1a85722d89e35a94bc6e9e12099ecf858b6f Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 5 Dec 2022 15:49:38 -0800 Subject: [PATCH 36/41] Make resolvedUsingTsExtension optional --- src/compiler/types.ts | 2 +- src/testRunner/unittests/moduleResolution.ts | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 9663407956ac2..8cc9aaec0f2db 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -7224,7 +7224,7 @@ export interface ResolvedModule { * True if the original module reference used a .ts extension to refer directly to a .ts file, * which should produce an error during checking if emit is enabled. */ - resolvedUsingTsExtension: boolean; + resolvedUsingTsExtension?: boolean; } /** diff --git a/src/testRunner/unittests/moduleResolution.ts b/src/testRunner/unittests/moduleResolution.ts index 8b9326b0a3ed7..5ae7ebee71e56 100644 --- a/src/testRunner/unittests/moduleResolution.ts +++ b/src/testRunner/unittests/moduleResolution.ts @@ -169,7 +169,6 @@ describe("unittests:: moduleResolution:: Node module resolution - non-relative p resolvedFileName: "/sub/node_modules/a/index.ts", isExternalLibraryImport: true, extension: ts.Extension.Ts, - resolvedUsingTsExtension: false, }, failedLookupLocations: [], affectingLocations: [], @@ -185,7 +184,6 @@ describe("unittests:: moduleResolution:: Node module resolution - non-relative p resolvedFileName: "/sub/directory/node_modules/b/index.ts", isExternalLibraryImport: true, extension: ts.Extension.Ts, - resolvedUsingTsExtension: false, }, failedLookupLocations: [], affectingLocations: [], @@ -203,7 +201,6 @@ describe("unittests:: moduleResolution:: Node module resolution - non-relative p resolvedFileName: "/bar/node_modules/c/index.ts", isExternalLibraryImport: true, extension: ts.Extension.Ts, - resolvedUsingTsExtension: false, }, failedLookupLocations: [], affectingLocations: [], @@ -220,7 +217,6 @@ describe("unittests:: moduleResolution:: Node module resolution - non-relative p resolvedFileName: "/foo/index.ts", isExternalLibraryImport: true, extension: ts.Extension.Ts, - resolvedUsingTsExtension: false, }, failedLookupLocations: [], affectingLocations: [], @@ -236,7 +232,6 @@ describe("unittests:: moduleResolution:: Node module resolution - non-relative p resolvedFileName: "d:/bar/node_modules/e/index.ts", isExternalLibraryImport: true, extension: ts.Extension.Ts, - resolvedUsingTsExtension: false, }, failedLookupLocations: [], affectingLocations: [], From a88b8ad2d2232d6fa9a472e2ed8d69e96b383a9b Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Mon, 5 Dec 2022 16:14:49 -0800 Subject: [PATCH 37/41] Update missed baselines --- tests/baselines/reference/api/tsserverlibrary.d.ts | 2 +- tests/baselines/reference/api/typescript.d.ts | 2 +- ...gBasedModuleResolution_withExtensionInName.trace.json | 4 ---- ...esolution_withExtension_MapedToNodeModules.trace.json | 9 --------- 4 files changed, 2 insertions(+), 15 deletions(-) diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 3531ac353759f..1b487d09bab4b 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -7264,7 +7264,7 @@ declare namespace ts { * True if the original module reference used a .ts extension to refer directly to a .ts file, * which should produce an error during checking if emit is enabled. */ - resolvedUsingTsExtension: boolean; + resolvedUsingTsExtension?: boolean; } /** * ResolvedModule with an explicitly provided `extension` property. diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 1ba7f1d31489b..30d6d7d1017d2 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3331,7 +3331,7 @@ declare namespace ts { * True if the original module reference used a .ts extension to refer directly to a .ts file, * which should produce an error during checking if emit is enabled. */ - resolvedUsingTsExtension: boolean; + resolvedUsingTsExtension?: boolean; } /** * ResolvedModule with an explicitly provided `extension` property. diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtensionInName.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtensionInName.trace.json index 16777d9bc8128..771d7c8ccf8ae 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtensionInName.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtensionInName.trace.json @@ -13,10 +13,6 @@ "File '/foo/zone.js.ts' does not exist.", "File '/foo/zone.js.tsx' does not exist.", "File '/foo/zone.js.d.ts' does not exist.", - "File name '/foo/zone.js' has a '.js' extension - stripping it.", - "File '/foo/zone.ts' does not exist.", - "File '/foo/zone.tsx' does not exist.", - "File '/foo/zone.d.ts' does not exist.", "File '/foo/zone.js/package.json' does not exist.", "File '/foo/zone.js/index.ts' does not exist.", "File '/foo/zone.js/index.tsx' does not exist.", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.trace.json index 043f67b4aa2ec..ef53886c656c8 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.trace.json @@ -13,10 +13,6 @@ "File '/node_modules/foo/bar/foobar.js.ts' does not exist.", "File '/node_modules/foo/bar/foobar.js.tsx' does not exist.", "File '/node_modules/foo/bar/foobar.js.d.ts' does not exist.", - "File name '/node_modules/foo/bar/foobar.js' has a '.js' extension - stripping it.", - "File '/node_modules/foo/bar/foobar.ts' does not exist.", - "File '/node_modules/foo/bar/foobar.tsx' does not exist.", - "File '/node_modules/foo/bar/foobar.d.ts' does not exist.", "Directory '/node_modules/foo/bar/foobar.js' does not exist, skipping all lookups in it.", "Trying substitution 'src/types', candidate module location: 'src/types'.", "Loading module as file / folder, candidate module location '/src/types', target file types: TypeScript, Declaration.", @@ -29,13 +25,8 @@ "File '/node_modules/foo/bar/foobar.js.ts' does not exist.", "File '/node_modules/foo/bar/foobar.js.tsx' does not exist.", "File '/node_modules/foo/bar/foobar.js.d.ts' does not exist.", - "File name '/node_modules/foo/bar/foobar.js' has a '.js' extension - stripping it.", - "File '/node_modules/foo/bar/foobar.ts' does not exist.", - "File '/node_modules/foo/bar/foobar.tsx' does not exist.", - "File '/node_modules/foo/bar/foobar.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "File name '/node_modules/@types/foo/bar/foobar.js' has a '.js' extension - stripping it.", - "File name '/node_modules/@types/foo/bar/foobar.js' has a '.js' extension - stripping it.", "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo/bar/foobar.js'.", "'paths' option is specified, looking for a pattern to match module name 'foo/bar/foobar.js'.", "Module name 'foo/bar/foobar.js', matched pattern '*'.", From b2e283ca818d9c9a500bb00e62e5fed3d9e5d75f Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Tue, 6 Dec 2022 10:02:21 -0800 Subject: [PATCH 38/41] Revert now-unnecessary API implementation changes --- src/services/shims.ts | 2 +- src/testRunner/unittests/tscWatch/watchApi.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/services/shims.ts b/src/services/shims.ts index 4339931349053..6f36697703396 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -449,7 +449,7 @@ export class LanguageServiceShimHostAdapter implements LanguageServiceHost { const resolutionsInFile = JSON.parse(this.shimHost.getModuleResolutionsForFile!(containingFile)) as MapLike; // TODO: GH#18217 return map(moduleNames, name => { const result = getProperty(resolutionsInFile, name); - return result ? { resolvedFileName: result, extension: extensionFromPath(result), isExternalLibraryImport: false, resolvedUsingTsExtension: false } : undefined; + return result ? { resolvedFileName: result, extension: extensionFromPath(result), isExternalLibraryImport: false } : undefined; }); }; } diff --git a/src/testRunner/unittests/tscWatch/watchApi.ts b/src/testRunner/unittests/tscWatch/watchApi.ts index 6fc862f2c8eec..102bbd7746bfe 100644 --- a/src/testRunner/unittests/tscWatch/watchApi.ts +++ b/src/testRunner/unittests/tscWatch/watchApi.ts @@ -50,7 +50,6 @@ describe("unittests:: tsc-watch:: watchAPI:: tsc-watch with custom module resolu resolvedFileName: resolvedModule.resolvedFileName, isExternalLibraryImport: resolvedModule.isExternalLibraryImport, originalFileName: resolvedModule.originalPath, - resolvedUsingTsExtension: false, }; }); const watch = ts.createWatchProgram(host); From 30afa864244c141673eaa98bffcebf8a202643b1 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 9 Dec 2022 11:03:00 -0800 Subject: [PATCH 39/41] Clean up --- src/compiler/moduleNameResolver.ts | 4 +++- src/compiler/moduleSpecifiers.ts | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index c76ea56eb126e..048ef814ed7ec 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1768,7 +1768,9 @@ function loadModuleFromFileNoImplicitExtensions(extensions: Extensions, candidat // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" if (hasJSFileExtension(candidate) || extensions & Extensions.Json && fileExtensionIs(candidate, Extension.Json) || - extensions & (Extensions.TypeScript | Extensions.Declaration) && moduleResolutionSupportsResolvingTsExtensions(state.compilerOptions) && fileExtensionIsOneOf(candidate, supportedTSExtensionsFlat) + extensions & (Extensions.TypeScript | Extensions.Declaration) + && moduleResolutionSupportsResolvingTsExtensions(state.compilerOptions) + && fileExtensionIsOneOf(candidate, supportedTSExtensionsFlat) ) { const extensionless = removeFileExtension(candidate); const extension = candidate.substring(extensionless.length); diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index db509d2c74ce3..351d98a24bd19 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -116,7 +116,7 @@ interface Preferences { /** * @param syntaxImpliedNodeFormat Used when the import syntax implies ESM or CJS irrespective of the mode of the file. */ - getAllowedEndingsInPrefererredOrder(syntaxImpliedNodeFormat?: SourceFile["impliedNodeFormat"]): ModuleSpecifierEnding[]; + getAllowedEndingsInPreferredOrder(syntaxImpliedNodeFormat?: SourceFile["impliedNodeFormat"]): ModuleSpecifierEnding[]; } function getPreferences( @@ -135,8 +135,8 @@ function getPreferences( importModuleSpecifierPreference === "non-relative" ? RelativePreference.NonRelative : importModuleSpecifierPreference === "project-relative" ? RelativePreference.ExternalNonRelative : RelativePreference.Shortest, - getAllowedEndingsInPrefererredOrder: syntaxImpliedNodeFormat => { - if (syntaxImpliedNodeFormat === ModuleKind.ESNext || (syntaxImpliedNodeFormat ?? importingSourceFile.impliedNodeFormat) === ModuleKind.ESNext) { + getAllowedEndingsInPreferredOrder: syntaxImpliedNodeFormat => { + if ((syntaxImpliedNodeFormat ?? importingSourceFile.impliedNodeFormat) === ModuleKind.ESNext) { if (shouldAllowImportingTsExtension(compilerOptions, importingSourceFile.fileName)) { return [ModuleSpecifierEnding.TsExtension, ModuleSpecifierEnding.JsExtension]; } @@ -429,7 +429,7 @@ function getInfo(importingSourceFileName: Path, host: ModuleSpecifierResolutionH function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOptions: CompilerOptions, host: ModuleSpecifierResolutionHost, importMode: ResolutionMode, preferences: Preferences): string; function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOptions: CompilerOptions, host: ModuleSpecifierResolutionHost, importMode: ResolutionMode, preferences: Preferences, pathsOnly?: boolean): string | undefined; -function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOptions: CompilerOptions, host: ModuleSpecifierResolutionHost, importMode: ResolutionMode, { getAllowedEndingsInPrefererredOrder, relativePreference }: Preferences, pathsOnly?: boolean): string | undefined { +function getLocalModuleSpecifier(moduleFileName: string, info: Info, compilerOptions: CompilerOptions, host: ModuleSpecifierResolutionHost, importMode: ResolutionMode, { getAllowedEndingsInPreferredOrder: getAllowedEndingsInPrefererredOrder, relativePreference }: Preferences, pathsOnly?: boolean): string | undefined { const { baseUrl, paths, rootDirs } = compilerOptions; if (pathsOnly && !paths) { return undefined; @@ -883,7 +883,7 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }: ModulePath, { getCan // Simplify the full file path to something that can be resolved by Node. const preferences = getPreferences(userPreferences, options, importingSourceFile); - const allowedEndings = preferences.getAllowedEndingsInPrefererredOrder(); + const allowedEndings = preferences.getAllowedEndingsInPreferredOrder(); let moduleSpecifier = path; let isPackageRootPath = false; if (!packageNameOnly) { From 6e763d969eeeb332bb9104e5232b9ede41ba48cb Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 9 Dec 2022 12:10:37 -0800 Subject: [PATCH 40/41] Update baselines to es5 emit --- ...ditions(resolvepackagejsonexports=false).js | 2 +- ...nditions(resolvepackagejsonexports=true).js | 2 +- tests/baselines/reference/hybridImportESM.js | 6 +++--- ...mportingtsextensions=false,noemit=false).js | 10 +++++----- ...importingtsextensions=true,noemit=false).js | 10 +++++----- .../baselines/reference/hybridNodeModules1.js | 6 +++--- tests/baselines/reference/hybridRelative1.js | 6 +++--- .../reference/hybridSyntaxRestrictions.js | 4 ++-- .../getSupportedCodeFixes-can-be-proxied.js | 18 ++++++++++++++++++ 9 files changed, 41 insertions(+), 23 deletions(-) diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).js b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).js index 8f831b27639a6..1ac29a4a032d3 100644 --- a/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).js +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).js @@ -30,4 +30,4 @@ import _ from "lodash"; //// [index.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).js b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).js index 8f831b27639a6..1ac29a4a032d3 100644 --- a/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).js +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).js @@ -30,4 +30,4 @@ import _ from "lodash"; //// [index.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/hybridImportESM.js b/tests/baselines/reference/hybridImportESM.js index 266e72301eaa5..9104892650c5a 100644 --- a/tests/baselines/reference/hybridImportESM.js +++ b/tests/baselines/reference/hybridImportESM.js @@ -15,12 +15,12 @@ import { esm } from "./esm.mjs"; //// [esm.mjs] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); exports.esm = void 0; exports.esm = 0; //// [not-actually-cjs.cjs] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); //// [still-not-cjs.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).js b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).js index 82f75ee374412..bb552961f4adc 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).js +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).js @@ -67,16 +67,16 @@ import type {} from "./a.d.ts"; //// [a.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); //// [index.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); //// [e.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); //// [e.txt.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); //// [main.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).js b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).js index 82f75ee374412..bb552961f4adc 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).js +++ b/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).js @@ -67,16 +67,16 @@ import type {} from "./a.d.ts"; //// [a.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); //// [index.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); //// [e.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); //// [e.txt.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); //// [main.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/hybridNodeModules1.js b/tests/baselines/reference/hybridNodeModules1.js index 03ed212a2f875..97b4ba34ff3d9 100644 --- a/tests/baselines/reference/hybridNodeModules1.js +++ b/tests/baselines/reference/hybridNodeModules1.js @@ -39,10 +39,10 @@ import { esm, cjs } from "dual"; //// [main.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); //// [main.mjs] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); //// [main.cjs] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/hybridRelative1.js b/tests/baselines/reference/hybridRelative1.js index 3c009b0588bcd..1eab035117f24 100644 --- a/tests/baselines/reference/hybridRelative1.js +++ b/tests/baselines/reference/hybridRelative1.js @@ -34,14 +34,14 @@ import * as cjs from "./types/cjs"; //// [index.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); exports.x = void 0; exports.x = 0; //// [index.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); exports.y = void 0; exports.y = 0; //// [main.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/hybridSyntaxRestrictions.js b/tests/baselines/reference/hybridSyntaxRestrictions.js index 95ac57e551973..7b066f1ff6dcf 100644 --- a/tests/baselines/reference/hybridSyntaxRestrictions.js +++ b/tests/baselines/reference/hybridSyntaxRestrictions.js @@ -21,12 +21,12 @@ export const a = "a"; //// [a.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); exports.a = void 0; exports.a = "a"; //// [mainJs.js] "use strict"; -exports.__esModule = true; +Object.defineProperty(exports, "__esModule", { value: true }); Promise.resolve().then(function () { return require("./a"); }); var _ = require("./a"); // No resolution _.a; // any diff --git a/tests/baselines/reference/tsserver/plugins/getSupportedCodeFixes-can-be-proxied.js b/tests/baselines/reference/tsserver/plugins/getSupportedCodeFixes-can-be-proxied.js index 12b3d134c26e8..cb8ce333a59cd 100644 --- a/tests/baselines/reference/tsserver/plugins/getSupportedCodeFixes-can-be-proxied.js +++ b/tests/baselines/reference/tsserver/plugins/getSupportedCodeFixes-can-be-proxied.js @@ -1143,6 +1143,7 @@ Info 32 [00:01:13.000] response: "2842", "2843", "2844", + "2846", "4000", "4002", "4004", @@ -1293,6 +1294,11 @@ Info 32 [00:01:13.000] response: "5093", "5094", "5095", + "5096", + "5097", + "5098", + "5099", + "5100", "6044", "6045", "6046", @@ -2463,6 +2469,7 @@ Info 38 [00:01:19.000] response: "2842", "2843", "2844", + "2846", "4000", "4002", "4004", @@ -2613,6 +2620,11 @@ Info 38 [00:01:19.000] response: "5093", "5094", "5095", + "5096", + "5097", + "5098", + "5099", + "5100", "6044", "6045", "6046", @@ -3695,6 +3707,7 @@ Info 40 [00:01:21.000] response: "2842", "2843", "2844", + "2846", "4000", "4002", "4004", @@ -3845,6 +3858,11 @@ Info 40 [00:01:21.000] response: "5093", "5094", "5095", + "5096", + "5097", + "5098", + "5099", + "5100", "6044", "6045", "6046", From d4a3b3c248e947211fe004023ccc4362ee4d02cc Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Tue, 13 Dec 2022 13:06:37 -0800 Subject: [PATCH 41/41] Rename to `bundler` --- src/compiler/binder.ts | 2 +- src/compiler/checker.ts | 16 +++++----- src/compiler/commandLineParser.ts | 8 ++--- src/compiler/diagnosticMessages.json | 12 ++++---- src/compiler/moduleNameResolver.ts | 18 +++++------ src/compiler/program.ts | 14 ++++----- src/compiler/types.ts | 2 +- src/compiler/utilities.ts | 10 +++---- .../reference/api/tsserverlibrary.d.ts | 4 +-- tests/baselines/reference/api/typescript.d.ts | 4 +-- ...hybridImportESM.js => bundlerImportESM.js} | 2 +- ...rtESM.symbols => bundlerImportESM.symbols} | 0 ...ImportESM.types => bundlerImportESM.types} | 0 ...extensions=false,noemit=false).errors.txt} | 0 ...ortingtsextensions=false,noemit=false).js} | 2 +- ...gtsextensions=false,noemit=false).symbols} | 0 ...extensions=false,noemit=false).trace.json} | 30 +++++++++---------- ...ingtsextensions=false,noemit=false).types} | 0 ...sextensions=false,noemit=true).errors.txt} | 0 ...ngtsextensions=false,noemit=true).symbols} | 0 ...sextensions=false,noemit=true).trace.json} | 30 +++++++++---------- ...tingtsextensions=false,noemit=true).types} | 0 ...sextensions=true,noemit=false).errors.txt} | 4 +-- ...portingtsextensions=true,noemit=false).js} | 2 +- ...ngtsextensions=true,noemit=false).symbols} | 0 ...sextensions=true,noemit=false).trace.json} | 30 +++++++++---------- ...tingtsextensions=true,noemit=false).types} | 0 ...tsextensions=true,noemit=true).errors.txt} | 0 ...ingtsextensions=true,noemit=true).symbols} | 0 ...tsextensions=true,noemit=true).trace.json} | 30 +++++++++---------- ...rtingtsextensions=true,noemit=true).types} | 0 ...ors.txt => bundlerNodeModules1.errors.txt} | 0 ...NodeModules1.js => bundlerNodeModules1.js} | 2 +- ...s1.symbols => bundlerNodeModules1.symbols} | 0 ...ce.json => bundlerNodeModules1.trace.json} | 2 +- ...dules1.types => bundlerNodeModules1.types} | 0 ...errors.txt => bundlerRelative1.errors.txt} | 0 ...hybridRelative1.js => bundlerRelative1.js} | 2 +- ...tive1.symbols => bundlerRelative1.symbols} | 0 ...trace.json => bundlerRelative1.trace.json} | 16 +++++----- ...Relative1.types => bundlerRelative1.types} | 0 ...t => bundlerSyntaxRestrictions.errors.txt} | 8 ++--- ...ctions.js => bundlerSyntaxRestrictions.js} | 2 +- ...bols => bundlerSyntaxRestrictions.symbols} | 0 ....types => bundlerSyntaxRestrictions.types} | 0 ...rse empty options of --moduleResolution.js | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- .../tsconfig.json | 2 +- ...esolvepackagejsonexports=false).trace.json | 2 +- ...resolvepackagejsonexports=true).trace.json | 2 +- ...riority(moduleresolution=bundler).symbols} | 0 ...gPriority(moduleresolution=bundler).types} | 0 ...ompat(moduleresolution=classic).errors.txt | 8 ++--- ...onCompat(moduleresolution=node).errors.txt | 8 ++--- .../bundlerImportESM.ts} | 2 +- .../bundlerImportTsExtensions.ts} | 2 +- .../bundlerNodeModules1.ts} | 2 +- .../bundlerRelative1.ts} | 2 +- .../bundlerSyntaxRestrictions.ts} | 2 +- .../moduleResolution/customConditions.ts | 2 +- .../extensionLoadingPriority.ts | 2 +- .../packageJsonImportsExportsOptionCompat.ts | 2 +- .../fourslash/autoImportAllowTsExtensions1.ts | 2 +- .../fourslash/autoImportAllowTsExtensions2.ts | 2 +- .../fourslash/autoImportAllowTsExtensions3.ts | 2 +- .../fourslash/autoImportAllowTsExtensions4.ts | 2 +- .../pathCompletionsAllowTsExtensions.ts | 2 +- 76 files changed, 161 insertions(+), 161 deletions(-) rename tests/baselines/reference/{hybridImportESM.js => bundlerImportESM.js} (84%) rename tests/baselines/reference/{hybridImportESM.symbols => bundlerImportESM.symbols} (100%) rename tests/baselines/reference/{hybridImportESM.types => bundlerImportESM.types} (100%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt => bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt} (100%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).js => bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).js} (91%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).symbols => bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).symbols} (100%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json => bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json} (88%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).types => bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).types} (100%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt => bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt} (100%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).symbols => bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).symbols} (100%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json => bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json} (88%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).types => bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).types} (100%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt => bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt} (91%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).js => bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).js} (91%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).symbols => bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).symbols} (100%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json => bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json} (88%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).types => bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).types} (100%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt => bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt} (100%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).symbols => bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).symbols} (100%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json => bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json} (88%) rename tests/baselines/reference/{hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).types => bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).types} (100%) rename tests/baselines/reference/{hybridNodeModules1.errors.txt => bundlerNodeModules1.errors.txt} (100%) rename tests/baselines/reference/{hybridNodeModules1.js => bundlerNodeModules1.js} (88%) rename tests/baselines/reference/{hybridNodeModules1.symbols => bundlerNodeModules1.symbols} (100%) rename tests/baselines/reference/{hybridNodeModules1.trace.json => bundlerNodeModules1.trace.json} (95%) rename tests/baselines/reference/{hybridNodeModules1.types => bundlerNodeModules1.types} (100%) rename tests/baselines/reference/{hybridRelative1.errors.txt => bundlerRelative1.errors.txt} (100%) rename tests/baselines/reference/{hybridRelative1.js => bundlerRelative1.js} (89%) rename tests/baselines/reference/{hybridRelative1.symbols => bundlerRelative1.symbols} (100%) rename tests/baselines/reference/{hybridRelative1.trace.json => bundlerRelative1.trace.json} (90%) rename tests/baselines/reference/{hybridRelative1.types => bundlerRelative1.types} (100%) rename tests/baselines/reference/{hybridSyntaxRestrictions.errors.txt => bundlerSyntaxRestrictions.errors.txt} (69%) rename tests/baselines/reference/{hybridSyntaxRestrictions.js => bundlerSyntaxRestrictions.js} (85%) rename tests/baselines/reference/{hybridSyntaxRestrictions.symbols => bundlerSyntaxRestrictions.symbols} (100%) rename tests/baselines/reference/{hybridSyntaxRestrictions.types => bundlerSyntaxRestrictions.types} (100%) rename tests/baselines/reference/{extensionLoadingPriority(moduleresolution=hybrid).symbols => extensionLoadingPriority(moduleresolution=bundler).symbols} (100%) rename tests/baselines/reference/{extensionLoadingPriority(moduleresolution=hybrid).types => extensionLoadingPriority(moduleresolution=bundler).types} (100%) rename tests/cases/conformance/moduleResolution/{hybrid/hybridImportESM.ts => bundler/bundlerImportESM.ts} (88%) rename tests/cases/conformance/moduleResolution/{hybrid/hybridImportTsExtensions.ts => bundler/bundlerImportTsExtensions.ts} (95%) rename tests/cases/conformance/moduleResolution/{hybrid/hybridNodeModules1.ts => bundler/bundlerNodeModules1.ts} (96%) rename tests/cases/conformance/moduleResolution/{hybrid/hybridRelative1.ts => bundler/bundlerRelative1.ts} (95%) rename tests/cases/conformance/moduleResolution/{hybrid/hybridSyntaxRestrictions.ts => bundler/bundlerSyntaxRestrictions.ts} (93%) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 1f9f269723444..d6bc1769ea5f3 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -3522,7 +3522,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { if (!isBindingPattern(node.name)) { const possibleVariableDecl = node.kind === SyntaxKind.VariableDeclaration ? node : node.parent.parent; if (isInJSFile(node) && - getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Hybrid && + getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Bundler && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & ModifierFlags.Export) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 16cbde17b8195..3d9d48b1bb893 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4547,7 +4547,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if ( namespace.valueDeclaration && isInJSFile(namespace.valueDeclaration) && - getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Hybrid && + getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Bundler && isVariableDeclaration(namespace.valueDeclaration) && namespace.valueDeclaration.initializer && isCommonJsRequire(namespace.valueDeclaration.initializer) @@ -33326,7 +33326,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } // In JavaScript files, calls to any identifier 'require' are treated as external module imports - if (isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Hybrid && isCommonJsRequire(node)) { + if (isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Bundler && isCommonJsRequire(node)) { return resolveExternalModuleTypeByLiteral(node.arguments![0] as StringLiteral); } @@ -42728,8 +42728,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // 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); } - else if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Hybrid) { - grammarErrorOnNode(node, Diagnostics.Import_assignment_is_not_allowed_when_moduleResolution_is_set_to_hybrid_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); + else if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Bundler) { + grammarErrorOnNode(node, Diagnostics.Import_assignment_is_not_allowed_when_moduleResolution_is_set_to_bundler_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -42953,8 +42953,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // system modules does not support export assignment grammarErrorOnNode(node, Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); } - else if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Hybrid) { - grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_moduleResolution_is_set_to_hybrid_Consider_using_export_default_or_another_module_format_instead); + else if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Bundler) { + grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_moduleResolution_is_set_to_bundler_Consider_using_export_default_or_another_module_format_instead); } } } @@ -44050,7 +44050,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // 4). type A = import("./f/*gotToDefinitionHere*/oo") 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.Hybrid && isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || isImportCall(node.parent)) || + ((isInJSFile(node) && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Bundler && isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || isImportCall(node.parent)) || (isLiteralTypeNode(node.parent) && isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent) ) { return resolveExternalModuleName(node, node as LiteralExpression, ignoreErrors); @@ -47356,4 +47356,4 @@ class SymbolTrackerImpl implements SymbolTracker { private onDiagnosticReported() { this.context.reportedDiagnostic = true; } -} \ No newline at end of file +} diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 60ed28d965141..e8f5452edfcba 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -965,7 +965,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [ classic: ModuleResolutionKind.Classic, node16: ModuleResolutionKind.Node16, nodenext: ModuleResolutionKind.NodeNext, - hybrid: ModuleResolutionKind.Hybrid, + bundler: ModuleResolutionKind.Bundler, })), affectsModuleResolution: true, paramType: Diagnostics.STRATEGY, @@ -1087,7 +1087,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [ type: "boolean", affectsModuleResolution: true, category: Diagnostics.Modules, - description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_hybrid_and_either_noEmit_or_emitDeclarationOnly_to_be_set, + description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_bundler_and_either_noEmit_or_emitDeclarationOnly_to_be_set, defaultValueDescription: false, }, { @@ -1096,7 +1096,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [ affectsModuleResolution: true, category: Diagnostics.Modules, description: Diagnostics.Use_the_package_json_exports_field_when_resolving_package_imports, - defaultValueDescription: Diagnostics.true_when_moduleResolution_is_node16_nodenext_or_hybrid_otherwise_false, + defaultValueDescription: Diagnostics.true_when_moduleResolution_is_node16_nodenext_or_bundler_otherwise_false, }, { name: "resolvePackageJsonImports", @@ -1104,7 +1104,7 @@ const commandOptionsWithoutBuild: CommandLineOption[] = [ affectsModuleResolution: true, category: Diagnostics.Modules, description: Diagnostics.Use_the_package_json_imports_field_when_resolving_imports, - defaultValueDescription: Diagnostics.true_when_moduleResolution_is_node16_nodenext_or_hybrid_otherwise_false, + defaultValueDescription: Diagnostics.true_when_moduleResolution_is_node16_nodenext_or_bundler_otherwise_false, }, { name: "customConditions", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index bee4bc522c85f..ad3d9ec3e3eba 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4225,7 +4225,7 @@ "category": "Error", "code": 5095 }, - "Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'hybrid' and either 'noEmit' or 'emitDeclarationOnly' is set.": { + "Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'bundler' and either 'noEmit' or 'emitDeclarationOnly' is set.": { "category": "Error", "code": 5096 }, @@ -4233,15 +4233,15 @@ "category": "Error", "code": 5097 }, - "Option '{0}' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'.": { + "Option '{0}' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'.": { "category": "Error", "code": 5098 }, - "Import assignment is not allowed when 'moduleResolution' is set to 'hybrid'. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead.": { + "Import assignment is not allowed when 'moduleResolution' is set to 'bundler'. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead.": { "category": "Error", "code": 5099 }, - "Export assignment cannot be used when 'moduleResolution' is set to 'hybrid'. Consider using 'export default' or another module format instead.": { + "Export assignment cannot be used when 'moduleResolution' is set to 'bundler'. Consider using 'export default' or another module format instead.": { "category": "Error", "code": 5100 }, @@ -5450,7 +5450,7 @@ "category": "Message", "code": 6406 }, - "Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set.": { + "Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set.": { "category": "Message", "code": 6407 }, @@ -5466,7 +5466,7 @@ "category": "Message", "code": 6410 }, - "`true` when 'moduleResolution' is 'node16', 'nodenext', or 'hybrid'; otherwise `false`.": { + "`true` when 'moduleResolution' is 'node16', 'nodenext', or 'bundler'; otherwise `false`.": { "category": "Message", "code": 6411 }, diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 585231137ff6a..5a1c504bc2515 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -638,8 +638,8 @@ function getNodeResolutionFeatures(options: CompilerOptions) { case ModuleResolutionKind.NodeNext: features = NodeResolutionFeatures.NodeNextDefault; break; - case ModuleResolutionKind.Hybrid: - features = NodeResolutionFeatures.HybridDefault; + case ModuleResolutionKind.Bundler: + features = NodeResolutionFeatures.BundlerDefault; break; } if (options.resolvePackageJsonExports) { @@ -658,9 +658,9 @@ function getNodeResolutionFeatures(options: CompilerOptions) { } function getConditions(options: CompilerOptions, esmMode?: boolean) { - // conditions are only used by the node16/nodenext/hybrid resolvers - there's no priority order in the list, + // conditions are only used by the node16/nodenext/bundler resolvers - there's no priority order in the list, // it's essentially a set (priority is determined by object insertion order in the object we look at). - const conditions = esmMode || getEmitModuleResolutionKind(options) === ModuleResolutionKind.Hybrid + const conditions = esmMode || getEmitModuleResolutionKind(options) === ModuleResolutionKind.Bundler ? ["node", "import"] : ["node", "require"]; if (!options.noDtsResolution) { @@ -1284,8 +1284,8 @@ export function resolveModuleName(moduleName: string, containingFile: string, co case ModuleResolutionKind.Classic: result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; - case ModuleResolutionKind.Hybrid: - result = hybridModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); + case ModuleResolutionKind.Bundler: + result = bundlerModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: return Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`); @@ -1541,7 +1541,7 @@ export enum NodeResolutionFeatures { NodeNextDefault = AllFeatures, - HybridDefault = Imports | SelfName | Exports | ExportsPatternTrailers, + BundlerDefault = Imports | SelfName | Exports | ExportsPatternTrailers, EsmMode = 1 << 5, } @@ -1601,7 +1601,7 @@ function tryResolveJSModuleWorker(moduleName: string, initialDir: string, host: /*redirectedReferences*/ undefined); } -export function hybridModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations { +export function bundlerModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations { const containingDirectory = getDirectoryPath(containingFile); let extensions = compilerOptions.noDtsResolution ? Extensions.ImplementationFiles : Extensions.TypeScript | Extensions.JavaScript | Extensions.Declaration; if (getResolveJsonModule(compilerOptions)) { @@ -2969,7 +2969,7 @@ export function classicNameResolver(moduleName: string, containingFile: string, } export function moduleResolutionSupportsResolvingTsExtensions(compilerOptions: CompilerOptions) { - return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Hybrid; + return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Bundler; } // Program errors validate that `noEmit` or `emitDeclarationOnly` is also set, diff --git a/src/compiler/program.ts b/src/compiler/program.ts index c8e9a5fea3358..ee27160a182e9 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -3162,8 +3162,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg collectModuleReferences(node, /*inAmbientModule*/ false); } - // `require` has no special meaning in `--moduleResolution hybrid` - const shouldProcessRequires = isJavaScriptFile && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Hybrid; + // `require` has no special meaning in `--moduleResolution bundler` + const shouldProcessRequires = isJavaScriptFile && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Bundler; if ((file.flags & NodeFlags.PossiblyContainsDynamicImport) || shouldProcessRequires) { collectDynamicImportOrRequireCalls(file); } @@ -4121,7 +4121,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeNext && - getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Hybrid) { + getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Bundler) { createDiagnosticForOptionName(Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule"); } // Any emit other than common js, amd, es2015 or esnext is error @@ -4213,18 +4213,18 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg } if (options.allowImportingTsExtensions && !(moduleResolutionSupportsResolvingTsExtensions(options) && (options.noEmit || options.emitDeclarationOnly))) { - createOptionValueDiagnostic("allowImportingTsExtensions", Diagnostics.Option_allowImportingTsExtensions_can_only_be_used_when_moduleResolution_is_set_to_hybrid_and_either_noEmit_or_emitDeclarationOnly_is_set); + createOptionValueDiagnostic("allowImportingTsExtensions", Diagnostics.Option_allowImportingTsExtensions_can_only_be_used_when_moduleResolution_is_set_to_bundler_and_either_noEmit_or_emitDeclarationOnly_is_set); } const moduleResolution = getEmitModuleResolutionKind(options); if (options.resolvePackageJsonExports && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) { - createOptionValueDiagnostic("resolvePackageJsonExports", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_hybrid, "resolvePackageJsonExports"); + createOptionValueDiagnostic("resolvePackageJsonExports", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler, "resolvePackageJsonExports"); } if (options.resolvePackageJsonImports && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) { - createOptionValueDiagnostic("resolvePackageJsonImports", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_hybrid, "resolvePackageJsonImports"); + createOptionValueDiagnostic("resolvePackageJsonImports", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler, "resolvePackageJsonImports"); } if (options.customConditions && !moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) { - createOptionValueDiagnostic("customConditions", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_hybrid, "customConditions"); + createOptionValueDiagnostic("customConditions", Diagnostics.Option_0_can_only_be_used_when_moduleResolution_is_set_to_node16_nodenext_or_bundler, "customConditions"); } // If the emit is enabled make sure that every output file is unique and not overwriting any of the input files diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0dad4de51a17a..52cd88091726b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -6886,7 +6886,7 @@ export enum ModuleResolutionKind { // In turn, we offer both a `NodeNext` moving resolution target, and a `Node16` version-anchored resolution target Node16 = 3, NodeNext = 99, // Not simply `Node16` so that compiled code linked against TS can use the `Next` value reliably (same as with `ModuleKind`) - Hybrid = 100, + Bundler = 100, } export enum ModuleDetectionKind { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 73ac5a2e36278..4f69ae16f98a5 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -7780,13 +7780,13 @@ export function getAllowSyntheticDefaultImports(compilerOptions: CompilerOptions } return getESModuleInterop(compilerOptions) || getEmitModuleKind(compilerOptions) === ModuleKind.System - || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Hybrid; + || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Bundler; } /** @internal */ export function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution: ModuleResolutionKind): boolean { return moduleResolution >= ModuleResolutionKind.Node16 && moduleResolution <= ModuleResolutionKind.NodeNext - || moduleResolution === ModuleResolutionKind.Hybrid; + || moduleResolution === ModuleResolutionKind.Bundler; } /** @internal */ @@ -7801,7 +7801,7 @@ export function getResolvePackageJsonExports(compilerOptions: CompilerOptions) { switch (moduleResolution) { case ModuleResolutionKind.Node16: case ModuleResolutionKind.NodeNext: - case ModuleResolutionKind.Hybrid: + case ModuleResolutionKind.Bundler: return true; } return false; @@ -7819,7 +7819,7 @@ export function getResolvePackageJsonImports(compilerOptions: CompilerOptions) { switch (moduleResolution) { case ModuleResolutionKind.Node16: case ModuleResolutionKind.NodeNext: - case ModuleResolutionKind.Hybrid: + case ModuleResolutionKind.Bundler: return true; } return false; @@ -7830,7 +7830,7 @@ export function getResolveJsonModule(compilerOptions: CompilerOptions) { if (compilerOptions.resolveJsonModule !== undefined) { return compilerOptions.resolveJsonModule; } - return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Hybrid; + return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Bundler; } /** @internal */ diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 3615aabce2ab3..cad75d3083540 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -6972,7 +6972,7 @@ declare namespace ts { NodeJs = 2, Node16 = 3, NodeNext = 99, - Hybrid = 100 + Bundler = 100 } enum ModuleDetectionKind { /** @@ -9213,7 +9213,7 @@ declare namespace ts { function createTypeReferenceDirectiveResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions, packageJsonInfoCache?: PackageJsonInfoCache): TypeReferenceDirectiveResolutionCache; function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache, mode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations | undefined; function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations; - function hybridModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + function bundlerModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; function moduleResolutionSupportsResolvingTsExtensions(compilerOptions: CompilerOptions): boolean; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 3bb8af561e2e4..c6bb421d196b8 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3038,7 +3038,7 @@ declare namespace ts { NodeJs = 2, Node16 = 3, NodeNext = 99, - Hybrid = 100 + Bundler = 100 } enum ModuleDetectionKind { /** @@ -5279,7 +5279,7 @@ declare namespace ts { function createTypeReferenceDirectiveResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions, packageJsonInfoCache?: PackageJsonInfoCache): TypeReferenceDirectiveResolutionCache; function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache, mode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations | undefined; function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, resolutionMode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations; - function hybridModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + function bundlerModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; function moduleResolutionSupportsResolvingTsExtensions(compilerOptions: CompilerOptions): boolean; diff --git a/tests/baselines/reference/hybridImportESM.js b/tests/baselines/reference/bundlerImportESM.js similarity index 84% rename from tests/baselines/reference/hybridImportESM.js rename to tests/baselines/reference/bundlerImportESM.js index 9104892650c5a..efe3cbd491689 100644 --- a/tests/baselines/reference/hybridImportESM.js +++ b/tests/baselines/reference/bundlerImportESM.js @@ -1,4 +1,4 @@ -//// [tests/cases/conformance/moduleResolution/hybrid/hybridImportESM.ts] //// +//// [tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts] //// //// [esm.mts] export const esm = 0; diff --git a/tests/baselines/reference/hybridImportESM.symbols b/tests/baselines/reference/bundlerImportESM.symbols similarity index 100% rename from tests/baselines/reference/hybridImportESM.symbols rename to tests/baselines/reference/bundlerImportESM.symbols diff --git a/tests/baselines/reference/hybridImportESM.types b/tests/baselines/reference/bundlerImportESM.types similarity index 100% rename from tests/baselines/reference/hybridImportESM.types rename to tests/baselines/reference/bundlerImportESM.types diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt similarity index 100% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).errors.txt diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).js b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).js similarity index 91% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).js rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).js index bb552961f4adc..e6f603d88dc3b 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).js +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).js @@ -1,4 +1,4 @@ -//// [tests/cases/conformance/moduleResolution/hybrid/hybridImportTsExtensions.ts] //// +//// [tests/cases/conformance/moduleResolution/bundler/bundlerImportTsExtensions.ts] //// //// [a.ts] export {}; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).symbols b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).symbols similarity index 100% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).symbols rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).symbols diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json similarity index 88% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json index 2ebe4e7c42081..16bd4a9de2e58 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json @@ -1,58 +1,58 @@ [ "======== Resolving module './a' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/a', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/a.ts' exist - use it as a name resolution result.", "======== Module name './a' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/a.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.js' has a '.js' extension - stripping it.", "File '/project/a.ts' exist - use it as a name resolution result.", "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/a.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.ts' has a '.ts' extension - stripping it.", "File '/project/a.ts' exist - use it as a name resolution result.", "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './b' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/b', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/b.ts' exist - use it as a name resolution result.", "======== Module name './b' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/b.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.js' has a '.js' extension - stripping it.", "File '/project/b.ts' exist - use it as a name resolution result.", "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/b.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.ts' has a '.ts' extension - stripping it.", "File '/project/b.ts' exist - use it as a name resolution result.", "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/b.d.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", "File '/project/b.d.ts' exist - use it as a name resolution result.", "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", "======== Resolving module './c.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/c.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/c.ts' has a '.ts' extension - stripping it.", "File '/project/c.ts' exist - use it as a name resolution result.", "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", "======== Resolving module './c.tsx' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/c.tsx', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", "File '/project/c.tsx' exist - use it as a name resolution result.", "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", "======== Resolving module './d' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/d', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/d.ts' does not exist.", "File '/project/d.tsx' does not exist.", @@ -63,23 +63,23 @@ "File '/project/d/index.ts' exist - use it as a name resolution result.", "======== Module name './d' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './d/index' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/d/index', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/d/index.ts' exist - use it as a name resolution result.", "======== Module name './d/index' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/d/index.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", "File '/project/d/index.ts' exist - use it as a name resolution result.", "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './e' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/e', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/e.ts' exist - use it as a name resolution result.", "======== Module name './e' was successfully resolved to '/project/e.ts'. ========", "======== Resolving module './e.txt' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/e.txt', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/e.txt.ts' exist - use it as a name resolution result.", "======== Module name './e.txt' was successfully resolved to '/project/e.txt.ts'. ========", @@ -87,7 +87,7 @@ "Resolution for module './a.ts' was found in cache from location '/project'.", "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/a.d.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", "File '/project/a.d.ts' does not exist.", diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).types b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).types similarity index 100% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).types rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=false).types diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt similarity index 100% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).errors.txt diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).symbols b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).symbols similarity index 100% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).symbols rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).symbols diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json similarity index 88% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json index 2ebe4e7c42081..16bd4a9de2e58 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json @@ -1,58 +1,58 @@ [ "======== Resolving module './a' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/a', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/a.ts' exist - use it as a name resolution result.", "======== Module name './a' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/a.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.js' has a '.js' extension - stripping it.", "File '/project/a.ts' exist - use it as a name resolution result.", "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/a.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.ts' has a '.ts' extension - stripping it.", "File '/project/a.ts' exist - use it as a name resolution result.", "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './b' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/b', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/b.ts' exist - use it as a name resolution result.", "======== Module name './b' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/b.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.js' has a '.js' extension - stripping it.", "File '/project/b.ts' exist - use it as a name resolution result.", "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/b.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.ts' has a '.ts' extension - stripping it.", "File '/project/b.ts' exist - use it as a name resolution result.", "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/b.d.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", "File '/project/b.d.ts' exist - use it as a name resolution result.", "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", "======== Resolving module './c.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/c.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/c.ts' has a '.ts' extension - stripping it.", "File '/project/c.ts' exist - use it as a name resolution result.", "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", "======== Resolving module './c.tsx' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/c.tsx', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", "File '/project/c.tsx' exist - use it as a name resolution result.", "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", "======== Resolving module './d' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/d', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/d.ts' does not exist.", "File '/project/d.tsx' does not exist.", @@ -63,23 +63,23 @@ "File '/project/d/index.ts' exist - use it as a name resolution result.", "======== Module name './d' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './d/index' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/d/index', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/d/index.ts' exist - use it as a name resolution result.", "======== Module name './d/index' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/d/index.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", "File '/project/d/index.ts' exist - use it as a name resolution result.", "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './e' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/e', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/e.ts' exist - use it as a name resolution result.", "======== Module name './e' was successfully resolved to '/project/e.ts'. ========", "======== Resolving module './e.txt' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/e.txt', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/e.txt.ts' exist - use it as a name resolution result.", "======== Module name './e.txt' was successfully resolved to '/project/e.txt.ts'. ========", @@ -87,7 +87,7 @@ "Resolution for module './a.ts' was found in cache from location '/project'.", "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/a.d.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", "File '/project/a.d.ts' does not exist.", diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).types b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).types similarity index 100% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).types rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=false,noemit=true).types diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt similarity index 91% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt index d8c5a67083615..683dac372525f 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).errors.txt @@ -1,6 +1,6 @@ error TS5056: Cannot write file 'out/b.js' because it would be overwritten by multiple input files. error TS5056: Cannot write file 'out/c.js' because it would be overwritten by multiple input files. -error TS5096: Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'hybrid' and either 'noEmit' or 'emitDeclarationOnly' is set. +error TS5096: Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'bundler' and either 'noEmit' or 'emitDeclarationOnly' is set. error TS6054: File '/project/e.txt' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. The file is in the program because: Root file specified for compilation @@ -12,7 +12,7 @@ error TS6054: File '/project/e.txt' has an unsupported extension. The only suppo !!! error TS5056: Cannot write file 'out/b.js' because it would be overwritten by multiple input files. !!! error TS5056: Cannot write file 'out/c.js' because it would be overwritten by multiple input files. -!!! error TS5096: Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'hybrid' and either 'noEmit' or 'emitDeclarationOnly' is set. +!!! error TS5096: Option 'allowImportingTsExtensions' can only be used when 'moduleResolution' is set to 'bundler' and either 'noEmit' or 'emitDeclarationOnly' is set. !!! error TS6054: File '/project/e.txt' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. !!! error TS6054: The file is in the program because: !!! error TS6054: Root file specified for compilation diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).js b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).js similarity index 91% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).js rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).js index bb552961f4adc..e6f603d88dc3b 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).js +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).js @@ -1,4 +1,4 @@ -//// [tests/cases/conformance/moduleResolution/hybrid/hybridImportTsExtensions.ts] //// +//// [tests/cases/conformance/moduleResolution/bundler/bundlerImportTsExtensions.ts] //// //// [a.ts] export {}; diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).symbols b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).symbols similarity index 100% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).symbols rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).symbols diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json similarity index 88% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json index 2ebe4e7c42081..16bd4a9de2e58 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=false).trace.json +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).trace.json @@ -1,58 +1,58 @@ [ "======== Resolving module './a' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/a', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/a.ts' exist - use it as a name resolution result.", "======== Module name './a' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/a.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.js' has a '.js' extension - stripping it.", "File '/project/a.ts' exist - use it as a name resolution result.", "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/a.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.ts' has a '.ts' extension - stripping it.", "File '/project/a.ts' exist - use it as a name resolution result.", "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './b' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/b', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/b.ts' exist - use it as a name resolution result.", "======== Module name './b' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/b.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.js' has a '.js' extension - stripping it.", "File '/project/b.ts' exist - use it as a name resolution result.", "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/b.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.ts' has a '.ts' extension - stripping it.", "File '/project/b.ts' exist - use it as a name resolution result.", "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/b.d.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", "File '/project/b.d.ts' exist - use it as a name resolution result.", "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", "======== Resolving module './c.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/c.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/c.ts' has a '.ts' extension - stripping it.", "File '/project/c.ts' exist - use it as a name resolution result.", "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", "======== Resolving module './c.tsx' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/c.tsx', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", "File '/project/c.tsx' exist - use it as a name resolution result.", "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", "======== Resolving module './d' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/d', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/d.ts' does not exist.", "File '/project/d.tsx' does not exist.", @@ -63,23 +63,23 @@ "File '/project/d/index.ts' exist - use it as a name resolution result.", "======== Module name './d' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './d/index' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/d/index', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/d/index.ts' exist - use it as a name resolution result.", "======== Module name './d/index' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/d/index.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", "File '/project/d/index.ts' exist - use it as a name resolution result.", "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './e' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/e', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/e.ts' exist - use it as a name resolution result.", "======== Module name './e' was successfully resolved to '/project/e.ts'. ========", "======== Resolving module './e.txt' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/e.txt', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/e.txt.ts' exist - use it as a name resolution result.", "======== Module name './e.txt' was successfully resolved to '/project/e.txt.ts'. ========", @@ -87,7 +87,7 @@ "Resolution for module './a.ts' was found in cache from location '/project'.", "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/a.d.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", "File '/project/a.d.ts' does not exist.", diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).types b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).types similarity index 100% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=false).types rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=false).types diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt similarity index 100% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).errors.txt diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).symbols b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).symbols similarity index 100% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).symbols rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).symbols diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json similarity index 88% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json index 2ebe4e7c42081..16bd4a9de2e58 100644 --- a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=false,noemit=true).trace.json +++ b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).trace.json @@ -1,58 +1,58 @@ [ "======== Resolving module './a' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/a', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/a.ts' exist - use it as a name resolution result.", "======== Module name './a' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/a.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.js' has a '.js' extension - stripping it.", "File '/project/a.ts' exist - use it as a name resolution result.", "======== Module name './a.js' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/a.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.ts' has a '.ts' extension - stripping it.", "File '/project/a.ts' exist - use it as a name resolution result.", "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './b' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/b', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/b.ts' exist - use it as a name resolution result.", "======== Module name './b' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.js' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/b.js', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.js' has a '.js' extension - stripping it.", "File '/project/b.ts' exist - use it as a name resolution result.", "======== Module name './b.js' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/b.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.ts' has a '.ts' extension - stripping it.", "File '/project/b.ts' exist - use it as a name resolution result.", "======== Module name './b.ts' was successfully resolved to '/project/b.ts'. ========", "======== Resolving module './b.d.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/b.d.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/b.d.ts' has a '.d.ts' extension - stripping it.", "File '/project/b.d.ts' exist - use it as a name resolution result.", "======== Module name './b.d.ts' was successfully resolved to '/project/b.d.ts'. ========", "======== Resolving module './c.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/c.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/c.ts' has a '.ts' extension - stripping it.", "File '/project/c.ts' exist - use it as a name resolution result.", "======== Module name './c.ts' was successfully resolved to '/project/c.ts'. ========", "======== Resolving module './c.tsx' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/c.tsx', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/c.tsx' has a '.tsx' extension - stripping it.", "File '/project/c.tsx' exist - use it as a name resolution result.", "======== Module name './c.tsx' was successfully resolved to '/project/c.tsx'. ========", "======== Resolving module './d' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/d', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/d.ts' does not exist.", "File '/project/d.tsx' does not exist.", @@ -63,23 +63,23 @@ "File '/project/d/index.ts' exist - use it as a name resolution result.", "======== Module name './d' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './d/index' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/d/index', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/d/index.ts' exist - use it as a name resolution result.", "======== Module name './d/index' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './d/index.ts' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/d/index.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/d/index.ts' has a '.ts' extension - stripping it.", "File '/project/d/index.ts' exist - use it as a name resolution result.", "======== Module name './d/index.ts' was successfully resolved to '/project/d/index.ts'. ========", "======== Resolving module './e' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/e', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/e.ts' exist - use it as a name resolution result.", "======== Module name './e' was successfully resolved to '/project/e.ts'. ========", "======== Resolving module './e.txt' from '/project/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/e.txt', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/project/e.txt.ts' exist - use it as a name resolution result.", "======== Module name './e.txt' was successfully resolved to '/project/e.txt.ts'. ========", @@ -87,7 +87,7 @@ "Resolution for module './a.ts' was found in cache from location '/project'.", "======== Module name './a.ts' was successfully resolved to '/project/a.ts'. ========", "======== Resolving module './a.d.ts' from '/project/types.d.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/project/a.d.ts', target file types: TypeScript, JavaScript, Declaration, JSON.", "File name '/project/a.d.ts' has a '.d.ts' extension - stripping it.", "File '/project/a.d.ts' does not exist.", diff --git a/tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).types b/tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).types similarity index 100% rename from tests/baselines/reference/hybridImportTsExtensions(allowimportingtsextensions=true,noemit=true).types rename to tests/baselines/reference/bundlerImportTsExtensions(allowimportingtsextensions=true,noemit=true).types diff --git a/tests/baselines/reference/hybridNodeModules1.errors.txt b/tests/baselines/reference/bundlerNodeModules1.errors.txt similarity index 100% rename from tests/baselines/reference/hybridNodeModules1.errors.txt rename to tests/baselines/reference/bundlerNodeModules1.errors.txt diff --git a/tests/baselines/reference/hybridNodeModules1.js b/tests/baselines/reference/bundlerNodeModules1.js similarity index 88% rename from tests/baselines/reference/hybridNodeModules1.js rename to tests/baselines/reference/bundlerNodeModules1.js index 97b4ba34ff3d9..8567c3f9b4561 100644 --- a/tests/baselines/reference/hybridNodeModules1.js +++ b/tests/baselines/reference/bundlerNodeModules1.js @@ -1,4 +1,4 @@ -//// [tests/cases/conformance/moduleResolution/hybrid/hybridNodeModules1.ts] //// +//// [tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts] //// //// [package.json] { diff --git a/tests/baselines/reference/hybridNodeModules1.symbols b/tests/baselines/reference/bundlerNodeModules1.symbols similarity index 100% rename from tests/baselines/reference/hybridNodeModules1.symbols rename to tests/baselines/reference/bundlerNodeModules1.symbols diff --git a/tests/baselines/reference/hybridNodeModules1.trace.json b/tests/baselines/reference/bundlerNodeModules1.trace.json similarity index 95% rename from tests/baselines/reference/hybridNodeModules1.trace.json rename to tests/baselines/reference/bundlerNodeModules1.trace.json index bcd13bb309acb..d1f74dccd4b1a 100644 --- a/tests/baselines/reference/hybridNodeModules1.trace.json +++ b/tests/baselines/reference/bundlerNodeModules1.trace.json @@ -1,6 +1,6 @@ [ "======== Resolving module 'dual' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "File '/package.json' does not exist.", "Loading module 'dual' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "Found 'package.json' at '/node_modules/dual/package.json'.", diff --git a/tests/baselines/reference/hybridNodeModules1.types b/tests/baselines/reference/bundlerNodeModules1.types similarity index 100% rename from tests/baselines/reference/hybridNodeModules1.types rename to tests/baselines/reference/bundlerNodeModules1.types diff --git a/tests/baselines/reference/hybridRelative1.errors.txt b/tests/baselines/reference/bundlerRelative1.errors.txt similarity index 100% rename from tests/baselines/reference/hybridRelative1.errors.txt rename to tests/baselines/reference/bundlerRelative1.errors.txt diff --git a/tests/baselines/reference/hybridRelative1.js b/tests/baselines/reference/bundlerRelative1.js similarity index 89% rename from tests/baselines/reference/hybridRelative1.js rename to tests/baselines/reference/bundlerRelative1.js index 1eab035117f24..9238cc0f8ef3b 100644 --- a/tests/baselines/reference/hybridRelative1.js +++ b/tests/baselines/reference/bundlerRelative1.js @@ -1,4 +1,4 @@ -//// [tests/cases/conformance/moduleResolution/hybrid/hybridRelative1.ts] //// +//// [tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts] //// //// [index.ts] export const x = 0; diff --git a/tests/baselines/reference/hybridRelative1.symbols b/tests/baselines/reference/bundlerRelative1.symbols similarity index 100% rename from tests/baselines/reference/hybridRelative1.symbols rename to tests/baselines/reference/bundlerRelative1.symbols diff --git a/tests/baselines/reference/hybridRelative1.trace.json b/tests/baselines/reference/bundlerRelative1.trace.json similarity index 90% rename from tests/baselines/reference/hybridRelative1.trace.json rename to tests/baselines/reference/bundlerRelative1.trace.json index 1c13c05219f26..19e7e28acd7ea 100644 --- a/tests/baselines/reference/hybridRelative1.trace.json +++ b/tests/baselines/reference/bundlerRelative1.trace.json @@ -1,6 +1,6 @@ [ "======== Resolving module './dir' from '/main.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "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.", @@ -11,24 +11,24 @@ "File '/dir/index.ts' exist - 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: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "Loading module as file / folder, candidate module location '/dir/index', target file types: TypeScript, JavaScript, Declaration, JSON.", "File '/dir/index.ts' exist - 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: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "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' exist - 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: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "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' exist - 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: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "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.", @@ -50,7 +50,7 @@ "File '/foo/index.ts' exist - 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: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "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.", @@ -60,14 +60,14 @@ "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: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "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' exist - 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: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "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.", diff --git a/tests/baselines/reference/hybridRelative1.types b/tests/baselines/reference/bundlerRelative1.types similarity index 100% rename from tests/baselines/reference/hybridRelative1.types rename to tests/baselines/reference/bundlerRelative1.types diff --git a/tests/baselines/reference/hybridSyntaxRestrictions.errors.txt b/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt similarity index 69% rename from tests/baselines/reference/hybridSyntaxRestrictions.errors.txt rename to tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt index e058049f3cd67..bae60c5cc726a 100644 --- a/tests/baselines/reference/hybridSyntaxRestrictions.errors.txt +++ b/tests/baselines/reference/bundlerSyntaxRestrictions.errors.txt @@ -1,6 +1,6 @@ error TS2468: Cannot find global value 'Promise'. -/main.ts(2,1): error TS5099: Import assignment is not allowed when 'moduleResolution' is set to 'hybrid'. 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 TS5100: Export assignment cannot be used when 'moduleResolution' is set to 'hybrid'. Consider using 'export default' or another module format instead. +/main.ts(2,1): error TS5099: Import assignment is not allowed when 'moduleResolution' is set to 'bundler'. 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 TS5100: Export assignment cannot be used when 'moduleResolution' is set to 'bundler'. 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. @@ -20,10 +20,10 @@ error TS2468: Cannot find global value 'Promise'. import {} from "./a"; import _ = require("./a"); // Error ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS5099: Import assignment is not allowed when 'moduleResolution' is set to 'hybrid'. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. +!!! error TS5099: Import assignment is not allowed when 'moduleResolution' is set to 'bundler'. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead. export = {}; // Error ~~~~~~~~~~~~ -!!! error TS5100: Export assignment cannot be used when 'moduleResolution' is set to 'hybrid'. Consider using 'export default' or another module format instead. +!!! error TS5100: Export assignment cannot be used when 'moduleResolution' is set to 'bundler'. Consider using 'export default' or another module format instead. export {}; ==== /a.ts (0 errors) ==== diff --git a/tests/baselines/reference/hybridSyntaxRestrictions.js b/tests/baselines/reference/bundlerSyntaxRestrictions.js similarity index 85% rename from tests/baselines/reference/hybridSyntaxRestrictions.js rename to tests/baselines/reference/bundlerSyntaxRestrictions.js index 7b066f1ff6dcf..cd49b3c2efd7d 100644 --- a/tests/baselines/reference/hybridSyntaxRestrictions.js +++ b/tests/baselines/reference/bundlerSyntaxRestrictions.js @@ -1,4 +1,4 @@ -//// [tests/cases/conformance/moduleResolution/hybrid/hybridSyntaxRestrictions.ts] //// +//// [tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts] //// //// [index.d.ts] declare var require: (...args: any[]) => any; diff --git a/tests/baselines/reference/hybridSyntaxRestrictions.symbols b/tests/baselines/reference/bundlerSyntaxRestrictions.symbols similarity index 100% rename from tests/baselines/reference/hybridSyntaxRestrictions.symbols rename to tests/baselines/reference/bundlerSyntaxRestrictions.symbols diff --git a/tests/baselines/reference/hybridSyntaxRestrictions.types b/tests/baselines/reference/bundlerSyntaxRestrictions.types similarity index 100% rename from tests/baselines/reference/hybridSyntaxRestrictions.types rename to tests/baselines/reference/bundlerSyntaxRestrictions.types diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse empty options of --moduleResolution.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse empty options of --moduleResolution.js index 2bcff8882d32d..562f23f1a7748 100644 --- a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse empty options of --moduleResolution.js +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse empty options of --moduleResolution.js @@ -7,4 +7,4 @@ FileNames:: 0.ts Errors:: error TS6044: Compiler option 'moduleResolution' expects an argument. -error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext', 'hybrid'. +error TS6046: Argument for '--moduleResolution' option must be: 'node', 'classic', 'node16', 'nodenext', 'bundler'. diff --git a/tests/baselines/reference/config/initTSConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Default initialized TSConfig/tsconfig.json index 6c441a8d09dc3..5eaa44daaec1e 100644 --- a/tests/baselines/reference/config/initTSConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Default initialized TSConfig/tsconfig.json @@ -35,7 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --help/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --help/tsconfig.json index 6c441a8d09dc3..5eaa44daaec1e 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --help/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --help/tsconfig.json @@ -35,7 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --watch/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --watch/tsconfig.json index 6c441a8d09dc3..5eaa44daaec1e 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --watch/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with --watch/tsconfig.json @@ -35,7 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with advanced options/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with advanced options/tsconfig.json index 51189f709b334..00903ad0c38a1 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with advanced options/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with advanced options/tsconfig.json @@ -35,7 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index 73cfaeb1e2781..07e8da2a6e437 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -35,7 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index 0ea88943dc980..ff2c5a0a7e672 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -35,7 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with files options/tsconfig.json index 9977c19ffc059..3955bbd422ede 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with files options/tsconfig.json @@ -35,7 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 8564d1f1c2aa8..f635f645ea08b 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -35,7 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index 6c441a8d09dc3..5eaa44daaec1e 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -35,7 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index 2b4eafb70befb..ed7f34f5e6557 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -35,7 +35,7 @@ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ diff --git a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options/tsconfig.json index 4a2a162913e21..cc9d87c258ddb 100644 --- a/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/config/initTSConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -35,7 +35,7 @@ "types": ["jquery","mocha"], /* Specify type package names to be included without being referenced in a source file. */ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ - // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution hybrid' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).trace.json b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).trace.json index 49c7146ff7ee8..1b85a4d6fcaf1 100644 --- a/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).trace.json +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=false).trace.json @@ -1,6 +1,6 @@ [ "======== Resolving module 'lodash' from '/index.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "File '/package.json' does not exist.", "Loading module 'lodash' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "Found 'package.json' at '/node_modules/lodash/package.json'.", diff --git a/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).trace.json b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).trace.json index 8289b5cf1eab2..2019c28fc9f0d 100644 --- a/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).trace.json +++ b/tests/baselines/reference/customConditions(resolvepackagejsonexports=true).trace.json @@ -1,6 +1,6 @@ [ "======== Resolving module 'lodash' from '/index.ts'. ========", - "Explicitly specified module resolution kind: 'Hybrid'.", + "Explicitly specified module resolution kind: 'Bundler'.", "File '/package.json' does not exist.", "Loading module 'lodash' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", "Found 'package.json' at '/node_modules/lodash/package.json'.", diff --git a/tests/baselines/reference/extensionLoadingPriority(moduleresolution=hybrid).symbols b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=bundler).symbols similarity index 100% rename from tests/baselines/reference/extensionLoadingPriority(moduleresolution=hybrid).symbols rename to tests/baselines/reference/extensionLoadingPriority(moduleresolution=bundler).symbols diff --git a/tests/baselines/reference/extensionLoadingPriority(moduleresolution=hybrid).types b/tests/baselines/reference/extensionLoadingPriority(moduleresolution=bundler).types similarity index 100% rename from tests/baselines/reference/extensionLoadingPriority(moduleresolution=hybrid).types rename to tests/baselines/reference/extensionLoadingPriority(moduleresolution=bundler).types diff --git a/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=classic).errors.txt b/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=classic).errors.txt index 023c4dc8610ad..93ffdb73d1766 100644 --- a/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=classic).errors.txt +++ b/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=classic).errors.txt @@ -1,8 +1,8 @@ -error TS5098: Option 'resolvePackageJsonExports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'. -error TS5098: Option 'resolvePackageJsonImports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'. +error TS5098: Option 'resolvePackageJsonExports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'. +error TS5098: Option 'resolvePackageJsonImports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'. -!!! error TS5098: Option 'resolvePackageJsonExports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'. -!!! error TS5098: Option 'resolvePackageJsonImports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'. +!!! error TS5098: Option 'resolvePackageJsonExports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'. +!!! error TS5098: Option 'resolvePackageJsonImports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'. ==== tests/cases/conformance/moduleResolution/index.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=node).errors.txt b/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=node).errors.txt index 023c4dc8610ad..93ffdb73d1766 100644 --- a/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=node).errors.txt +++ b/tests/baselines/reference/packageJsonImportsExportsOptionCompat(moduleresolution=node).errors.txt @@ -1,8 +1,8 @@ -error TS5098: Option 'resolvePackageJsonExports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'. -error TS5098: Option 'resolvePackageJsonImports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'. +error TS5098: Option 'resolvePackageJsonExports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'. +error TS5098: Option 'resolvePackageJsonImports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'. -!!! error TS5098: Option 'resolvePackageJsonExports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'. -!!! error TS5098: Option 'resolvePackageJsonImports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'hybrid'. +!!! error TS5098: Option 'resolvePackageJsonExports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'. +!!! error TS5098: Option 'resolvePackageJsonImports' can only be used when 'moduleResolution' is set to 'node16', 'nodenext', or 'bundler'. ==== tests/cases/conformance/moduleResolution/index.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/cases/conformance/moduleResolution/hybrid/hybridImportESM.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts similarity index 88% rename from tests/cases/conformance/moduleResolution/hybrid/hybridImportESM.ts rename to tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts index fcd14153c4c16..86107d98fbcab 100644 --- a/tests/cases/conformance/moduleResolution/hybrid/hybridImportESM.ts +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerImportESM.ts @@ -1,4 +1,4 @@ -// @moduleResolution: hybrid +// @moduleResolution: bundler // @Filename: /esm.mts export const esm = 0; diff --git a/tests/cases/conformance/moduleResolution/hybrid/hybridImportTsExtensions.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerImportTsExtensions.ts similarity index 95% rename from tests/cases/conformance/moduleResolution/hybrid/hybridImportTsExtensions.ts rename to tests/cases/conformance/moduleResolution/bundler/bundlerImportTsExtensions.ts index 8cb7141e5c409..8ba4b62b7116b 100644 --- a/tests/cases/conformance/moduleResolution/hybrid/hybridImportTsExtensions.ts +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerImportTsExtensions.ts @@ -1,4 +1,4 @@ -// @moduleResolution: hybrid +// @moduleResolution: bundler // @outDir: dist // @allowJs: true // @checkJs: true diff --git a/tests/cases/conformance/moduleResolution/hybrid/hybridNodeModules1.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts similarity index 96% rename from tests/cases/conformance/moduleResolution/hybrid/hybridNodeModules1.ts rename to tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts index c1f35a255db6c..ffa7242ff3c09 100644 --- a/tests/cases/conformance/moduleResolution/hybrid/hybridNodeModules1.ts +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerNodeModules1.ts @@ -1,4 +1,4 @@ -// @moduleResolution: hybrid +// @moduleResolution: bundler // @traceResolution: true // @Filename: /node_modules/dual/package.json diff --git a/tests/cases/conformance/moduleResolution/hybrid/hybridRelative1.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts similarity index 95% rename from tests/cases/conformance/moduleResolution/hybrid/hybridRelative1.ts rename to tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts index b560bf5462709..d23292176f8d4 100644 --- a/tests/cases/conformance/moduleResolution/hybrid/hybridRelative1.ts +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerRelative1.ts @@ -1,4 +1,4 @@ -// @moduleResolution: hybrid +// @moduleResolution: bundler // @traceResolution: true // @Filename: /dir/index.ts diff --git a/tests/cases/conformance/moduleResolution/hybrid/hybridSyntaxRestrictions.ts b/tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts similarity index 93% rename from tests/cases/conformance/moduleResolution/hybrid/hybridSyntaxRestrictions.ts rename to tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts index b4b50b6b910f6..fdc7f7c77819d 100644 --- a/tests/cases/conformance/moduleResolution/hybrid/hybridSyntaxRestrictions.ts +++ b/tests/cases/conformance/moduleResolution/bundler/bundlerSyntaxRestrictions.ts @@ -1,4 +1,4 @@ -// @moduleResolution: hybrid +// @moduleResolution: bundler // @checkJs: true // @allowJs: true // @outDir: out diff --git a/tests/cases/conformance/moduleResolution/customConditions.ts b/tests/cases/conformance/moduleResolution/customConditions.ts index 1205a9860f07d..47fb048ac28bf 100644 --- a/tests/cases/conformance/moduleResolution/customConditions.ts +++ b/tests/cases/conformance/moduleResolution/customConditions.ts @@ -1,4 +1,4 @@ -// @moduleResolution: hybrid +// @moduleResolution: bundler // @customConditions: webpack, browser // @resolvePackageJsonExports: true, false // @traceResolution: true diff --git a/tests/cases/conformance/moduleResolution/extensionLoadingPriority.ts b/tests/cases/conformance/moduleResolution/extensionLoadingPriority.ts index 485d9f905d4cf..c3a06a36b52aa 100644 --- a/tests/cases/conformance/moduleResolution/extensionLoadingPriority.ts +++ b/tests/cases/conformance/moduleResolution/extensionLoadingPriority.ts @@ -1,4 +1,4 @@ -// @moduleResolution: classic,node,node16,nodenext,hybrid +// @moduleResolution: classic,node,node16,nodenext,bundler // @allowJs: true // @checkJs: true // @noEmit: true diff --git a/tests/cases/conformance/moduleResolution/packageJsonImportsExportsOptionCompat.ts b/tests/cases/conformance/moduleResolution/packageJsonImportsExportsOptionCompat.ts index db00495c4ed8d..b1bf3811d6e64 100644 --- a/tests/cases/conformance/moduleResolution/packageJsonImportsExportsOptionCompat.ts +++ b/tests/cases/conformance/moduleResolution/packageJsonImportsExportsOptionCompat.ts @@ -1,4 +1,4 @@ -// @moduleResolution: classic, node, node16, nodenext, hybrid +// @moduleResolution: classic, node, node16, nodenext, bundler // @resolvePackageJsonImports: true // @resolvePackageJsonExports: true // @noTypesAndSymbols: true diff --git a/tests/cases/fourslash/autoImportAllowTsExtensions1.ts b/tests/cases/fourslash/autoImportAllowTsExtensions1.ts index 882ab404669b9..e71867ceb67d8 100644 --- a/tests/cases/fourslash/autoImportAllowTsExtensions1.ts +++ b/tests/cases/fourslash/autoImportAllowTsExtensions1.ts @@ -1,6 +1,6 @@ /// -// @moduleResolution: hybrid +// @moduleResolution: bundler // @allowImportingTsExtensions: true // @noEmit: true diff --git a/tests/cases/fourslash/autoImportAllowTsExtensions2.ts b/tests/cases/fourslash/autoImportAllowTsExtensions2.ts index 84eda57047a35..5fd8b0730bbf0 100644 --- a/tests/cases/fourslash/autoImportAllowTsExtensions2.ts +++ b/tests/cases/fourslash/autoImportAllowTsExtensions2.ts @@ -1,6 +1,6 @@ /// -// @moduleResolution: hybrid +// @moduleResolution: bundler // @allowImportingTsExtensions: true // @noEmit: true diff --git a/tests/cases/fourslash/autoImportAllowTsExtensions3.ts b/tests/cases/fourslash/autoImportAllowTsExtensions3.ts index f46128644c6bd..d6e38bf236e1d 100644 --- a/tests/cases/fourslash/autoImportAllowTsExtensions3.ts +++ b/tests/cases/fourslash/autoImportAllowTsExtensions3.ts @@ -1,6 +1,6 @@ /// -// @moduleResolution: hybrid +// @moduleResolution: bundler // @allowImportingTsExtensions: true // @noEmit: true diff --git a/tests/cases/fourslash/autoImportAllowTsExtensions4.ts b/tests/cases/fourslash/autoImportAllowTsExtensions4.ts index bc6235658c2bc..b4f479fef5bf9 100644 --- a/tests/cases/fourslash/autoImportAllowTsExtensions4.ts +++ b/tests/cases/fourslash/autoImportAllowTsExtensions4.ts @@ -1,6 +1,6 @@ /// -// @moduleResolution: hybrid +// @moduleResolution: bundler // @allowImportingTsExtensions: true // @noEmit: true diff --git a/tests/cases/fourslash/pathCompletionsAllowTsExtensions.ts b/tests/cases/fourslash/pathCompletionsAllowTsExtensions.ts index 32b566f0839e6..b871ce1f429e4 100644 --- a/tests/cases/fourslash/pathCompletionsAllowTsExtensions.ts +++ b/tests/cases/fourslash/pathCompletionsAllowTsExtensions.ts @@ -1,6 +1,6 @@ /// -// @moduleResolution: hybrid +// @moduleResolution: bundler // @allowImportingTsExtensions: true // @noEmit: true