From 9e845d224859950fb263dec43f8fa1f7334e52da Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 5 Dec 2022 11:56:33 -0800 Subject: [PATCH] Api cleanup for Module and Type Reference directive resolution (#51546) * Refactoring so CacheWithRedirects has Key and Value type parameters * ModuleResolutionCache or TypeRefDirectiveCache will look in directory before solving, so ResolutionCache doesnt need this check * Test showing module resolution is not shared because resolution cache doesnt update own options * Enable traceResolution on some of the project reference tests * Simplify CacheWithRedirects and ensure the options are set in all common scenarios so cache can be shared between redirects * Make failedlookup etc optional in ResolvedModule/TypeRefefWithFailedLookupLocations Also make accidental public failed lookup internal * Add new API for module and type ref resolution * Store auto type reference resolutions * Modify test to show how using program partially doesnt report resolution diagnostics * Ensure that resolution diagnostics are reported in filePreocessingDiagnostics so they can be reused when program is reused * Some cleanup * Remove the newly added ReoslutionInfo in favor of new APIs * update --- src/compiler/builderState.ts | 2 +- src/compiler/checker.ts | 22 +- src/compiler/moduleNameResolver.ts | 56 +- src/compiler/program.ts | 498 +++++++++++------- src/compiler/resolutionCache.ts | 296 ++++++----- src/compiler/tsbuildPublic.ts | 48 +- src/compiler/types.ts | 69 ++- src/compiler/utilities.ts | 65 ++- src/compiler/watchPublic.ts | 58 +- src/server/project.ts | 32 +- src/server/session.ts | 6 +- src/services/findAllReferences.ts | 2 +- src/services/getEditsForFileRename.ts | 6 +- src/services/goToDefinition.ts | 6 +- src/services/importTracker.ts | 2 +- src/services/services.ts | 10 +- src/services/types.ts | 26 +- .../unittests/tscWatch/moduleResolution.ts | 13 +- .../tsserver/getEditsForFileRename.ts | 27 +- .../unittests/tsserver/symlinkCache.ts | 10 +- .../unittests/tsserver/typingsInstaller.ts | 2 +- .../reference/api/tsserverlibrary.d.ts | 45 +- tests/baselines/reference/api/typescript.d.ts | 42 +- ...seUrl-without-path-mappings-or-rootDirs.js | 60 +-- .../classic-baseUrl-path-mappings.js | 18 +- .../moduleResolution/classic-baseUrl.js | 18 +- .../moduleResolution/classic-rootDirs.js | 12 +- .../moduleResolution/nested-node-module.js | 6 +- .../node-baseUrl-path-mappings.js | 58 +- .../moduleResolution/node-baseUrl.js | 32 +- .../moduleResolution/node-rootDirs.js | 24 +- .../non-relative-module-name-as-directory.js | 8 +- ...module-name-as-file-ts-files-not-loaded.js | 8 +- .../non-relative-module-name-as-file.js | 8 +- .../non-relative-preserveSymlinks.js | 6 +- ...ive-preserves-originalPath-on-cache-hit.js | 6 +- ...-relative-uses-originalPath-for-caching.js | 10 +- ...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 | 104 +--- .../type-reference-from-primary-location.js | 22 +- .../type-reference-from-secondary-location.js | 18 +- ...-reference-overrides-secondary-location.js | 4 +- ...ive-is-relative-and-in-a-sibling-folder.js | 10 +- ...le-declarations-from-non-modified-files.js | 87 ++- ...ule-resolutions-from-non-modified-files.js | 259 ++++++--- ...ge-affects-a-single-module-of-a-package.js | 106 ++-- .../change-affects-imports.js | 34 +- .../change-affects-tripleslash-references.js | 13 +- .../change-affects-type-directives.js | 26 +- .../change-affects-type-references.js | 26 +- ...ge-does-not-affect-imports-or-type-refs.js | 26 +- .../change-doesnot-affect-type-references.js | 26 +- .../config-path-changes.js | 26 +- .../fetches-imports-after-npm-install.js | 36 +- .../missing-file-is-created.js | 26 +- .../missing-files-remain-missing.js | 26 +- .../module-kind-changes.js | 26 +- .../redirect-no-change.js | 176 +++++-- .../redirect-previous-duplicate-packages.js | 176 +++++-- .../redirect-target-changes.js | 166 ++++-- .../redirect-underlying-changes.js | 176 +++++-- ...rect-with-getSourceFileByPath-no-change.js | 176 +++++-- ...eFileByPath-previous-duplicate-packages.js | 176 +++++-- ...with-getSourceFileByPath-target-changes.js | 166 ++++-- ...-getSourceFileByPath-underlying-changes.js | 176 +++++-- .../resolution-cache-follows-imports.js | 37 +- ...irectives-cache-follows-type-directives.js | 46 +- ...-an-ambient-external-module-declaration.js | 16 +- .../reuseProgramStructure/rootdir-changes.js | 26 +- .../works-with-updated-SourceFiles.js | 16 +- .../diagnostics-from-cache.js | 101 +++- 73 files changed, 2770 insertions(+), 1438 deletions(-) diff --git a/src/compiler/builderState.ts b/src/compiler/builderState.ts index 8ae0d6295ca..ff95c66876d 100644 --- a/src/compiler/builderState.ts +++ b/src/compiler/builderState.ts @@ -233,7 +233,7 @@ export namespace BuilderState { // Handle type reference directives if (sourceFile.resolvedTypeReferenceDirectiveNames) { - sourceFile.resolvedTypeReferenceDirectiveNames.forEach((resolvedTypeReferenceDirective) => { + sourceFile.resolvedTypeReferenceDirectiveNames.forEach(({ resolvedTypeReferenceDirective }) => { if (!resolvedTypeReferenceDirective) { return; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b2347c6b994..48fcaf414fc 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1333,8 +1333,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { host.getSourceFiles().forEach(sf => { if (!sf.resolvedModules) return; - sf.resolvedModules.forEach(r => { - if (r && r.packageId) map.set(r.packageId.name, r.extension === Extension.Dts || !!map.get(r.packageId.name)); + sf.resolvedModules.forEach(({ resolvedModule }) => { + if (resolvedModule?.packageId) map.set(resolvedModule.packageId.name, resolvedModule.extension === Extension.Dts || !!map.get(resolvedModule.packageId.name)); }); }); return map; @@ -44897,15 +44897,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // this variable and functions that use it are deliberately moved here from the outer scope // to avoid scope pollution const resolvedTypeReferenceDirectives = host.getResolvedTypeReferenceDirectives(); - let fileToDirective: Map; + let fileToDirective: Map; if (resolvedTypeReferenceDirectives) { // populate reverse mapping: file path -> type reference directive that was resolved to this file - fileToDirective = new Map(); - resolvedTypeReferenceDirectives.forEach((resolvedDirective, key, mode) => { - if (!resolvedDirective || !resolvedDirective.resolvedFileName) { + fileToDirective = new Map(); + resolvedTypeReferenceDirectives.forEach(({ resolvedTypeReferenceDirective }, key, mode) => { + if (!resolvedTypeReferenceDirective?.resolvedFileName) { return; } - const file = host.getSourceFile(resolvedDirective.resolvedFileName); + const file = host.getSourceFile(resolvedTypeReferenceDirective.resolvedFileName); if (file) { // Add the transitive closure of path references loaded by this file (as long as they are not) // part of an existing type reference. @@ -45032,7 +45032,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } // defined here to avoid outer scope pollution - function getTypeReferenceDirectivesForEntityName(node: EntityNameOrEntityNameExpression): [specifier: string, mode: ResolutionMode | undefined][] | undefined { + function getTypeReferenceDirectivesForEntityName(node: EntityNameOrEntityNameExpression): [specifier: string, mode: ResolutionMode][] | undefined { // program does not have any files with type reference directives - bail out if (!fileToDirective) { return undefined; @@ -45057,13 +45057,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } // defined here to avoid outer scope pollution - function getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): [specifier: string, mode: ResolutionMode | undefined][] | undefined { + function getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): [specifier: string, mode: ResolutionMode][] | undefined { // program does not have any files with type reference directives - bail out if (!fileToDirective || !isSymbolFromTypeDeclarationFile(symbol)) { return undefined; } // check what declarations in the symbol can contribute to the target meaning - let typeReferenceDirectives: [specifier: string, mode: ResolutionMode | undefined][] | undefined; + let typeReferenceDirectives: [specifier: string, mode: ResolutionMode][] | undefined; for (const decl of symbol.declarations!) { // check meaning of the local symbol to see if declaration needs to be analyzed further if (decl.symbol && decl.symbol.flags & meaning!) { @@ -45114,7 +45114,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return false; } - function addReferencedFilesToTypeDirective(file: SourceFile, key: string, mode: ResolutionMode | undefined) { + function addReferencedFilesToTypeDirective(file: SourceFile, key: string, mode: ResolutionMode) { if (fileToDirective.has(file.path)) return; fileToDirective.set(file.path, [key, mode]); for (const { fileName, resolutionMode } of file.referencedFiles) { diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index b400bc23ba1..ee02f47f17a 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -27,7 +27,6 @@ import { extensionIsTS, fileExtensionIs, fileExtensionIsOneOf, - FileReference, filter, firstDefined, forEach, @@ -41,7 +40,6 @@ import { GetEffectiveTypeRootsHost, getEmitModuleKind, getEmitModuleResolutionKind, - getModeForUsageLocation, getNormalizedAbsolutePath, getOwnKeys, getPathComponents, @@ -58,7 +56,6 @@ import { isExternalModuleNameRelative, isRootedDiskPath, isString, - isStringLiteralLike, lastOrUndefined, length, MapLike, @@ -86,6 +83,7 @@ import { removeFileExtension, removePrefix, ResolutionMode, + ResolutionNameAndModeGetter, ResolvedModuleWithFailedLookupLocations, ResolvedProjectReference, ResolvedTypeReferenceDirective, @@ -95,10 +93,8 @@ import { SourceFile, startsWith, stringContains, - StringLiteralLike, supportedDeclarationExtensions, supportedTSImplementationExtensions, - toFileNameLowerCase, toPath, tryExtractTSExtension, tryGetExtensionFromPath, @@ -213,17 +209,28 @@ function createResolvedModuleWithFailedLookupLocations( resultFromCache: ResolvedModuleWithFailedLookupLocations | undefined ): ResolvedModuleWithFailedLookupLocations { if (resultFromCache) { - resultFromCache.failedLookupLocations.push(...failedLookupLocations); - resultFromCache.affectingLocations.push(...affectingLocations); + resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations); + resultFromCache.affectingLocations = updateResolutionField(resultFromCache.affectingLocations, affectingLocations); + resultFromCache.resolutionDiagnostics = updateResolutionField(resultFromCache.resolutionDiagnostics, diagnostics); return resultFromCache; } return { resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport, packageId: resolved.packageId }, - failedLookupLocations, - affectingLocations, - resolutionDiagnostics: diagnostics, + failedLookupLocations: initializeResolutionField(failedLookupLocations), + affectingLocations: initializeResolutionField(affectingLocations), + resolutionDiagnostics: initializeResolutionField(diagnostics), }; } +function initializeResolutionField(value: T[]): T[] | undefined { + return value.length ? value : undefined; +} +/** @internal */ +export function updateResolutionField(to: T[] | undefined, value: T[] | undefined) { + if (!value?.length) return to; + if (!to?.length) return value; + to.push(...value); + return to; +} /** @internal */ export interface ModuleResolutionState { @@ -524,7 +531,12 @@ export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string isExternalLibraryImport: pathContainsNodeModules(fileName), }; } - result = { resolvedTypeReferenceDirective, failedLookupLocations, affectingLocations, resolutionDiagnostics: diagnostics }; + result = { + resolvedTypeReferenceDirective, + failedLookupLocations: initializeResolutionField(failedLookupLocations), + affectingLocations: initializeResolutionField(affectingLocations), + resolutionDiagnostics: initializeResolutionField(diagnostics), + }; perFolderCache?.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result); if (traceEnabled) traceResult(result); return result; @@ -911,23 +923,17 @@ export function createModeAwareCache(): ModeAwareCache { } /** @internal */ -export function getResolutionName(entry: string | FileReference | StringLiteralLike) { - // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. - return !isString(entry) ? isStringLiteralLike(entry) ? entry.text : toFileNameLowerCase(entry.fileName) : entry; -} - -/** @internal */ -export function getResolutionMode(entry: FileReference | StringLiteralLike, file: SourceFile) { - return isStringLiteralLike(entry) ? getModeForUsageLocation(file, entry) : entry.resolutionMode || file.impliedNodeFormat; -} - -/** @internal */ -export function zipToModeAwareCache(file: SourceFile, keys: readonly StringLiteralLike[] | readonly FileReference[], values: readonly V[]): ModeAwareCache { +export function zipToModeAwareCache( + file: SourceFile, + keys: readonly K[], + values: readonly V[], + nameAndModeGetter: ResolutionNameAndModeGetter, +): ModeAwareCache { Debug.assert(keys.length === values.length); const map = createModeAwareCache(); for (let i = 0; i < keys.length; ++i) { const entry = keys[i]; - map.set(getResolutionName(entry), getResolutionMode(entry, file), values[i]); + map.set(nameAndModeGetter.getName(entry), nameAndModeGetter.getMode(entry, file), values[i]); } return map; } @@ -1373,7 +1379,7 @@ function tryLoadModuleUsingBaseUrl(extensions: Extensions, moduleName: string, l export function resolveJSModule(moduleName: string, initialDir: string, host: ModuleResolutionHost): string { const { resolvedModule, failedLookupLocations } = tryResolveJSModuleWorker(moduleName, initialDir, host); if (!resolvedModule) { - throw new Error(`Could not resolve JS module '${moduleName}' starting at '${initialDir}'. Looked in: ${failedLookupLocations.join(", ")}`); + throw new Error(`Could not resolve JS module '${moduleName}' starting at '${initialDir}'. Looked in: ${failedLookupLocations?.join(", ")}`); } return resolvedModule.resolvedFileName; } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 3f30a3a33a3..ea600b28df7 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -15,7 +15,6 @@ import { changeExtension, changesAffectingProgramStructure, changesAffectModuleResolution, - clone, combinePaths, CommentDirective, CommentDirectivesMap, @@ -42,6 +41,7 @@ import { createGetCanonicalFileName, createInputFilesWithFilePaths, createModeAwareCache, + createModeAwareCacheKey, createModuleResolutionCache, createMultiMap, CreateProgramOptions, @@ -131,10 +131,7 @@ import { getPositionOfLineAndCharacter, getPropertyArrayElementValue, getPropertyAssignment, - getResolutionMode, - getResolutionName, getResolvedModule, - getResolvedTypeReferenceDirective, getRootLength, getSetExternalModuleIndicator, getSpellingSuggestion, @@ -207,6 +204,8 @@ import { maybeBind, memoize, MethodDeclaration, + ModeAwareCache, + ModeAwareCacheKey, ModifierFlags, ModifierLike, ModuleBlock, @@ -214,7 +213,6 @@ import { ModuleKind, ModuleResolutionCache, ModuleResolutionHost, - ModuleResolutionInfo, moduleResolutionIsEqualTo, ModuleResolutionKind, Mutable, @@ -261,9 +259,8 @@ import { ResolvedModuleFull, ResolvedModuleWithFailedLookupLocations, ResolvedProjectReference, - ResolvedTypeReferenceDirective, + ResolvedTypeReferenceDirectiveWithFailedLookupLocations, resolveModuleName, - resolveModuleNameFromCache, resolveTypeReferenceDirective, returnFalse, returnUndefined, @@ -304,7 +301,6 @@ import { TypeChecker, typeDirectiveIsEqualTo, TypeReferenceDirectiveResolutionCache, - TypeReferenceDirectiveResolutionInfo, UnparsedSource, VariableDeclaration, VariableStatement, @@ -808,28 +804,6 @@ export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageCha return result; } -/** @internal */ -export function loadWithTypeDirectiveCache(names: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, containingFileMode: ResolutionMode, loader: (name: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined, resolutionMode: ResolutionMode) => T): T[] { - if (names.length === 0) { - return []; - } - const resolutions: T[] = []; - const cache = createModeAwareCache(); - for (const name of names) { - let result: T; - const mode = getModeForFileReference(name, containingFileMode); - const strName = getResolutionName(name); - if (cache.has(strName, mode)) { - result = cache.get(strName, mode)!; - } - else { - cache.set(strName, mode, result = loader(strName, containingFile, redirectedReference, mode)); - } - resolutions.push(result); - } - return resolutions; -} - /** * Subset of a SourceFile used to calculate index-based resolutions * This includes some internal fields, so unless you have very good reason, @@ -937,26 +911,117 @@ export function getResolutionModeOverrideForClause(clause: AssertClause | undefi return elem.value.text === "import" ? ModuleKind.ESNext : ModuleKind.CommonJS; } +const emptyResolution: ResolvedModuleWithFailedLookupLocations & ResolvedTypeReferenceDirectiveWithFailedLookupLocations = { + resolvedModule: undefined, + resolvedTypeReferenceDirective: undefined, +}; + /** @internal */ -export function loadWithModeAwareCache(names: readonly StringLiteralLike[] | readonly string[], containingFile: SourceFile, containingFileName: string, redirectedReference: ResolvedProjectReference | undefined, resolutionInfo: ModuleResolutionInfo | undefined, loader: (name: string, resolverMode: ResolutionMode, containingFileName: string, redirectedReference: ResolvedProjectReference | undefined) => T): T[] { - if (names.length === 0) { - return []; - } - const resolutions: T[] = []; - const cache = createModeAwareCache(); - let i = 0; - for (const entry of resolutionInfo ? resolutionInfo.names : names) { - let result: T; - const mode = !isString(entry) ? - getModeForUsageLocation(containingFile, entry) : - getModeForResolutionAtIndex(containingFile, i); - i++; - const name = isString(entry) ? entry : entry.text; - if (cache.has(name, mode)) { - result = cache.get(name, mode)!; - } - else { - cache.set(name, mode, result = loader(name, mode, containingFileName, redirectedReference)); +export interface ResolutionNameAndModeGetter { + getName(entry: Entry): string; + getMode(entry: Entry, file: SourceFile): ResolutionMode; +} + + +/** @internal */ +export interface ResolutionLoader { + nameAndMode: ResolutionNameAndModeGetter; + resolve(name: string, mode: ResolutionMode): Resolution; +} + +function getModuleResolutionName(literal: StringLiteralLike) { + return literal.text; +} + +/** @internal */ +export const moduleResolutionNameAndModeGetter: ResolutionNameAndModeGetter = { + getName: getModuleResolutionName, + getMode: (entry, file) => getModeForUsageLocation(file, entry), +}; + +/** @internal */ +export function createModuleResolutionLoader( + containingFile: string, + redirectedReference: ResolvedProjectReference | undefined, + options: CompilerOptions, + host: ModuleResolutionHost, + cache: ModuleResolutionCache | undefined, +): ResolutionLoader { + return { + nameAndMode: moduleResolutionNameAndModeGetter, + resolve: (moduleName, resoluionMode) => resolveModuleName( + moduleName, + containingFile, + options, + host, + cache, + redirectedReference, + resoluionMode, + ), + }; +} + +function getTypeReferenceResolutionName(entry: T) { + // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. + return !isString(entry) ? toFileNameLowerCase(entry.fileName) : entry; +} + +/** @internal */ +export const typeReferenceResolutionNameAndModeGetter: ResolutionNameAndModeGetter = { + getName: getTypeReferenceResolutionName, + getMode: (entry, file) => getModeForFileReference(entry, file?.impliedNodeFormat), +}; + +/** @internal */ +export function createTypeReferenceResolutionLoader( + containingFile: string, + redirectedReference: ResolvedProjectReference | undefined, + options: CompilerOptions, + host: ModuleResolutionHost, + cache: TypeReferenceDirectiveResolutionCache | undefined, +): ResolutionLoader { + return { + nameAndMode: typeReferenceResolutionNameAndModeGetter, + resolve: (typeRef, resoluionMode) => resolveTypeReferenceDirective( + typeRef, + containingFile, + options, + host, + redirectedReference, + cache, + resoluionMode, + ), + }; +} + +/** @internal */ +export function loadWithModeAwareCache( + entries: readonly Entry[], + containingFile: string, + redirectedReference: ResolvedProjectReference | undefined, + options: CompilerOptions, + containingSourceFile: SourceFile, + host: ModuleResolutionHost, + resolutionCache: ResolutionCache | undefined, + createLoader: ( + containingFile: string, + redirectedReference: ResolvedProjectReference | undefined, + options: CompilerOptions, + host: ModuleResolutionHost, + resolutionCache: ResolutionCache | undefined, + ) => ResolutionLoader, +): readonly Resolution[] { + if (entries.length === 0) return emptyArray; + const resolutions: Resolution[] = []; + const cache = new Map(); + const loader = createLoader(containingFile, redirectedReference, options, host, resolutionCache); + for (const entry of entries) { + const name = loader.nameAndMode.getName(entry); + const mode = loader.nameAndMode.getMode(entry, containingSourceFile); + const key = createModeAwareCacheKey(name, mode); + let result = cache.get(key); + if (!result) { + cache.set(key, result = loader.resolve(name, mode)); } resolutions.push(result); } @@ -1057,7 +1122,7 @@ export function getReferencedFileLocation(getSourceFileByPath: (path: Path) => S switch (kind) { case FileIncludeKind.Import: const importLiteral = getModuleNameStringLiteralAt(file, index); - packageId = file.resolvedModules?.get(importLiteral.text, getModeForResolutionAtIndex(file, index))?.packageId; + packageId = file.resolvedModules?.get(importLiteral.text, getModeForResolutionAtIndex(file, index))?.resolvedModule?.packageId; if (importLiteral.pos === -1) return { file, packageId, text: importLiteral.text }; pos = skipTrivia(file.text, importLiteral.pos); end = importLiteral.end; @@ -1067,7 +1132,7 @@ export function getReferencedFileLocation(getSourceFileByPath: (path: Path) => S break; case FileIncludeKind.TypeReferenceDirective: ({ pos, end, resolutionMode } = file.typeReferenceDirectives[index]); - packageId = file.resolvedTypeReferenceDirectiveNames?.get(toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), resolutionMode || file.impliedNodeFormat)?.packageId; + packageId = file.resolvedTypeReferenceDirectiveNames?.get(toFileNameLowerCase(file.typeReferenceDirectives[index].fileName), resolutionMode || file.impliedNodeFormat)?.resolvedTypeReferenceDirective?.packageId; break; case FileIncludeKind.LibReferenceDirective: ({ pos, end } = file.libReferenceDirectives[index]); @@ -1376,8 +1441,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg const cachedBindAndCheckDiagnosticsForFile: DiagnosticCache = {}; const cachedDeclarationDiagnosticsForFile: DiagnosticCache = {}; - let resolvedTypeReferenceDirectives = createModeAwareCache(); + let resolvedTypeReferenceDirectives = createModeAwareCache(); let fileProcessingDiagnostics: FilePreprocessingDiagnostics[] | undefined; + let automaticTypeDirectiveNames: string[] | undefined; + let automaticTypeDirectiveResolutions: ModeAwareCache; // The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules. // This works as imported modules are discovered recursively in a depth first manner, specifically: @@ -1405,6 +1472,11 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg let skipDefaultLib = options.noLib; const getDefaultLibraryFileName = memoize(() => host.getDefaultLibFileName(options)); const defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : getDirectoryPath(getDefaultLibraryFileName()); + /** + * Diagnostics for the program + * Only add diagnostics directly if it always would be done irrespective of program structure reuse. + * Otherwise fileProcessingDiagnostics is correct locations so that the diagnostics can be reported in all structure use scenarios + */ const programDiagnostics = createDiagnosticCollection(); const currentDirectory = host.getCurrentDirectory(); const supportedExtensions = getSupportedExtensions(options); @@ -1415,67 +1487,86 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg let _compilerOptionsObjectLiteralSyntax: ObjectLiteralExpression | false | undefined; let moduleResolutionCache: ModuleResolutionCache | undefined; - let typeReferenceDirectiveResolutionCache: TypeReferenceDirectiveResolutionCache | undefined; let actualResolveModuleNamesWorker: ( moduleNames: readonly StringLiteralLike[], - containingFile: SourceFile, - containingFileName: string, + containingFile: string, redirectedReference: ResolvedProjectReference | undefined, - resolutionInfo: ModuleResolutionInfo | undefined, - ) => (ResolvedModuleFull | undefined)[]; + options: CompilerOptions, + containingSourceFile: SourceFile, + reusedNames: readonly StringLiteralLike[] | undefined, + ) => readonly ResolvedModuleWithFailedLookupLocations[]; const hasInvalidatedResolutions = host.hasInvalidatedResolutions || returnFalse; - if (host.resolveModuleNames) { - actualResolveModuleNamesWorker = (moduleNames, containingFile, containingFileName, redirectedReference, resolutionInfo) => + if (host.resolveModuleNameLiterals) { + actualResolveModuleNamesWorker = host.resolveModuleNameLiterals.bind(host); + moduleResolutionCache = host.getModuleResolutionCache?.(); + } + else if (host.resolveModuleNames) { + actualResolveModuleNamesWorker = (moduleNames, containingFile, redirectedReference, options, containingSourceFile, reusedNames) => host.resolveModuleNames!( - moduleNames.map(literal => literal.text), - containingFileName, - resolutionInfo?.reusedNames?.map(literal => literal.text), + moduleNames.map(getModuleResolutionName), + containingFile, + reusedNames?.map(getModuleResolutionName), redirectedReference, options, - containingFile, - resolutionInfo, - ).map(resolved => { - // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. - if (!resolved || (resolved as ResolvedModuleFull).extension !== undefined) { - return resolved as ResolvedModuleFull; - } - const withExtension = clone(resolved) as ResolvedModuleFull; - withExtension.extension = extensionFromPath(resolved.resolvedFileName); - return withExtension; - }); + containingSourceFile, + ).map(resolved => resolved ? + ((resolved as ResolvedModuleFull).extension !== undefined) ? + { resolvedModule: resolved as ResolvedModuleFull } : + // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. + { resolvedModule: { ...resolved, extension: extensionFromPath(resolved.resolvedFileName) } } : + emptyResolution + ); moduleResolutionCache = host.getModuleResolutionCache?.(); } else { moduleResolutionCache = createModuleResolutionCache(currentDirectory, getCanonicalFileName, options); - const loader = (moduleName: string, resolverMode: ResolutionMode, containingFileName: string, redirectedReference: ResolvedProjectReference | undefined) => - resolveModuleName(moduleName, containingFileName, options, host, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; - actualResolveModuleNamesWorker = (moduleNames, containingFile, containingFileName, redirectedReference, resolutionInfo) => - loadWithModeAwareCache(moduleNames, containingFile, containingFileName, redirectedReference, resolutionInfo, loader); + actualResolveModuleNamesWorker = (moduleNames, containingFile, redirectedReference, options, containingSourceFile) => + loadWithModeAwareCache( + moduleNames, + containingFile, + redirectedReference, + options, + containingSourceFile, + host, + moduleResolutionCache, + createModuleResolutionLoader, + ); } - let actualResolveTypeReferenceDirectiveNamesWorker: ( - typeDirectiveNames: string[] | readonly FileReference[], + let actualResolveTypeReferenceDirectiveNamesWorker: ( + typeDirectiveNames: T[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, - containingFileMode: ResolutionMode | undefined, - resolutionInfo: TypeReferenceDirectiveResolutionInfo | undefined, - ) => (ResolvedTypeReferenceDirective | undefined)[]; - if (host.resolveTypeReferenceDirectives) { - actualResolveTypeReferenceDirectiveNamesWorker = (typeDirectiveNames, containingFile, redirectedReference, containingFileMode, resolutionInfo) => - host.resolveTypeReferenceDirectives!(Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options, containingFileMode, resolutionInfo); + options: CompilerOptions, + containingSourceFile: SourceFile | undefined, + reusedNames: readonly T[] | undefined, + ) => readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[]; + if (host.resolveTypeReferenceDirectiveReferences) { + actualResolveTypeReferenceDirectiveNamesWorker = host.resolveTypeReferenceDirectiveReferences.bind(host); + } + else if (host.resolveTypeReferenceDirectives) { + actualResolveTypeReferenceDirectiveNamesWorker = (typeDirectiveNames, containingFile, redirectedReference, options, containingSourceFile) => + host.resolveTypeReferenceDirectives!( + typeDirectiveNames.map(getTypeReferenceResolutionName), + containingFile, + redirectedReference, + options, + containingSourceFile?.impliedNodeFormat, + ).map(resolvedTypeReferenceDirective => ({ resolvedTypeReferenceDirective })); } else { - typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache?.getPackageJsonInfoCache()); - const loader = (typesRef: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined, resolutionMode: ResolutionMode | undefined) => resolveTypeReferenceDirective( - typesRef, - containingFile, - options, - host, - redirectedReference, - typeReferenceDirectiveResolutionCache, - resolutionMode, - ).resolvedTypeReferenceDirective!; // TODO: GH#18217 - actualResolveTypeReferenceDirectiveNamesWorker = (typeReferenceDirectiveNames, containingFile, redirectedReference, containingFileMode) => loadWithTypeDirectiveCache(Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader); + const typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache?.getPackageJsonInfoCache()); + actualResolveTypeReferenceDirectiveNamesWorker = (typeDirectiveNames, containingFile, redirectedReference, options, containingSourceFile) => + loadWithModeAwareCache( + typeDirectiveNames, + containingFile, + redirectedReference, + options, + containingSourceFile, + host, + typeReferenceDirectiveResolutionCache, + createTypeReferenceResolutionLoader, + ); } // Map from a stringified PackageId to the source file with that id. @@ -1569,17 +1660,27 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg tracing?.pop(); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders - const typeReferences: string[] = rootNames.length ? getAutomaticTypeDirectiveNames(options, host) : emptyArray; - - if (typeReferences.length) { - tracing?.push(tracing.Phase.Program, "processTypeReferences", { count: typeReferences.length }); + automaticTypeDirectiveNames ??= rootNames.length ? getAutomaticTypeDirectiveNames(options, host) : emptyArray; + automaticTypeDirectiveResolutions = createModeAwareCache(); + if (automaticTypeDirectiveNames.length) { + tracing?.push(tracing.Phase.Program, "processTypeReferences", { count: automaticTypeDirectiveNames.length }); // This containingFilename needs to match with the one used in managed-side const containingDirectory = options.configFilePath ? getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); const containingFilename = combinePaths(containingDirectory, inferredTypesContainingFile); - const resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typeReferences, containingFilename); - for (let i = 0; i < typeReferences.length; i++) { + const resolutions = resolveTypeReferenceDirectiveNamesReusingOldState(automaticTypeDirectiveNames, containingFilename); + for (let i = 0; i < automaticTypeDirectiveNames.length; i++) { // under node16/nodenext module resolution, load `types`/ata include names as cjs resolution results by passing an `undefined` mode - processTypeReferenceDirective(typeReferences[i], /*mode*/ undefined, resolutions[i], { kind: FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: resolutions[i]?.packageId }); + automaticTypeDirectiveResolutions.set(automaticTypeDirectiveNames[i], /*mode*/ undefined, resolutions[i]); + processTypeReferenceDirective( + automaticTypeDirectiveNames[i], + /*mode*/ undefined, + resolutions[i], + { + kind: FileIncludeKind.AutomaticTypeDirectiveFile, + typeReference: automaticTypeDirectiveNames[i], + packageId: resolutions[i]?.resolvedTypeReferenceDirective?.packageId, + }, + ); } tracing?.pop(); } @@ -1646,8 +1747,6 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg ); } - typeReferenceDirectiveResolutionCache = undefined; - // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; @@ -1682,6 +1781,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg getRelationCacheSizes: () => getTypeChecker().getRelationCacheSizes(), getFileProcessingDiagnostics: () => fileProcessingDiagnostics, getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives, + getAutomaticTypeDirectiveNames: () => automaticTypeDirectiveNames!, + getAutomaticTypeDirectiveResolutions: () => automaticTypeDirectiveResolutions, isSourceFileFromExternalLibrary, isSourceFileDefaultLibrary, getSourceFileFromReference, @@ -1691,7 +1792,6 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg usesUriStyleNodeCoreModules, isEmittedFile, getConfigFileParsingDiagnostics, - getResolvedModuleWithFailedLookupLocationsFromCache, getProjectReferences, getResolvedProjectReferences, getProjectReferenceRedirect, @@ -1721,6 +1821,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg case FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic: const { file, pos, end } = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason) as ReferenceFileLocation; return programDiagnostics.add(createFileDiagnostic(file, Debug.checkDefined(pos), Debug.checkDefined(end) - pos, diagnostic.diagnostic, ...diagnostic.args || emptyArray)); + case FilePreprocessingDiagnosticsKind.ResolutionDiagnostics: + return diagnostic.diagnostics.forEach(d => programDiagnostics.add(d)); default: Debug.assertNever(diagnostic); } @@ -1733,55 +1835,51 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg return program; - function addResolutionDiagnostics(list: Diagnostic[] | undefined) { - if (!list) return; - for (const elem of list) { - programDiagnostics.add(elem); - } + function addResolutionDiagnostics(resolution: ResolvedModuleWithFailedLookupLocations | ResolvedTypeReferenceDirectiveWithFailedLookupLocations) { + if (!resolution.resolutionDiagnostics?.length) return; + (fileProcessingDiagnostics ??= []).push({ + kind: FilePreprocessingDiagnosticsKind.ResolutionDiagnostics, + diagnostics: resolution.resolutionDiagnostics + }); } - function pullDiagnosticsFromCache(names: readonly StringLiteralLike[] | readonly FileReference[], containingFile: SourceFile) { - if (!moduleResolutionCache) return; + function addResolutionDiagnosticsFromResolutionOrCache(containingFile: SourceFile, name: string, resolution: ResolvedModuleWithFailedLookupLocations, mode: ResolutionMode) { + // diagnostics directly from the resolution + if (host.resolveModuleNameLiterals || !host.resolveModuleNames) return addResolutionDiagnostics(resolution); + if (!moduleResolutionCache || isExternalModuleNameRelative(name)) return; const containingFileName = getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); const containingDir = getDirectoryPath(containingFileName); const redirectedReference = getRedirectReferenceForResolution(containingFile); - for (const n of names) { - // mimics logic done in the resolution cache, should be resilient to upgrading it to use `FileReference`s for non-type-reference modal lookups to make it rely on the index in the list less - const mode = getResolutionMode(n, containingFile); - const name = getResolutionName(n); - // only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics - // (Since diagnostics are only issued via import or export map lookup) - // This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context - // When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache - // APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way - if (isExternalModuleNameRelative(name)) continue; - const diags = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)?.resolutionDiagnostics; - addResolutionDiagnostics(diags); - } + // only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics + // (Since diagnostics are only issued via import or export map lookup) + // This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context + // When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache + // APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way + const fromCache = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir); + if (fromCache) addResolutionDiagnostics(fromCache); } - function resolveModuleNamesWorker(moduleNames: readonly StringLiteralLike[], containingFile: SourceFile, resolutionInfo: ModuleResolutionInfo | undefined): readonly (ResolvedModuleFull | undefined)[] { + function resolveModuleNamesWorker(moduleNames: readonly StringLiteralLike[], containingFile: SourceFile, reusedNames: readonly StringLiteralLike[] | undefined): readonly ResolvedModuleWithFailedLookupLocations[] { if (!moduleNames.length) return emptyArray; const containingFileName = getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); const redirectedReference = getRedirectReferenceForResolution(containingFile); tracing?.push(tracing.Phase.Program, "resolveModuleNamesWorker", { containingFileName }); performance.mark("beforeResolveModule"); - const result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, redirectedReference, resolutionInfo); + const result = actualResolveModuleNamesWorker(moduleNames, containingFileName, redirectedReference, options, containingFile, reusedNames); performance.mark("afterResolveModule"); performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); tracing?.pop(); - pullDiagnosticsFromCache(moduleNames, containingFile); return result; } - function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames: string[] | readonly FileReference[], containingFile: string | SourceFile, resolutionInfo: TypeReferenceDirectiveResolutionInfo | undefined): readonly (ResolvedTypeReferenceDirective | undefined)[] { + function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames: T[], containingFile: string | SourceFile, reusedNames: readonly T[] | undefined): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[] { if (!typeDirectiveNames.length) return []; + const containingSourceFile = !isString(containingFile) ? containingFile : undefined; const containingFileName = !isString(containingFile) ? getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; - const redirectedReference = !isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; - const containingFileMode = !isString(containingFile) ? containingFile.impliedNodeFormat : undefined; + const redirectedReference = containingSourceFile && getRedirectReferenceForResolution(containingSourceFile); tracing?.push(tracing.Phase.Program, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName }); performance.mark("beforeResolveTypeReference"); - const result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode, resolutionInfo); + const result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, options, containingSourceFile, reusedNames); performance.mark("afterResolveTypeReference"); performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference"); tracing?.pop(); @@ -1833,10 +1931,6 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg return libs.length + 2; } - function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string, mode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations | undefined { - return moduleResolutionCache && resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache, mode); - } - function toPath(fileName: string): Path { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); } @@ -1869,11 +1963,11 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg return classifiableNames; } - function resolveModuleNamesReusingOldState(moduleNames: readonly StringLiteralLike[], file: SourceFile): readonly (ResolvedModuleFull | undefined)[] { + function resolveModuleNamesReusingOldState(moduleNames: readonly StringLiteralLike[], file: SourceFile): readonly ResolvedModuleWithFailedLookupLocations[] { if (structureIsReused === StructureIsReused.Not && !file.ambientModuleNames.length) { // If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules, // the best we can do is fallback to the default logic. - return resolveModuleNamesWorker(moduleNames, file, /*resolutionInfo*/ undefined); + return resolveModuleNamesWorker(moduleNames, file, /*reusedNames*/ undefined); } const oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName); @@ -1886,9 +1980,9 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg // which per above occurred during the current program creation. // Since we assume the filesystem does not change during program creation, // it is safe to reuse resolutions from the earlier call. - const result: (ResolvedModuleFull | undefined)[] = []; + const result: ResolvedModuleWithFailedLookupLocations[] = []; for (const moduleName of moduleNames) { - const resolvedModule = file.resolvedModules.get(moduleName.text, getModeForUsageLocation(file, moduleName)); + const resolvedModule = file.resolvedModules.get(moduleName.text, getModeForUsageLocation(file, moduleName))!; result.push(resolvedModule); } return result; @@ -1909,30 +2003,30 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg * Needs to be reset to undefined before returning, * * ResolvedModuleFull instance: can be reused. */ - let result: (ResolvedModuleFull | undefined)[] | undefined; + let result: ResolvedModuleWithFailedLookupLocations[] | undefined; let reusedNames: StringLiteralLike[] | undefined; /** A transient placeholder used to mark predicted resolution in the result list. */ - const predictedToResolveToAmbientModuleMarker: ResolvedModuleFull = {} as any; + const predictedToResolveToAmbientModuleMarker: ResolvedModuleWithFailedLookupLocations = emptyResolution; for (let i = 0; i < moduleNames.length; i++) { const moduleName = moduleNames[i]; // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions if (file === oldSourceFile && !hasInvalidatedResolutions(oldSourceFile.path)) { const mode = getModeForUsageLocation(file, moduleName); - const oldResolvedModule = getResolvedModule(oldSourceFile, moduleName.text, mode); - if (oldResolvedModule) { + const oldResolution = oldSourceFile.resolvedModules?.get(moduleName.text, mode); + if (oldResolution?.resolvedModule) { if (isTraceEnabled(options, host)) { trace(host, - oldResolvedModule.packageId ? + oldResolution.resolvedModule.packageId ? Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2, moduleName.text, getNormalizedAbsolutePath(file.originalFileName, currentDirectory), - oldResolvedModule.resolvedFileName, - oldResolvedModule.packageId && packageIdToString(oldResolvedModule.packageId) + oldResolution.resolvedModule.resolvedFileName, + oldResolution.resolvedModule.packageId && packageIdToString(oldResolution.resolvedModule.packageId) ); } - (result ??= new Array(moduleNames.length))[i] = oldResolvedModule; + (result ??= new Array(moduleNames.length))[i] = oldResolution; (reusedNames ??= []).push(moduleName); continue; } @@ -1962,7 +2056,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg } const resolutions = unknownModuleNames && unknownModuleNames.length - ? resolveModuleNamesWorker(unknownModuleNames, file, { names: unknownModuleNames, reusedNames }) + ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames) : emptyArray; // Combine results of resolutions and predicted results @@ -1974,14 +2068,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg let j = 0; for (let i = 0; i < result.length; i++) { - if (result[i]) { - // `result[i]` is either a `ResolvedModuleFull` or a marker. - // If it is the former, we can leave it as is. - if (result[i] === predictedToResolveToAmbientModuleMarker) { - result[i] = undefined; - } - } - else { + if (!result[i]) { result[i] = resolutions[j]; j++; } @@ -2017,13 +2104,13 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg } } - function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames: readonly FileReference[], containingFile: SourceFile): readonly (ResolvedTypeReferenceDirective | undefined)[]; - function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames: string[], containingFile: string): readonly (ResolvedTypeReferenceDirective | undefined)[]; - function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames: string[] | readonly FileReference[], containingFile: string | SourceFile): readonly (ResolvedTypeReferenceDirective | undefined)[] { + function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames: readonly FileReference[], containingFile: SourceFile): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[]; + function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames: string[], containingFile: string): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[]; + function resolveTypeReferenceDirectiveNamesReusingOldState(typeDirectiveNames: T[], containingFile: string | SourceFile): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[] { if (structureIsReused === StructureIsReused.Not) { // If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules, // the best we can do is fallback to the default logic. - return resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, /*resolutionInfo*/ undefined); + return resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, /*resuedNames*/ undefined); } const oldSourceFile = !isString(containingFile) ? oldProgram && oldProgram.getSourceFile(containingFile.fileName) : undefined; @@ -2037,10 +2124,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg // which per above occurred during the current program creation. // Since we assume the filesystem does not change during program creation, // it is safe to reuse resolutions from the earlier call. - const result: (ResolvedTypeReferenceDirective | undefined)[] = []; + const result: ResolvedTypeReferenceDirectiveWithFailedLookupLocations[] = []; for (const typeDirectiveName of typeDirectiveNames as readonly FileReference[]) { // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. - const resolvedTypeReferenceDirective = containingFile.resolvedTypeReferenceDirectiveNames.get(getResolutionName(typeDirectiveName), typeDirectiveName.resolutionMode || containingFile.impliedNodeFormat); + const resolvedTypeReferenceDirective = containingFile.resolvedTypeReferenceDirectiveNames.get(getTypeReferenceResolutionName(typeDirectiveName), getModeForFileReference(typeDirectiveName, containingFile.impliedNodeFormat))!; result.push(resolvedTypeReferenceDirective); } return result; @@ -2048,9 +2135,9 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg } /** An ordered list of module names for which we cannot recover the resolution. */ - let unknownTypeReferenceDirectiveNames: string[] | FileReference[] | undefined; - let result: (ResolvedTypeReferenceDirective | undefined)[] | undefined; - let reusedNames: (string | FileReference)[] | undefined; + let unknownTypeReferenceDirectiveNames: T[] | undefined; + let result: ResolvedTypeReferenceDirectiveWithFailedLookupLocations[] | undefined; + let reusedNames: T[] | undefined; const containingSourceFile = !isString(containingFile) ? containingFile : undefined; const canReuseResolutions = !isString(containingFile) ? containingFile === oldSourceFile && !hasInvalidatedResolutions(oldSourceFile.path) : @@ -2058,35 +2145,35 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg for (let i = 0; i < typeDirectiveNames.length; i++) { const entry = typeDirectiveNames[i]; if (canReuseResolutions) { - const typeDirectiveName = getResolutionName(entry); + const typeDirectiveName = getTypeReferenceResolutionName(entry); const mode = getModeForFileReference(entry, containingSourceFile?.impliedNodeFormat); - const oldResolvedTypeReferenceDirective = getResolvedTypeReferenceDirective(oldSourceFile, typeDirectiveName, mode); - if (oldResolvedTypeReferenceDirective) { + const oldResolution = (!isString(containingFile) ? oldSourceFile?.resolvedTypeReferenceDirectiveNames : oldProgram?.getAutomaticTypeDirectiveResolutions())?.get(typeDirectiveName, mode); + if (oldResolution?.resolvedTypeReferenceDirective) { if (isTraceEnabled(options, host)) { trace(host, - oldResolvedTypeReferenceDirective.packageId ? + oldResolution.resolvedTypeReferenceDirective.packageId ? Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : Diagnostics.Reusing_resolution_of_type_reference_directive_0_from_1_of_old_program_it_was_successfully_resolved_to_2, typeDirectiveName, !isString(containingFile) ? getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile, - oldResolvedTypeReferenceDirective.resolvedFileName, - oldResolvedTypeReferenceDirective.packageId && packageIdToString(oldResolvedTypeReferenceDirective.packageId) + oldResolution.resolvedTypeReferenceDirective.resolvedFileName, + oldResolution.resolvedTypeReferenceDirective.packageId && packageIdToString(oldResolution.resolvedTypeReferenceDirective.packageId) ); } - (result ??= new Array(typeDirectiveNames.length))[i] = oldResolvedTypeReferenceDirective; + (result ??= new Array(typeDirectiveNames.length))[i] = oldResolution; (reusedNames ??= []).push(entry); continue; } } // Resolution failed in the old program, or resolved to an ambient module for which we can't reuse the result. - (unknownTypeReferenceDirectiveNames ??= []).push(entry as FileReference & string); + (unknownTypeReferenceDirectiveNames ??= []).push(entry); } if (!unknownTypeReferenceDirectiveNames) return result || emptyArray; const resolutions = resolveTypeReferenceDirectiveNamesWorker( unknownTypeReferenceDirectiveNames, containingFile, - { names: unknownTypeReferenceDirectiveNames, reusedNames } + reusedNames, ); // Combine results of resolutions @@ -2301,10 +2388,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg const moduleNames = getModuleNames(newSourceFile); const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile); // ensure that module resolution results are still correct - const resolutionsChanged = hasChangesInResolutions(moduleNames, newSourceFile, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo); + const resolutionsChanged = hasChangesInResolutions(moduleNames, newSourceFile, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo, moduleResolutionNameAndModeGetter); if (resolutionsChanged) { structureIsReused = StructureIsReused.SafeModules; - newSourceFile.resolvedModules = zipToModeAwareCache(newSourceFile, moduleNames, resolutions); + newSourceFile.resolvedModules = zipToModeAwareCache(newSourceFile, moduleNames, resolutions, moduleResolutionNameAndModeGetter); } else { newSourceFile.resolvedModules = oldSourceFile.resolvedModules; @@ -2312,10 +2399,10 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg const typesReferenceDirectives = newSourceFile.typeReferenceDirectives; const typeReferenceResolutions = resolveTypeReferenceDirectiveNamesReusingOldState(typesReferenceDirectives, newSourceFile); // ensure that types resolutions are still correct - const typeReferenceResolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, newSourceFile, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo); + const typeReferenceResolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, newSourceFile, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo, typeReferenceResolutionNameAndModeGetter); if (typeReferenceResolutionsChanged) { structureIsReused = StructureIsReused.SafeModules; - newSourceFile.resolvedTypeReferenceDirectiveNames = zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions); + newSourceFile.resolvedTypeReferenceDirectiveNames = zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions, typeReferenceResolutionNameAndModeGetter); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; @@ -2326,10 +2413,17 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg return structureIsReused; } - if (changesAffectingProgramStructure(oldOptions, options) || host.hasChangedAutomaticTypeDirectiveNames?.()) { + if (changesAffectingProgramStructure(oldOptions, options)) { return StructureIsReused.SafeModules; } + if (host.hasChangedAutomaticTypeDirectiveNames) { + if (host.hasChangedAutomaticTypeDirectiveNames()) return StructureIsReused.SafeModules; + } + else { + automaticTypeDirectiveNames = getAutomaticTypeDirectiveNames(options, host); + if (!arrayIsEqualTo(oldProgram.getAutomaticTypeDirectiveNames(), automaticTypeDirectiveNames)) return StructureIsReused.SafeModules; + } missingFilePaths = oldProgram.getMissingFilePaths(); // update fileName -> file mapping @@ -2357,6 +2451,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg fileReasons = oldProgram.getFileIncludeReasons(); fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics(); resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); + automaticTypeDirectiveNames = oldProgram.getAutomaticTypeDirectiveNames(); + automaticTypeDirectiveResolutions = oldProgram.getAutomaticTypeDirectiveResolutions(); sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; @@ -3573,7 +3669,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg function processTypeReferenceDirectives(file: SourceFile) { const typeDirectives = file.typeReferenceDirectives; - if (!typeDirectives) { + if (!typeDirectives.length) { + file.resolvedTypeReferenceDirectiveNames = undefined; return; } @@ -3586,7 +3683,12 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective, getModeForFileReference(ref, file.impliedNodeFormat)); const mode = ref.resolutionMode || file.impliedNodeFormat; if (mode && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.Node16 && getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeNext) { - programDiagnostics.add(createDiagnosticForRange(file, ref, Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext)); + (fileProcessingDiagnostics ??= []).push({ + kind: FilePreprocessingDiagnosticsKind.ResolutionDiagnostics, + diagnostics: [ + createDiagnosticForRange(file, ref, Diagnostics.resolution_mode_assertions_are_only_supported_when_moduleResolution_is_node16_or_nodenext) + ] + }); } processTypeReferenceDirective(fileName, mode, resolvedTypeReferenceDirective, { kind: FileIncludeKind.TypeReferenceDirective, file: file.path, index, }); } @@ -3594,28 +3696,29 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg function processTypeReferenceDirective( typeReferenceDirective: string, - mode: ResolutionMode | undefined, - resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined, + mode: ResolutionMode, + resolution: ResolvedTypeReferenceDirectiveWithFailedLookupLocations, reason: FileIncludeReason ): void { - tracing?.push(tracing.Phase.Program, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); - processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason); + tracing?.push(tracing.Phase.Program, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolution.resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); + processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolution, reason); tracing?.pop(); } function processTypeReferenceDirectiveWorker( typeReferenceDirective: string, - mode: ResolutionMode | undefined, - resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined, + mode: ResolutionMode, + resolution: ResolvedTypeReferenceDirectiveWithFailedLookupLocations, reason: FileIncludeReason ): void { - + addResolutionDiagnostics(resolution); // If we already found this library as a primary reference - nothing to do - const previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode); + const previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective, mode)?.resolvedTypeReferenceDirective; if (previousResolution && previousResolution.primary) { return; } let saveResolution = true; + const { resolvedTypeReferenceDirective } = resolution; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth++; @@ -3656,7 +3759,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg } if (saveResolution) { - resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolvedTypeReferenceDirective); + resolvedTypeReferenceDirectives.set(typeReferenceDirective, mode, resolution); } } @@ -3714,8 +3817,11 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg Debug.assert(resolutions.length === moduleNames.length); const optionsForFile = (useSourceOfProjectReferenceRedirect ? getRedirectReferenceForResolution(file)?.commandLine.options : undefined) || options; for (let index = 0; index < moduleNames.length; index++) { - const resolution = resolutions[index]; - setResolvedModule(file, moduleNames[index].text, resolution, getModeForUsageLocation(file, moduleNames[index])); + const resolution = resolutions[index].resolvedModule; + const moduleName = moduleNames[index].text; + const mode = getModeForUsageLocation(file, moduleNames[index]); + setResolvedModule(file, moduleName, resolutions[index], mode); + addResolutionDiagnosticsFromResolutionOrCache(file, moduleName, resolutions[index], mode); if (!resolution) { continue; @@ -4479,8 +4585,8 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg if (!symlinks) { symlinks = createSymlinkCache(currentDirectory, getCanonicalFileName); } - if (files && resolvedTypeReferenceDirectives && !symlinks.hasProcessedResolutions()) { - symlinks.setSymlinksFromResolutions(files, resolvedTypeReferenceDirectives); + if (files && automaticTypeDirectiveResolutions && !symlinks.hasProcessedResolutions()) { + symlinks.setSymlinksFromResolutions(files, automaticTypeDirectiveResolutions); } return symlinks; } diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts index 90c45fc4ecf..030e837a26e 100644 --- a/src/compiler/resolutionCache.ts +++ b/src/compiler/resolutionCache.ts @@ -7,11 +7,11 @@ import { closeFileWatcher, closeFileWatcherOf, CompilerOptions, - contains, createModeAwareCache, createModuleResolutionCache, createMultiMap, createTypeReferenceDirectiveResolutionCache, + createTypeReferenceResolutionLoader, Debug, Diagnostics, directorySeparator, @@ -30,11 +30,7 @@ import { GetCanonicalFileName, getDirectoryPath, getEffectiveTypeRoots, - getModeForFileReference, - getModeForResolutionAtIndex, - getModeForUsageLocation, getNormalizedAbsolutePath, - getResolutionName, getRootLength, HasInvalidatedResolutions, ignoredPaths, @@ -44,8 +40,6 @@ import { isExternalOrCommonJsModule, isNodeModulesDirectory, isRootedDiskPath, - isString, - isStringLiteralLike, isTraceEnabled, length, loadModuleFromGlobalCache, @@ -53,8 +47,7 @@ import { MinimalResolutionCacheHost, ModeAwareCache, ModuleResolutionCache, - ModuleResolutionHost, - ModuleResolutionInfo, + moduleResolutionNameAndModeGetter, mutateMap, noopFileWatcher, normalizePath, @@ -67,20 +60,20 @@ import { removeSuffix, removeTrailingDirectorySeparator, resolutionExtensionIsTSOrJson, + ResolutionLoader, ResolutionMode, - ResolvedModuleFull, ResolvedModuleWithFailedLookupLocations, ResolvedProjectReference, - ResolvedTypeReferenceDirective, ResolvedTypeReferenceDirectiveWithFailedLookupLocations, returnTrue, some, SourceFile, startsWith, stringContains, + StringLiteralLike, trace, - TypeReferenceDirectiveResolutionInfo, unorderedRemoveItem, + updateResolutionField, WatchDirectoryFlags, } from "./_namespaces/ts"; @@ -93,22 +86,27 @@ export interface ResolutionCache { startRecordingFilesWithChangedResolutions(): void; finishRecordingFilesWithChangedResolutions(): Path[] | undefined; - resolveModuleNames( - moduleNames: string[], + resolveModuleNameLiterals( + moduleLiterals: readonly StringLiteralLike[], containingFile: string, - reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, + options: CompilerOptions, + containingSourceFile: SourceFile, + reusedNames: readonly StringLiteralLike[] | undefined, + ): readonly ResolvedModuleWithFailedLookupLocations[]; + resolveTypeReferenceDirectiveReferences( + typeDirectiveReferences: readonly T[], + containingFile: string, + redirectedReference: ResolvedProjectReference | undefined, + options: CompilerOptions, containingSourceFile: SourceFile | undefined, - resolutionInfo: ModuleResolutionInfo | undefined - ): (ResolvedModuleFull | undefined)[]; - getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string, resolutionMode?: ResolutionMode): CachedResolvedModuleWithFailedLookupLocations | undefined; - resolveTypeReferenceDirectives( - typeDirectiveNames: string[] | readonly FileReference[], + reusedNames: readonly T[] | undefined + ): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[]; + + resolveSingleModuleNameWithoutWatching( + moduleName: string, containingFile: string, - redirectedReference: ResolvedProjectReference | undefined, - containingFileMode: ResolutionMode, - resolutionInfo: TypeReferenceDirectiveResolutionInfo | undefined, - ): (ResolvedTypeReferenceDirective | undefined)[]; + ): ResolvedModuleWithFailedLookupLocations; invalidateResolutionsOfFailedLookupLocations(): boolean; invalidateResolutionOfFile(filePath: Path): void; @@ -133,8 +131,8 @@ export interface ResolutionCache { /** @internal */ export interface ResolutionWithFailedLookupLocations { - readonly failedLookupLocations: string[]; - readonly affectingLocations: string[]; + failedLookupLocations?: string[]; + affectingLocations?: string[]; isInvalidated?: boolean; refCount?: number; // Files that have this resolution using @@ -329,9 +327,9 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) startCachingPerDirectoryResolution, finishCachingPerDirectoryResolution, - resolveModuleNames, - getResolvedModuleWithFailedLookupLocationsFromCache, - resolveTypeReferenceDirectives, + resolveModuleNameLiterals, + resolveTypeReferenceDirectiveReferences, + resolveSingleModuleNameWithoutWatching, removeResolutionsFromProjectReferenceRedirects, removeResolutionsOfFile, hasChangedAutomaticTypeDirectiveNames: () => hasChangedAutomaticTypeDirectiveNames, @@ -466,7 +464,8 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD hasChangedAutomaticTypeDirectiveNames = false; } - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, _containingSourceFile?: never, mode?: ResolutionMode): CachedResolvedModuleWithFailedLookupLocations { + function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, redirectedReference?: ResolvedProjectReference, mode?: ResolutionMode): CachedResolvedModuleWithFailedLookupLocations { + const host = resolutionHost.getCompilerHost?.() || resolutionHost; const primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference, mode); // return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts if (!resolutionHost.getGlobalCache) { @@ -478,7 +477,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD if (globalCache !== undefined && !isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && extensionIsTS(primaryResult.resolvedModule.extension))) { // create different collection of failed lookup locations for second pass // if it will fail and we've already found something during the first pass - we don't want to pollute its results - const { resolvedModule, failedLookupLocations, affectingLocations } = loadModuleFromGlobalCache( + const { resolvedModule, failedLookupLocations, affectingLocations, resolutionDiagnostics } = loadModuleFromGlobalCache( Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, @@ -489,8 +488,9 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD if (resolvedModule) { // Modify existing resolution so its saved in the directory cache as well (primaryResult.resolvedModule as any) = resolvedModule; - primaryResult.failedLookupLocations.push(...failedLookupLocations); - primaryResult.affectingLocations.push(...affectingLocations); + primaryResult.failedLookupLocations = updateResolutionField(primaryResult.failedLookupLocations, failedLookupLocations); + primaryResult.affectingLocations = updateResolutionField(primaryResult.affectingLocations, affectingLocations); + primaryResult.resolutionDiagnostics = updateResolutionField(primaryResult.resolutionDiagnostics, resolutionDiagnostics); return primaryResult; } } @@ -499,34 +499,45 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD return primaryResult; } - function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, _containingSourceFile?: SourceFile, resolutionMode?: ResolutionMode): CachedResolvedTypeReferenceDirectiveWithFailedLookupLocations { - return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache, resolutionMode); + function createModuleResolutionLoader( + containingFile: string, + redirectedReference: ResolvedProjectReference | undefined, + options: CompilerOptions, + ): ResolutionLoader { + return { + nameAndMode: moduleResolutionNameAndModeGetter, + resolve: (moduleName, resoluionMode) => resolveModuleName( + moduleName, + containingFile, + options, + redirectedReference, + resoluionMode, + ), + }; } - interface ResolveNamesWithLocalCacheInput { - names: readonly string[] | readonly FileReference[]; + interface ResolveNamesWithLocalCacheInput { + entries: readonly Entry[]; containingFile: string; + containingSourceFile: SourceFile; redirectedReference: ResolvedProjectReference | undefined; + options: CompilerOptions; + reusedNames?: readonly Entry[]; perFileCache: Map>; - loader: (name: string, containingFile: string, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, containingSourceFile?: SourceFile, resolutionMode?: ResolutionMode) => T; + loader: ResolutionLoader; getResolutionWithResolvedFileName: GetResolutionWithResolvedFileName; shouldRetryResolution: (t: T) => boolean; - reusedNames?: readonly string[]; - resolutionInfo?: ModuleResolutionInfo | TypeReferenceDirectiveResolutionInfo; logChanges?: boolean; - containingSourceFile?: SourceFile; - containingSourceFileMode?: ResolutionMode; } - function resolveNamesWithLocalCache({ - names, containingFile, redirectedReference, - perFileCache, + function resolveNamesWithLocalCache({ + entries, containingFile, containingSourceFile, redirectedReference, options, + perFileCache, reusedNames, loader, getResolutionWithResolvedFileName, - shouldRetryResolution, reusedNames, resolutionInfo, logChanges, containingSourceFile, containingSourceFileMode - }: ResolveNamesWithLocalCacheInput): (R | undefined)[] { + shouldRetryResolution, logChanges, + }: ResolveNamesWithLocalCacheInput): readonly T[] { const path = resolutionHost.toPath(containingFile); const resolutionsInFile = perFileCache.get(path) || perFileCache.set(path, createModeAwareCache()).get(path)!; - const resolvedModules: (R | undefined)[] = []; - const compilerOptions = resolutionHost.getCompilationSettings(); + const resolvedModules: T[] = []; const hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path); // All the resolutions in this file are invalidated if this file wasn't resolved using same redirect @@ -537,22 +548,9 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD !!redirectedReference; const seenNamesInFile = createModeAwareCache(); - let i = 0; - for (const entry of containingSourceFile && resolutionInfo ? resolutionInfo.names : names) { - const name = getResolutionName(entry); - // Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant - // they require calculating the mode for a given import from it's position in the resolution table, since a given - // import's syntax may override the file's default mode. - // Type references instead supply a `containingSourceFileMode` and a non-string entry which contains - // a default file mode override if applicable. - const mode = !isString(entry) ? - isStringLiteralLike(entry) ? - getModeForUsageLocation(containingSourceFile!, entry) : - getModeForFileReference(entry, containingSourceFileMode) : - containingSourceFile ? - getModeForResolutionAtIndex(containingSourceFile, i) : - undefined; - i++; + for (const entry of entries) { + const name = loader.nameAndMode.getName(entry); + const mode = loader.nameAndMode.getMode(entry, containingSourceFile); let resolution = resolutionsInFile.get(name, mode); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name, mode) && @@ -560,7 +558,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD // If the name is unresolved import that was invalidated, recalculate (hasInvalidatedNonRelativeUnresolvedImport && !isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) { const existingResolution = resolution; - resolution = loader(name, containingFile, compilerOptions, resolutionHost.getCompilerHost?.() || resolutionHost, redirectedReference, containingSourceFile, mode); + resolution = loader.resolve(name, mode); if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) { resolutionHost.onDiscoveredSymlink(); } @@ -578,11 +576,11 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD } else { const host = resolutionHost.getCompilerHost?.() || resolutionHost; - if (isTraceEnabled(compilerOptions, host) && !seenNamesInFile.has(name, mode)) { + if (isTraceEnabled(options, host) && !seenNamesInFile.has(name, mode)) { const resolved = getResolutionWithResolvedFileName(resolution); trace( host, - loader === resolveModuleName as unknown ? + perFileCache === resolvedModuleNames as unknown ? resolved?.resolvedFileName ? resolved.packageId ? Diagnostics.Reusing_resolution_of_module_0_from_1_of_old_program_it_was_successfully_resolved_to_2_with_Package_ID_3 : @@ -602,30 +600,22 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD } Debug.assert(resolution !== undefined && !resolution.isInvalidated); seenNamesInFile.set(name, mode, true); - resolvedModules.push(getResolutionWithResolvedFileName(resolution)); - } - - // If resolving type reference directive we dont need containingSourceFile to determine if we can use resolutionInfo - if (resolutionInfo && (loader === resolveTypeReferenceDirective as unknown || containingSourceFile)) { - resolutionInfo.reusedNames?.forEach(entry => seenNamesInFile.set( - getResolutionName(entry), - !isString(entry) && isStringLiteralLike(entry) ? - getModeForUsageLocation(containingSourceFile!, entry) : - getModeForFileReference(entry, containingSourceFileMode), - true, - )); - reusedNames = undefined; + resolvedModules.push(resolution); } + reusedNames?.forEach(entry => seenNamesInFile.set( + loader.nameAndMode.getName(entry), + loader.nameAndMode.getMode(entry, containingSourceFile), + true, + )); if (resolutionsInFile.size() !== seenNamesInFile.size()) { // Stop watching and remove the unused name resolutionsInFile.forEach((resolution, name, mode) => { - if (!seenNamesInFile.has(name, mode) && !contains(reusedNames, name)) { + if (!seenNamesInFile.has(name, mode)) { stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName); resolutionsInFile.delete(name, mode); } }); } - return resolvedModules; function resolutionIsEqualTo(oldResolution: T | undefined, newResolution: T | undefined): boolean { @@ -647,53 +637,67 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD } } - function resolveTypeReferenceDirectives( - typeDirectiveNames: string[] | readonly FileReference[], + function resolveTypeReferenceDirectiveReferences( + typeDirectiveReferences: readonly T[], containingFile: string, - redirectedReference?: ResolvedProjectReference, - containingFileMode?: ResolutionMode, - resolutionInfo?: TypeReferenceDirectiveResolutionInfo, - ): (ResolvedTypeReferenceDirective | undefined)[] { - return resolveNamesWithLocalCache({ - names: typeDirectiveNames, + redirectedReference: ResolvedProjectReference | undefined, + options: CompilerOptions, + containingSourceFile: SourceFile | undefined, + reusedNames: readonly T[] | undefined + ): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[]{ + return resolveNamesWithLocalCache({ + entries: typeDirectiveReferences, containingFile, + containingSourceFile, redirectedReference, + options, + reusedNames, perFileCache: resolvedTypeReferenceDirectives, - loader: resolveTypeReferenceDirective, + loader: createTypeReferenceResolutionLoader( + containingFile, + redirectedReference, + options, + resolutionHost.getCompilerHost?.() || resolutionHost, + typeReferenceDirectiveResolutionCache + ), getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective, shouldRetryResolution: resolution => resolution.resolvedTypeReferenceDirective === undefined, - containingSourceFileMode: containingFileMode, - resolutionInfo, }); } - function resolveModuleNames( - moduleNames: string[], + function resolveModuleNameLiterals( + moduleLiterals: readonly StringLiteralLike[], containingFile: string, - reusedNames: string[] | undefined, - redirectedReference?: ResolvedProjectReference, - containingSourceFile?: SourceFile, - resolutionInfo?: ModuleResolutionInfo - ): (ResolvedModuleFull | undefined)[] { - return resolveNamesWithLocalCache({ - names: moduleNames, + redirectedReference: ResolvedProjectReference | undefined, + options: CompilerOptions, + containingSourceFile: SourceFile, + reusedNames: readonly StringLiteralLike[] | undefined, + ): readonly ResolvedModuleWithFailedLookupLocations[] { + return resolveNamesWithLocalCache({ + entries: moduleLiterals, containingFile, + containingSourceFile, redirectedReference, + options, + reusedNames, perFileCache: resolvedModuleNames, - loader: resolveModuleName, + loader: createModuleResolutionLoader( + containingFile, + redirectedReference, + options, + ), getResolutionWithResolvedFileName: getResolvedModule, shouldRetryResolution: resolution => !resolution.resolvedModule || !resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension), - reusedNames, - resolutionInfo, logChanges: logChangesWhenResolvingModule, - containingSourceFile, }); } - function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string, resolutionMode?: ResolutionMode): CachedResolvedModuleWithFailedLookupLocations | undefined { - const cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile)); - if (!cache) return undefined; - return cache.get(moduleName, resolutionMode); + function resolveSingleModuleNameWithoutWatching(moduleName: string, containingFile: string) { + const path = resolutionHost.toPath(containingFile); + const resolutionsInFile = resolvedModuleNames.get(path); + const resolution = resolutionsInFile?.get(moduleName, /*mode*/ undefined); + if (resolution && !resolution.isInvalidated) return resolution; + return resolveModuleName(moduleName, containingFile, resolutionHost.getCompilationSettings()); } function isNodeModulesAtTypesDirectory(dirPath: Path) { @@ -797,42 +801,44 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD Debug.assert(!!resolution.refCount); const { failedLookupLocations, affectingLocations } = resolution; - if (!failedLookupLocations.length && !affectingLocations.length) return; - if (failedLookupLocations.length) resolutionsWithFailedLookups.push(resolution); + if (!failedLookupLocations?.length && !affectingLocations?.length) return; + if (failedLookupLocations?.length) resolutionsWithFailedLookups.push(resolution); let setAtRoot = false; - for (const failedLookupLocation of failedLookupLocations) { - const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); - const toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); - if (toWatch) { - const { dir, dirPath, nonRecursive } = toWatch; - // If the failed lookup location path is not one of the supported extensions, - // store it in the custom path - if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) { - const refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0; - customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1); - } - if (dirPath === rootPath) { - Debug.assert(!nonRecursive); - setAtRoot = true; - } - else { - setDirectoryWatcher(dir, dirPath, nonRecursive); + if (failedLookupLocations) { + for (const failedLookupLocation of failedLookupLocations) { + const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); + const toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); + if (toWatch) { + const { dir, dirPath, nonRecursive } = toWatch; + // If the failed lookup location path is not one of the supported extensions, + // store it in the custom path + if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) { + const refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0; + customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1); + } + if (dirPath === rootPath) { + Debug.assert(!nonRecursive); + setAtRoot = true; + } + else { + setDirectoryWatcher(dir, dirPath, nonRecursive); + } } } - } - if (setAtRoot) { - // This is always non recursive - setDirectoryWatcher(rootDir!, rootPath, /*nonRecursive*/ true); // TODO: GH#18217 + if (setAtRoot) { + // This is always non recursive + setDirectoryWatcher(rootDir!, rootPath, /*nonRecursive*/ true); // TODO: GH#18217 + } } - watchAffectingLocationsOfResolution(resolution, !failedLookupLocations.length); + watchAffectingLocationsOfResolution(resolution, !failedLookupLocations?.length); } function watchAffectingLocationsOfResolution(resolution: ResolutionWithFailedLookupLocations, addToResolutionsWithOnlyAffectingLocations: boolean) { Debug.assert(!!resolution.refCount); const { affectingLocations } = resolution; - if (!affectingLocations.length) return; + if (!affectingLocations?.length) return; if (addToResolutionsWithOnlyAffectingLocations) resolutionsWithOnlyAffectingLocations.push(resolution); // Watch package json for (const affectingLocation of affectingLocations) { @@ -932,7 +938,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD const { failedLookupLocations, affectingLocations } = resolution; if (unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) { let removeAtRoot = false; - for (const failedLookupLocation of failedLookupLocations) { + for (const failedLookupLocation of failedLookupLocations!) { const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation); const toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath); if (toWatch) { @@ -960,13 +966,15 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD removeDirectoryWatcher(rootPath); } } - else if (affectingLocations.length) { + else if (affectingLocations?.length) { unorderedRemoveItem(resolutionsWithOnlyAffectingLocations, resolution); } - for (const affectingLocation of affectingLocations) { - const watcher = fileWatchesOfAffectingLocations.get(affectingLocation)!; - watcher.resolutions--; + if (affectingLocations) { + for (const affectingLocation of affectingLocations) { + const watcher = fileWatchesOfAffectingLocations.get(affectingLocation)!; + watcher.resolutions--; + } } } @@ -1020,7 +1028,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective); } - function invalidateResolutions(resolutions: ResolutionWithFailedLookupLocations[] | undefined, canInvalidate: (resolution: ResolutionWithFailedLookupLocations) => boolean) { + function invalidateResolutions(resolutions: ResolutionWithFailedLookupLocations[] | undefined, canInvalidate: (resolution: ResolutionWithFailedLookupLocations) => boolean | undefined) { if (!resolutions) return false; let invalidated = false; for (const resolution of resolutions) { @@ -1130,7 +1138,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD function canInvalidateFailedLookupResolution(resolution: ResolutionWithFailedLookupLocations) { if (canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution)) return true; if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) return false; - return resolution.failedLookupLocations.some(location => isInvalidatedFailedLookup(resolutionHost.toPath(location))); + return resolution.failedLookupLocations?.some(location => isInvalidatedFailedLookup(resolutionHost.toPath(location))); } function isInvalidatedFailedLookup(locationPath: Path) { @@ -1140,7 +1148,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD } function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution: ResolutionWithFailedLookupLocations) { - return !!affectingPathChecks && resolution.affectingLocations.some(location => affectingPathChecks!.has(location)); + return !!affectingPathChecks && resolution.affectingLocations?.some(location => affectingPathChecks!.has(location)); } function closeTypeRootsWatch() { diff --git a/src/compiler/tsbuildPublic.ts b/src/compiler/tsbuildPublic.ts index f4baf9145f8..f2b4ccae01b 100644 --- a/src/compiler/tsbuildPublic.ts +++ b/src/compiler/tsbuildPublic.ts @@ -24,9 +24,11 @@ import { createDiagnosticReporter, createGetCanonicalFileName, createModuleResolutionCache, + createModuleResolutionLoader, CreateProgram, createProgramHost, createTypeReferenceDirectiveResolutionCache, + createTypeReferenceResolutionLoader, createWatchFactory, createWatchHost, CustomTransformers, @@ -75,7 +77,6 @@ import { isString, listFiles, loadWithModeAwareCache, - loadWithTypeDirectiveCache, map, maybeBind, missingFileModifiedTime, @@ -97,15 +98,10 @@ import { ProgramMultiFileEmitBuildInfo, readBuilderProgram, ReadBuildProgramHost, - ResolutionMode, resolveConfigFileProjectName, ResolvedConfigFileName, - ResolvedProjectReference, - ResolvedTypeReferenceDirective, - resolveModuleName, resolvePath, resolveProjectReferencePath, - resolveTypeReferenceDirective, returnUndefined, SemanticDiagnosticsBuilderProgram, setGetSourceFileAsHashVersioned, @@ -438,22 +434,40 @@ function createSolutionBuilderState(watch: boolean, ho const compilerHost = createCompilerHostFromProgramHost(host, () => state.projectCompilerOptions) as CompilerHost & ReadBuildProgramHost; setGetSourceFileAsHashVersioned(compilerHost); compilerHost.getParsedCommandLine = fileName => parseConfigFile(state, fileName as ResolvedConfigFileName, toResolvedConfigFilePath(state, fileName as ResolvedConfigFileName)); + compilerHost.resolveModuleNameLiterals = maybeBind(host, host.resolveModuleNameLiterals); + compilerHost.resolveTypeReferenceDirectiveReferences = maybeBind(host, host.resolveTypeReferenceDirectiveReferences); compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives); compilerHost.getModuleResolutionCache = maybeBind(host, host.getModuleResolutionCache); - const moduleResolutionCache = !compilerHost.resolveModuleNames ? createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined; - const typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache?.getPackageJsonInfoCache()) : undefined; - if (!compilerHost.resolveModuleNames) { - const loader = (moduleName: string, resolverMode: ResolutionMode, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => - resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference, resolverMode).resolvedModule; - compilerHost.resolveModuleNames = (moduleNames, containingFile, _reusedNames, redirectedReference, _options, containingSourceFile, resolutionInfo) => - loadWithModeAwareCache(Debug.checkEachDefined(moduleNames), Debug.checkDefined(containingSourceFile), containingFile, redirectedReference, resolutionInfo, loader); + let moduleResolutionCache: ModuleResolutionCache | undefined, typeReferenceDirectiveResolutionCache: TypeReferenceDirectiveResolutionCache | undefined; + if (!compilerHost.resolveModuleNameLiterals && !compilerHost.resolveModuleNames) { + moduleResolutionCache = createModuleResolutionCache(currentDirectory, getCanonicalFileName); + compilerHost.resolveModuleNameLiterals = (moduleNames, containingFile, redirectedReference, options, containingSourceFile) => + loadWithModeAwareCache( + moduleNames, + containingFile, + redirectedReference, + options, + containingSourceFile, + host, + moduleResolutionCache, + createModuleResolutionLoader, + ); compilerHost.getModuleResolutionCache = () => moduleResolutionCache; } - if (!compilerHost.resolveTypeReferenceDirectives) { - const loader = (moduleName: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined, containingFileMode: ResolutionMode) => resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache, containingFileMode).resolvedTypeReferenceDirective!; - compilerHost.resolveTypeReferenceDirectives = (typeReferenceDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) => - loadWithTypeDirectiveCache(Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, containingFileMode, loader); + if (!compilerHost.resolveTypeReferenceDirectiveReferences && !compilerHost.resolveTypeReferenceDirectives) { + typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache?.getPackageJsonInfoCache()); + compilerHost.resolveTypeReferenceDirectiveReferences = (typeDirectiveNames, containingFile, redirectedReference, options, containingSourceFile) => + loadWithModeAwareCache( + typeDirectiveNames, + containingFile, + redirectedReference, + options, + containingSourceFile, + host, + typeReferenceDirectiveResolutionCache, + createTypeReferenceResolutionLoader, + ); } compilerHost.getBuildInfo = (fileName, configFilePath) => getBuildInfo(state, fileName, toResolvedConfigFilePath(state, configFilePath as ResolvedConfigFileName), /*modifiedTime*/ undefined); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7ce54d3dd6c..47db014d8ae 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4114,8 +4114,8 @@ export interface SourceFile extends Declaration { // Stores a mapping 'external module reference text' -> 'resolved file name' | undefined // It is used to resolve module names in the checker. // Content of this field should never be used directly - use getResolvedModuleFileName/setResolvedModuleFileName functions instead - /** @internal */ resolvedModules?: ModeAwareCache; - /** @internal */ resolvedTypeReferenceDirectiveNames: ModeAwareCache; + /** @internal */ resolvedModules?: ModeAwareCache; + /** @internal */ resolvedTypeReferenceDirectiveNames?: ModeAwareCache; /** @internal */ imports: readonly StringLiteralLike[]; // Identifier only if `declare global` /** @internal */ moduleAugmentations: readonly (StringLiteral | Identifier)[]; @@ -4386,7 +4386,8 @@ export type FileIncludeReason = /** @internal */ export const enum FilePreprocessingDiagnosticsKind { FilePreprocessingReferencedDiagnostic, - FilePreprocessingFileExplainingDiagnostic + FilePreprocessingFileExplainingDiagnostic, + ResolutionDiagnostics, } /** @internal */ @@ -4407,7 +4408,13 @@ export interface FilePreprocessingFileExplainingDiagnostic { } /** @internal */ -export type FilePreprocessingDiagnostics = FilePreprocessingReferencedDiagnostic | FilePreprocessingFileExplainingDiagnostic; +export interface ResolutionDiagnostics { + kind: FilePreprocessingDiagnosticsKind.ResolutionDiagnostics; + diagnostics: readonly Diagnostic[]; +} + +/** @internal */ +export type FilePreprocessingDiagnostics = FilePreprocessingReferencedDiagnostic | FilePreprocessingFileExplainingDiagnostic | ResolutionDiagnostics; /** @internal */ export const enum EmitOnly{ @@ -4483,7 +4490,9 @@ export interface Program extends ScriptReferenceHost { getRelationCacheSizes(): { assignable: number, identity: number, subtype: number, strictSubtype: number }; /** @internal */ getFileProcessingDiagnostics(): FilePreprocessingDiagnostics[] | undefined; - /** @internal */ getResolvedTypeReferenceDirectives(): ModeAwareCache; + /** @internal */ getResolvedTypeReferenceDirectives(): ModeAwareCache; + /** @internal */ getAutomaticTypeDirectiveNames(): string[]; + /** @internal */ getAutomaticTypeDirectiveResolutions(): ModeAwareCache; isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; @@ -4521,8 +4530,6 @@ export interface Program extends ScriptReferenceHost { /** @internal */ getFileIncludeReasons(): MultiMap; /** @internal */ useCaseSensitiveFileNames(): boolean; - /** @internal */ getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string, mode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations | undefined; - getProjectReferences(): readonly ProjectReference[] | undefined; getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined; /** @internal */ getProjectReferenceRedirect(fileName: string): string | undefined; @@ -4646,7 +4653,7 @@ export interface TypeCheckerHost extends ModuleSpecifierResolutionHost { getSourceFiles(): readonly SourceFile[]; getSourceFile(fileName: string): SourceFile | undefined; - getResolvedTypeReferenceDirectives(): ModeAwareCache; + getResolvedTypeReferenceDirectives(): ModeAwareCache; getProjectReferenceRedirect(fileName: string): string | undefined; isSourceOfProjectReferenceRedirect(fileName: string): boolean; @@ -5343,8 +5350,8 @@ export interface EmitResolver { moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean; isArgumentsLocalBinding(node: Identifier): boolean; getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration | ImportTypeNode | ImportCall): SourceFile | undefined; - getTypeReferenceDirectivesForEntityName(name: EntityNameOrEntityNameExpression): [specifier: string, mode: ResolutionMode | undefined][] | undefined; - getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): [specifier: string, mode: ResolutionMode | undefined][] | undefined; + getTypeReferenceDirectivesForEntityName(name: EntityNameOrEntityNameExpression): [specifier: string, mode: ResolutionMode][] | undefined; + getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): [specifier: string, mode: ResolutionMode][] | undefined; isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean; getJsxFactoryEntity(location?: Node): EntityName | undefined; getJsxFragmentFactoryEntity(location?: Node): EntityName | undefined; @@ -7275,11 +7282,11 @@ export const enum Extension { export interface ResolvedModuleWithFailedLookupLocations { readonly resolvedModule: ResolvedModuleFull | undefined; /** @internal */ - readonly failedLookupLocations: string[]; + failedLookupLocations?: string[]; /** @internal */ - readonly affectingLocations: string[]; + affectingLocations?: string[]; /** @internal */ - readonly resolutionDiagnostics: Diagnostic[] + resolutionDiagnostics?: Diagnostic[] } export interface ResolvedTypeReferenceDirective { @@ -7300,9 +7307,9 @@ export interface ResolvedTypeReferenceDirective { export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; - readonly failedLookupLocations: string[]; - /** @internal */ readonly affectingLocations: string[]; - /** @internal */ resolutionDiagnostics: Diagnostic[]; + /** @internal */ failedLookupLocations?: string[]; + /** @internal */ affectingLocations?: string[]; + /** @internal */ resolutionDiagnostics?: Diagnostic[]; } /** @internal */ @@ -7310,13 +7317,6 @@ export type HasInvalidatedResolutions = (sourceFile: Path) => boolean; /** @internal */ export type HasChangedAutomaticTypeDirectiveNames = () => boolean; -export interface ResolutionInfo { - names: readonly T[]; - reusedNames: readonly T[] | undefined; -} -export type ModuleResolutionInfo = ResolutionInfo; -export type TypeReferenceDirectiveResolutionInfo = ResolutionInfo; - export interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; getSourceFileByPath?(fileName: string, path: Path, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; @@ -7337,15 +7337,34 @@ export interface CompilerHost extends ModuleResolutionHost { * If resolveModuleNames is implemented then implementation for members from ModuleResolutionHost can be just * 'throw new Error("NotImplemented")' */ - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile, resolutionInfo?: ModuleResolutionInfo): (ResolvedModule | undefined)[]; + /** @deprecated supply resolveModuleNameLiterals instead for resolution that can handle newer resolution modes like nodenext */ + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; /** * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it */ getModuleResolutionCache?(): ModuleResolutionCache | undefined; /** + * @deprecated supply resolveTypeReferenceDirectiveReferences instead for resolution that can handle newer resolution modes like nodenext + * * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode | undefined, resolutionInfo?: TypeReferenceDirectiveResolutionInfo): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode): (ResolvedTypeReferenceDirective | undefined)[]; + resolveModuleNameLiterals?( + moduleLiterals: readonly StringLiteralLike[], + containingFile: string, + redirectedReference: ResolvedProjectReference | undefined, + options: CompilerOptions, + containingSourceFile: SourceFile, + reusedNames: readonly StringLiteralLike[] | undefined, + ): readonly ResolvedModuleWithFailedLookupLocations[]; + resolveTypeReferenceDirectiveReferences?( + typeDirectiveReferences: readonly T[], + containingFile: string, + redirectedReference: ResolvedProjectReference | undefined, + options: CompilerOptions, + containingSourceFile: SourceFile | undefined, + reusedNames: readonly T[] | undefined + ): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[]; getEnvironmentVariable?(name: string): string | undefined; /** @internal */ onReleaseOldSourceFile?(oldSourceFile: SourceFile, oldOptions: CompilerOptions, hasSourceFileByPath: boolean): void; /** @internal */ onReleaseParsedCommandLine?(configFileName: string, oldResolvedRef: ResolvedProjectReference | undefined, optionOptions: CompilerOptions): void; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 36cfe74f91e..b2cc2fb99f3 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -124,7 +124,6 @@ import { FileExtensionInfo, fileExtensionIs, fileExtensionIsOneOf, - FileReference, FileWatcher, filter, find, @@ -184,8 +183,6 @@ import { getPathComponents, getPathFromPathComponents, getRelativePathToDirectoryOrUrl, - getResolutionMode, - getResolutionName, getRootLength, getSnippetElement, getStringComparer, @@ -425,8 +422,11 @@ import { RequireOrImportCall, RequireVariableStatement, ResolutionMode, + ResolutionNameAndModeGetter, ResolvedModuleFull, + ResolvedModuleWithFailedLookupLocations, ResolvedTypeReferenceDirective, + ResolvedTypeReferenceDirectiveWithFailedLookupLocations, ReturnStatement, SatisfiesExpression, ScriptKind, @@ -705,11 +705,11 @@ export function getFullWidth(node: Node) { /** @internal */ export function getResolvedModule(sourceFile: SourceFile | undefined, moduleNameText: string, mode: ResolutionMode): ResolvedModuleFull | undefined { - return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText, mode); + return sourceFile?.resolvedModules?.get(moduleNameText, mode)?.resolvedModule; } /** @internal */ -export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleFull | undefined, mode: ResolutionMode): void { +export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModuleWithFailedLookupLocations, mode: ResolutionMode): void { if (!sourceFile.resolvedModules) { sourceFile.resolvedModules = createModeAwareCache(); } @@ -718,7 +718,7 @@ export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string } /** @internal */ -export function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined, mode: ResolutionMode): void { +export function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirectiveWithFailedLookupLocations, mode: ResolutionMode): void { if (!sourceFile.resolvedTypeReferenceDirectiveNames) { sourceFile.resolvedTypeReferenceDirectiveNames = createModeAwareCache(); } @@ -728,7 +728,7 @@ export function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeRe /** @internal */ export function getResolvedTypeReferenceDirective(sourceFile: SourceFile | undefined, typeReferenceDirectiveName: string, mode: ResolutionMode): ResolvedTypeReferenceDirective | undefined { - return sourceFile?.resolvedTypeReferenceDirectiveNames?.get(typeReferenceDirectiveName, mode); + return sourceFile?.resolvedTypeReferenceDirectiveNames?.get(typeReferenceDirectiveName, mode)?.resolvedTypeReferenceDirective; } /** @internal */ @@ -739,12 +739,16 @@ export function projectReferenceIsEqualTo(oldRef: ProjectReference, newRef: Proj } /** @internal */ -export function moduleResolutionIsEqualTo(oldResolution: ResolvedModuleFull, newResolution: ResolvedModuleFull): boolean { - return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport && - oldResolution.extension === newResolution.extension && - oldResolution.resolvedFileName === newResolution.resolvedFileName && - oldResolution.originalPath === newResolution.originalPath && - packageIdIsEqual(oldResolution.packageId, newResolution.packageId); +export function moduleResolutionIsEqualTo(oldResolution: ResolvedModuleWithFailedLookupLocations, newResolution: ResolvedModuleWithFailedLookupLocations): boolean { + return oldResolution === newResolution || + oldResolution.resolvedModule === newResolution.resolvedModule || + !!oldResolution.resolvedModule && + !!newResolution.resolvedModule && + oldResolution.resolvedModule.isExternalLibraryImport === newResolution.resolvedModule.isExternalLibraryImport && + oldResolution.resolvedModule.extension === newResolution.resolvedModule.extension && + oldResolution.resolvedModule.resolvedFileName === newResolution.resolvedModule.resolvedFileName && + oldResolution.resolvedModule.originalPath === newResolution.resolvedModule.originalPath && + packageIdIsEqual(oldResolution.resolvedModule.packageId, newResolution.resolvedModule.packageId); } function packageIdIsEqual(a: PackageId | undefined, b: PackageId | undefined): boolean { @@ -762,26 +766,32 @@ export function packageIdToString(packageId: PackageId): string { } /** @internal */ -export function typeDirectiveIsEqualTo(oldResolution: ResolvedTypeReferenceDirective, newResolution: ResolvedTypeReferenceDirective): boolean { - return oldResolution.resolvedFileName === newResolution.resolvedFileName - && oldResolution.primary === newResolution.primary - && oldResolution.originalPath === newResolution.originalPath; +export function typeDirectiveIsEqualTo(oldResolution: ResolvedTypeReferenceDirectiveWithFailedLookupLocations, newResolution: ResolvedTypeReferenceDirectiveWithFailedLookupLocations): boolean { + return oldResolution === newResolution || + oldResolution.resolvedTypeReferenceDirective === newResolution.resolvedTypeReferenceDirective || + !!oldResolution.resolvedTypeReferenceDirective && + !!newResolution.resolvedTypeReferenceDirective && + oldResolution.resolvedTypeReferenceDirective.resolvedFileName === newResolution.resolvedTypeReferenceDirective.resolvedFileName && + !!oldResolution.resolvedTypeReferenceDirective.primary === !!newResolution.resolvedTypeReferenceDirective.primary && + oldResolution.resolvedTypeReferenceDirective.originalPath === newResolution.resolvedTypeReferenceDirective.originalPath; } /** @internal */ -export function hasChangesInResolutions( - names: readonly StringLiteralLike[] | readonly FileReference[], +export function hasChangesInResolutions( + names: readonly K[], newSourceFile: SourceFile, - newResolutions: readonly T[], - oldResolutions: ModeAwareCache | undefined, - comparer: (oldResolution: T, newResolution: T) => boolean): boolean { + newResolutions: readonly V[], + oldResolutions: ModeAwareCache | undefined, + comparer: (oldResolution: V, newResolution: V) => boolean, + nameAndModeGetter: ResolutionNameAndModeGetter, +): boolean { Debug.assert(names.length === newResolutions.length); for (let i = 0; i < names.length; i++) { const newResolution = newResolutions[i]; const entry = names[i]; - const name = getResolutionName(entry); - const mode = getResolutionMode(entry, newSourceFile); + const name = nameAndModeGetter.getName(entry); + const mode = nameAndModeGetter.getMode(entry, newSourceFile); const oldResolution = oldResolutions && oldResolutions.get(name, mode); const changed = oldResolution @@ -7726,7 +7736,7 @@ export interface SymlinkCache { * don't include automatic type reference directives. Must be called only when * `hasProcessedResolutions` returns false (once per cache instance). */ - setSymlinksFromResolutions(files: readonly SourceFile[], typeReferenceDirectives: ModeAwareCache | undefined): void; + setSymlinksFromResolutions(files: readonly SourceFile[], typeReferenceDirectives: ModeAwareCache): void; /** * @internal * Whether `setSymlinksFromResolutions` has already been called. @@ -7762,9 +7772,10 @@ export function createSymlinkCache(cwd: string, getCanonicalFileName: GetCanonic Debug.assert(!hasProcessedResolutions); hasProcessedResolutions = true; for (const file of files) { - file.resolvedModules?.forEach(resolution => processResolution(this, resolution)); + file.resolvedModules?.forEach(resolution => processResolution(this, resolution.resolvedModule)); + file.resolvedTypeReferenceDirectiveNames?.forEach(resolution => processResolution(this, resolution.resolvedTypeReferenceDirective)); } - typeReferenceDirectives?.forEach(resolution => processResolution(this, resolution)); + typeReferenceDirectives.forEach(resolution => processResolution(this, resolution.resolvedTypeReferenceDirective)); }, hasProcessedResolutions: () => hasProcessedResolutions, }; diff --git a/src/compiler/watchPublic.ts b/src/compiler/watchPublic.ts index e386f748bea..d46964109c9 100644 --- a/src/compiler/watchPublic.ts +++ b/src/compiler/watchPublic.ts @@ -57,7 +57,6 @@ import { MapLike, maybeBind, ModuleResolutionCache, - ModuleResolutionInfo, noop, noopFileWatcher, parseConfigHostFromCompilerHostLike, @@ -69,18 +68,20 @@ import { ResolutionCacheHost, ResolutionMode, ResolvedModule, + ResolvedModuleWithFailedLookupLocations, ResolvedProjectReference, ResolvedTypeReferenceDirective, + ResolvedTypeReferenceDirectiveWithFailedLookupLocations, returnFalse, returnTrue, ScriptTarget, setGetSourceFileAsHashVersioned, SharedExtendedConfigFileWatcher, SourceFile, + StringLiteralLike, sys, System, toPath, - TypeReferenceDirectiveResolutionInfo, updateErrorForNoInputFiles, updateMissingFilePathsWatch, updateSharedExtendedConfigFileWatcher, @@ -202,10 +203,34 @@ export interface ProgramHost { /** If provided is used to get the environment variable */ getEnvironmentVariable?(name: string): string | undefined; - /** If provided, used to resolve the module names, otherwise typescript's default module resolution */ - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile, resolutionInfo?: ModuleResolutionInfo): (ResolvedModule | undefined)[]; - /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode, resolutionInfo?: TypeReferenceDirectiveResolutionInfo): (ResolvedTypeReferenceDirective | undefined)[]; + /** + * @deprecated supply resolveModuleNameLiterals instead for resolution that can handle newer resolution modes like nodenext + * + * If provided, used to resolve the module names, otherwise typescript's default module resolution + */ + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; + /** + * @deprecated supply resolveTypeReferenceDirectiveReferences instead for resolution that can handle newer resolution modes like nodenext + * + * If provided, used to resolve type reference directives, otherwise typescript's default resolution + */ + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode): (ResolvedTypeReferenceDirective | undefined)[]; + resolveModuleNameLiterals?( + moduleLiterals: readonly StringLiteralLike[], + containingFile: string, + redirectedReference: ResolvedProjectReference | undefined, + options: CompilerOptions, + containingSourceFile: SourceFile, + reusedNames: readonly StringLiteralLike[] | undefined, + ): readonly ResolvedModuleWithFailedLookupLocations[]; + resolveTypeReferenceDirectiveReferences?( + typeDirectiveReferences: readonly T[], + containingFile: string, + redirectedReference: ResolvedProjectReference | undefined, + options: CompilerOptions, + containingSourceFile: SourceFile | undefined, + reusedNames: readonly T[] | undefined + ): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[]; /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */ hasInvalidatedResolutions?(filePath: Path): boolean; /** @@ -463,16 +488,21 @@ export function createWatchProgram(host: WatchCompiler /*logChangesWhenResolvingModule*/ false ); // Resolve module using host module resolution strategy if provided otherwise use resolution cache to resolve module names - compilerHost.resolveModuleNames = host.resolveModuleNames ? - ((...args) => host.resolveModuleNames!(...args)) : - ((moduleNames, containingFile, reusedNames, redirectedReference, _options, sourceFile, resolutionInfo) => resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, sourceFile, resolutionInfo)); - compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ? - ((...args) => host.resolveTypeReferenceDirectives!(...args)) : - ((typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode, resolutionInfo) => resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, resolutionInfo)); - compilerHost.getModuleResolutionCache = host.resolveModuleNames ? + compilerHost.resolveModuleNameLiterals = maybeBind(host, host.resolveModuleNameLiterals); + compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames); + if (!compilerHost.resolveModuleNameLiterals && !compilerHost.resolveModuleNames) { + compilerHost.resolveModuleNameLiterals = resolutionCache.resolveModuleNameLiterals.bind(resolutionCache); + } + compilerHost.resolveTypeReferenceDirectiveReferences = maybeBind(host, host.resolveTypeReferenceDirectiveReferences); + compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives); + if (!compilerHost.resolveTypeReferenceDirectiveReferences && !compilerHost.resolveTypeReferenceDirectives) { + compilerHost.resolveTypeReferenceDirectiveReferences = resolutionCache.resolveTypeReferenceDirectiveReferences.bind(resolutionCache); + } + compilerHost.getModuleResolutionCache = host.resolveModuleNameLiterals || host.resolveModuleNames ? maybeBind(host, host.getModuleResolutionCache) : (() => resolutionCache.getModuleResolutionCache()); - const userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; + const userProvidedResolution = !!host.resolveModuleNameLiterals || !!host.resolveTypeReferenceDirectiveReferences || + !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; // All resolutions are invalid if user provided resolutions and didnt supply hasInvalidatedResolutions const customHasInvalidatedResolutions = userProvidedResolution ? maybeBind(host, host.hasInvalidatedResolutions) || returnTrue : diff --git a/src/server/project.ts b/src/server/project.ts index dcce4777002..ab2a5252cd7 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -98,7 +98,6 @@ import { maybeBind, ModuleResolutionCache, ModuleResolutionHost, - ModuleResolutionInfo, noop, noopFileWatcher, normalizePath, @@ -120,11 +119,9 @@ import { removeFileExtension, ResolutionCache, resolutionExtensionIsTSOrJson, - ResolutionMode, - ResolvedModuleFull, ResolvedModuleWithFailedLookupLocations, ResolvedProjectReference, - ResolvedTypeReferenceDirective, + ResolvedTypeReferenceDirectiveWithFailedLookupLocations, resolvePackageNameToPackageJson, returnFalse, returnTrue, @@ -136,6 +133,7 @@ import { SourceFile, SourceMapper, startsWith, + StringLiteralLike, stripQuotes, StructureIsReused, SymlinkCache, @@ -144,7 +142,6 @@ import { toPath, tracing, TypeAcquisition, - TypeReferenceDirectiveResolutionInfo, updateErrorForNoInputFiles, updateMissingFilePathsWatch, WatchDirectoryFlags, @@ -554,7 +551,7 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo if (this.program && !this.symlinks.hasProcessedResolutions()) { this.symlinks.setSymlinksFromResolutions( this.program.getSourceFiles(), - this.program.getResolvedTypeReferenceDirectives()); + this.program.getAutomaticTypeDirectiveResolutions()); } return this.symlinks; } @@ -666,20 +663,25 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo return !this.isWatchedMissingFile(path) && this.directoryStructureHost.fileExists(file); } - resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference, _options?: CompilerOptions, containingSourceFile?: SourceFile, resolutionInfo?: ModuleResolutionInfo): (ResolvedModuleFull | undefined)[] { - return this.resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile, resolutionInfo); + /** @internal */ + resolveModuleNameLiterals(moduleLiterals: readonly StringLiteralLike[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile: SourceFile, reusedNames: readonly StringLiteralLike[] | undefined): readonly ResolvedModuleWithFailedLookupLocations[] { + return this.resolutionCache.resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options, containingSourceFile, reusedNames); } getModuleResolutionCache(): ModuleResolutionCache | undefined { return this.resolutionCache.getModuleResolutionCache(); } - getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string, resolutionMode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations | undefined { - return this.resolutionCache.getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode); - } - - resolveTypeReferenceDirectives(typeDirectiveNames: string[] | FileReference[], containingFile: string, redirectedReference?: ResolvedProjectReference, _options?: CompilerOptions, containingFileMode?: ResolutionMode, resolutionInfo?: TypeReferenceDirectiveResolutionInfo): (ResolvedTypeReferenceDirective | undefined)[] { - return this.resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode, resolutionInfo); + /** @internal */ + resolveTypeReferenceDirectiveReferences(typeDirectiveReferences: readonly T[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile: SourceFile | undefined, reusedNames: readonly T[] | undefined): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[] { + return this.resolutionCache.resolveTypeReferenceDirectiveReferences( + typeDirectiveReferences, + containingFile, + redirectedReference, + options, + containingSourceFile, + reusedNames, + ); } directoryExists(path: string): boolean { @@ -2096,7 +2098,7 @@ function extractUnresolvedImportsFromSourceFile(file: SourceFile, ambientModules return getOrUpdate(cachedUnresolvedImportsPerFile, file.path, () => { if (!file.resolvedModules) return emptyArray; let unresolvedImports: string[] | undefined; - file.resolvedModules.forEach((resolvedModule, name) => { + file.resolvedModules.forEach(({ resolvedModule }, name) => { // pick unresolved non-relative names if ((!resolvedModule || !resolutionExtensionIsTSOrJson(resolvedModule.extension)) && !isExternalModuleNameRelative(name) && diff --git a/src/server/session.ts b/src/server/session.ts index ceb15519eb4..35623f9aa1f 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1578,15 +1578,13 @@ export class Session implements EventSender { if (entrypoints && some(entrypoints, e => project.toPath(e) === path)) { // This file was the main entrypoint of a package. Try to resolve that same package name with // the auxiliary project that only resolves to implementation files. - const [implementationResolution] = auxiliaryProject.resolveModuleNames([packageName], resolveFromFile); - return implementationResolution?.resolvedFileName; + return auxiliaryProject.resolutionCache.resolveSingleModuleNameWithoutWatching(packageName, resolveFromFile).resolvedModule?.resolvedFileName; } else { // It wasn't the main entrypoint but we are in node_modules. Try a subpath into the package. const pathToFileInPackage = fileName.substring(nodeModulesPathParts.packageRootIndex + 1); const specifier = `${packageName}/${removeFileExtension(pathToFileInPackage)}`; - const [implementationResolution] = auxiliaryProject.resolveModuleNames([specifier], resolveFromFile); - return implementationResolution?.resolvedFileName; + return auxiliaryProject.resolutionCache.resolveSingleModuleNameWithoutWatching(specifier, resolveFromFile).resolvedModule?.resolvedFileName; } } // We're not in node_modules, and we only get to this function if non-dts module resolution failed. diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 6e9a5570306..dad6d6f2dfa 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -959,7 +959,7 @@ export namespace Core { if (!options.implementations && isStringLiteralLike(node)) { if (isModuleSpecifierLike(node)) { const fileIncludeReasons = program.getFileIncludeReasons(); - const referencedFileName = node.getSourceFile().resolvedModules?.get(node.text, getModeForUsageLocation(node.getSourceFile(), node))?.resolvedFileName; + const referencedFileName = node.getSourceFile().resolvedModules?.get(node.text, getModeForUsageLocation(node.getSourceFile(), node))?.resolvedModule?.resolvedFileName; const referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; if (referencedFile) { return [{ definition: { type: DefinitionKind.String, node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || emptyArray }]; diff --git a/src/services/getEditsForFileRename.ts b/src/services/getEditsForFileRename.ts index e8c7f4c2bd1..4d87384d5a4 100644 --- a/src/services/getEditsForFileRename.ts +++ b/src/services/getEditsForFileRename.ts @@ -248,9 +248,9 @@ function getSourceFileToImport( } else { const mode = getModeForUsageLocation(importingSourceFile, importLiteral); - const resolved = host.resolveModuleNames - ? host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode) - : program.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode); + const resolved = host.resolveModuleNameLiterals || !host.resolveModuleNames ? + importingSourceFile.resolvedModules?.get(importLiteral.text, mode) : + host.getResolvedModuleWithFailedLookupLocationsFromCache && host.getResolvedModuleWithFailedLookupLocationsFromCache(importLiteral.text, importingSourceFile.fileName, mode); return getSourceFileToImportFromResolved(importLiteral, resolved, oldToNew, program.getSourceFiles()); } } diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index 47be1d6781c..e5fbe7f3bb1 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -161,7 +161,7 @@ export function getDefinitionAtPosition(program: Program, sourceFile: SourceFile if (!symbol && isModuleSpecifierLike(fallbackNode)) { // We couldn't resolve the module specifier as an external module, but it could // be that module resolution succeeded but the target was not a module. - const ref = sourceFile.resolvedModules?.get(fallbackNode.text, getModeForUsageLocation(sourceFile, fallbackNode)); + const ref = sourceFile.resolvedModules?.get(fallbackNode.text, getModeForUsageLocation(sourceFile, fallbackNode))?.resolvedModule; if (ref) { return [{ name: fallbackNode.text, @@ -300,7 +300,7 @@ export function getReferenceAtPosition(sourceFile: SourceFile, position: number, const typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { - const reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName, typeReferenceDirective.resolutionMode || sourceFile.impliedNodeFormat); + const reference = program.getResolvedTypeReferenceDirectives().get(typeReferenceDirective.fileName, typeReferenceDirective.resolutionMode || sourceFile.impliedNodeFormat)?.resolvedTypeReferenceDirective; const file = reference && program.getSourceFile(reference.resolvedFileName!); // TODO:GH#18217 return file && { reference: typeReferenceDirective, fileName: file.fileName, file, unverified: false }; } @@ -314,7 +314,7 @@ export function getReferenceAtPosition(sourceFile: SourceFile, position: number, if (sourceFile.resolvedModules?.size()) { const node = getTouchingToken(sourceFile, position); if (isModuleSpecifierLike(node) && isExternalModuleNameRelative(node.text) && sourceFile.resolvedModules.has(node.text, getModeForUsageLocation(sourceFile, node))) { - const verifiedFileName = sourceFile.resolvedModules.get(node.text, getModeForUsageLocation(sourceFile, node))?.resolvedFileName; + const verifiedFileName = sourceFile.resolvedModules.get(node.text, getModeForUsageLocation(sourceFile, node))?.resolvedModule?.resolvedFileName; const fileName = verifiedFileName || resolvePath(getDirectoryPath(sourceFile.fileName), node.text); return { file: program.getSourceFile(fileName), diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 0cca4a93f91..9b59debc104 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -461,7 +461,7 @@ export function findModuleReferences(program: Program, sourceFiles: readonly Sou } } for (const ref of referencingFile.typeReferenceDirectives) { - const referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName, ref.resolutionMode || referencingFile.impliedNodeFormat); + const referenced = program.getResolvedTypeReferenceDirectives().get(ref.fileName, ref.resolutionMode || referencingFile.impliedNodeFormat)?.resolvedTypeReferenceDirective; if (referenced !== undefined && referenced.resolvedFileName === (searchSourceFile as SourceFile).fileName) { refs.push({ kind: "reference", referencingFile, ref }); } diff --git a/src/services/services.ts b/src/services/services.ts index 374d59223a2..723f1e9b774 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -253,9 +253,9 @@ import { RenameInfo, RenameInfoOptions, RenameLocation, - ResolvedModuleFull, + ResolvedModuleWithFailedLookupLocations, ResolvedProjectReference, - ResolvedTypeReferenceDirective, + ResolvedTypeReferenceDirectiveWithFailedLookupLocations, returnFalse, scanner, ScriptElementKind, @@ -1029,8 +1029,8 @@ class SourceFileObject extends NodeObject implements SourceFile { public languageVariant!: LanguageVariant; public identifiers!: Map; public nameTable: UnderscoreEscapedMap | undefined; - public resolvedModules: ModeAwareCache | undefined; - public resolvedTypeReferenceDirectiveNames!: ModeAwareCache; + public resolvedModules: ModeAwareCache | undefined; + public resolvedTypeReferenceDirectiveNames!: ModeAwareCache; public imports!: readonly StringLiteralLike[]; public moduleAugmentations!: StringLiteral[]; private namedDeclarations: Map | undefined; @@ -1667,6 +1667,8 @@ export function createLanguageService( getModuleResolutionCache: maybeBind(host, host.getModuleResolutionCache), createHash: maybeBind(host, host.createHash), resolveTypeReferenceDirectives: maybeBind(host, host.resolveTypeReferenceDirectives), + resolveModuleNameLiterals: maybeBind(host, host.resolveModuleNameLiterals), + resolveTypeReferenceDirectiveReferences: maybeBind(host, host.resolveTypeReferenceDirectiveReferences), useSourceOfProjectReferenceRedirect: maybeBind(host, host.useSourceOfProjectReferenceRedirect), getParsedCommandLine, }; diff --git a/src/services/types.ts b/src/services/types.ts index ee6c8a22ba4..f3ddf1bf715 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -16,7 +16,6 @@ import { LineAndCharacter, MinimalResolutionCacheHost, ModuleResolutionCache, - ModuleResolutionInfo, ModuleSpecifierCache, ParsedCommandLine, Path, @@ -27,17 +26,18 @@ import { ResolvedModuleWithFailedLookupLocations, ResolvedProjectReference, ResolvedTypeReferenceDirective, + ResolvedTypeReferenceDirectiveWithFailedLookupLocations, ScriptKind, SourceFile, SourceFileLike, SourceMapper, + StringLiteralLike, Symbol, SymlinkCache, TextChangeRange, textChanges, TextRange, TextSpan, - TypeReferenceDirectiveResolutionInfo, UserPreferences, } from "./_namespaces/ts"; @@ -357,9 +357,27 @@ export interface LanguageServiceHost extends GetEffectiveTypeRootsHost, MinimalR * * If this is implemented, `getResolvedModuleWithFailedLookupLocationsFromCache` should be too. */ - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile, resolutionInfo?: ModuleResolutionInfo): (ResolvedModule | undefined)[]; + /** @deprecated supply resolveModuleNameLiterals instead for resolution that can handle newer resolution modes like nodenext */ + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string, resolutionMode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations | undefined; - resolveTypeReferenceDirectives?(typeDirectiveNames: string[] | FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode, resolutionInfo?: TypeReferenceDirectiveResolutionInfo): (ResolvedTypeReferenceDirective | undefined)[]; + /** @deprecated supply resolveTypeReferenceDirectiveReferences instead for resolution that can handle newer resolution modes like nodenext */ + resolveTypeReferenceDirectives?(typeDirectiveNames: string[] | FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode): (ResolvedTypeReferenceDirective | undefined)[]; + resolveModuleNameLiterals?( + moduleLiterals: readonly StringLiteralLike[], + containingFile: string, + redirectedReference: ResolvedProjectReference | undefined, + options: CompilerOptions, + containingSourceFile: SourceFile, + reusedNames: readonly StringLiteralLike[] | undefined, + ): readonly ResolvedModuleWithFailedLookupLocations[]; + resolveTypeReferenceDirectiveReferences?( + typeDirectiveReferences: readonly T[], + containingFile: string, + redirectedReference: ResolvedProjectReference | undefined, + options: CompilerOptions, + containingSourceFile: SourceFile | undefined, + reusedNames: readonly T[] | undefined + ): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[]; /** @internal */ hasInvalidatedResolutions?: HasInvalidatedResolutions; /** @internal */ hasChangedAutomaticTypeDirectiveNames?: HasChangedAutomaticTypeDirectiveNames; /** @internal */ getGlobalTypingsCacheLocation?(): string | undefined; diff --git a/src/testRunner/unittests/tscWatch/moduleResolution.ts b/src/testRunner/unittests/tscWatch/moduleResolution.ts index 4a198b652f5..92add355fde 100644 --- a/src/testRunner/unittests/tscWatch/moduleResolution.ts +++ b/src/testRunner/unittests/tscWatch/moduleResolution.ts @@ -1,4 +1,3 @@ -import * as ts from "../../_namespaces/ts"; import * as Utils from "../../_namespaces/Utils"; import { createWatchedSystem, @@ -117,10 +116,20 @@ describe("unittests:: tsc-watch:: moduleResolution", () => { export function thing(): void {} ` }, + { + path: `/user/username/projects/myproject/index2.ts`, + content: Utils.dedent` + export function thing(): void {} + ` + }, libFile ], { currentDirectory: "/user/username/projects/myproject" }), commandLineArgs: ["-w", "--traceResolution"], - changes: ts.emptyArray + changes: [{ + caption: "Add import to index2", + change: sys => sys.prependFile(`/user/username/projects/myproject/index2.ts`, `import * as me from "./index.js";`), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }] }); describe("package json file is edited", () => { diff --git a/src/testRunner/unittests/tsserver/getEditsForFileRename.ts b/src/testRunner/unittests/tsserver/getEditsForFileRename.ts index 71183160b5c..38ae46689f8 100644 --- a/src/testRunner/unittests/tsserver/getEditsForFileRename.ts +++ b/src/testRunner/unittests/tsserver/getEditsForFileRename.ts @@ -6,7 +6,6 @@ import { import { baselineTsserverLogs, createLoggerWithInMemoryLogs, - createProjectService, createSession, openFilesForSession, textSpanFromSubstring, @@ -28,13 +27,25 @@ describe("unittests:: tsserver:: getEditsForFileRename", () => { }; const host = createServerHost([userTs, newTs, tsconfig]); - const projectService = createProjectService(host); - projectService.openClientFile(userTs.path); - const project = projectService.configuredProjects.get(tsconfig.path)!; - - ts.Debug.assert(!!project.resolveModuleNames); - - const edits = project.getLanguageService().getEditsForFileRename("/old.ts", "/new.ts", ts.testFormatSettings, ts.emptyOptions); + const options: ts.CompilerOptions = {}; + const moduleResolutionCache = ts.createModuleResolutionCache(host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames), options); + const lsHost: ts.LanguageServiceHost = { + getCompilationSettings: () => options, + getScriptFileNames: () => [newTs.path, userTs.path], + getScriptVersion: fileName => host.readFile(fileName)!, + getScriptSnapshot: fileName => { + const text = host.readFile(fileName); + return text ? ts.ScriptSnapshot.fromString(text) : undefined; + }, + getCurrentDirectory: () => host.getCurrentDirectory(), + getDefaultLibFileName: options => ts.getDefaultLibFileName(options), + readFile: path => host.readFile(path), + fileExists: path => host.fileExists(path), + resolveModuleNames: (moduleNames, containingFile) => moduleNames.map(name => ts.resolveModuleName(name, containingFile, options, lsHost, moduleResolutionCache).resolvedModule), + getResolvedModuleWithFailedLookupLocationsFromCache: (moduleName, containingFile, mode) => moduleResolutionCache.getOrCreateCacheForDirectory(ts.getDirectoryPath(containingFile)).get(moduleName, mode), + }; + const service = ts.createLanguageService(lsHost); + const edits = service.getEditsForFileRename("/old.ts", "/new.ts", ts.testFormatSettings, ts.emptyOptions); assert.deepEqual(edits, [{ fileName: "/user.ts", textChanges: [{ diff --git a/src/testRunner/unittests/tsserver/symlinkCache.ts b/src/testRunner/unittests/tsserver/symlinkCache.ts index f93933499ce..e389efd319f 100644 --- a/src/testRunner/unittests/tsserver/symlinkCache.ts +++ b/src/testRunner/unittests/tsserver/symlinkCache.ts @@ -71,11 +71,13 @@ describe("unittests:: tsserver:: symlinkCache", () => { it("works for paths close to the root", () => { const cache = ts.createSymlinkCache("/", ts.createGetCanonicalFileName(/*useCaseSensitiveFileNames*/ false)); // Used to crash, #44953 - const map = ts.createModeAwareCache(); + const map = ts.createModeAwareCache(); map.set("foo", /*mode*/ undefined, { - primary: true, - originalPath: "/foo", - resolvedFileName: "/one/two/foo", + resolvedTypeReferenceDirective: { + primary: true, + originalPath: "/foo", + resolvedFileName: "/one/two/foo", + } }); cache.setSymlinksFromResolutions([], map); }); diff --git a/src/testRunner/unittests/tsserver/typingsInstaller.ts b/src/testRunner/unittests/tsserver/typingsInstaller.ts index 6c016e79cdb..0ba9c7de56e 100644 --- a/src/testRunner/unittests/tsserver/typingsInstaller.ts +++ b/src/testRunner/unittests/tsserver/typingsInstaller.ts @@ -1964,7 +1964,7 @@ describe("unittests:: tsserver:: typingsInstaller:: recomputing resolutions of u const foooPath = "/a/b/node_modules/fooo/index.d.ts"; function verifyResolvedModuleOfFooo(project: ts.server.Project) { ts.server.updateProjectIfDirty(project); - const foooResolution = project.getLanguageService().getProgram()!.getSourceFileByPath(appPath)!.resolvedModules!.get("fooo", /*mode*/ undefined)!; + const foooResolution = project.getLanguageService().getProgram()!.getSourceFileByPath(appPath)!.resolvedModules!.get("fooo", /*mode*/ undefined)!.resolvedModule!; assert.equal(foooResolution.resolvedFileName, foooPath); return foooResolution; } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index e3e8466ccd1..d9c8599b1a2 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3183,10 +3183,7 @@ declare namespace ts { readFile(fileName: string): string | undefined; writeFile(fileName: string, content: string): void; fileExists(file: string): boolean; - resolveModuleNames(moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference, _options?: CompilerOptions, containingSourceFile?: SourceFile, resolutionInfo?: ModuleResolutionInfo): (ResolvedModuleFull | undefined)[]; getModuleResolutionCache(): ModuleResolutionCache | undefined; - getResolvedModuleWithFailedLookupLocationsFromCache(moduleName: string, containingFile: string, resolutionMode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations | undefined; - resolveTypeReferenceDirectives(typeDirectiveNames: string[] | FileReference[], containingFile: string, redirectedReference?: ResolvedProjectReference, _options?: CompilerOptions, containingFileMode?: ResolutionMode, resolutionInfo?: TypeReferenceDirectiveResolutionInfo): (ResolvedTypeReferenceDirective | undefined)[]; directoryExists(path: string): boolean; getDirectories(path: string): string[]; log(s: string): void; @@ -7318,14 +7315,7 @@ declare namespace ts { } interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; - readonly failedLookupLocations: string[]; } - interface ResolutionInfo { - names: readonly T[]; - reusedNames: readonly T[] | undefined; - } - type ModuleResolutionInfo = ResolutionInfo; - type TypeReferenceDirectiveResolutionInfo = ResolutionInfo; interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; getSourceFileByPath?(fileName: string, path: Path, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; @@ -7338,15 +7328,20 @@ declare namespace ts { useCaseSensitiveFileNames(): boolean; getNewLine(): string; readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile, resolutionInfo?: ModuleResolutionInfo): (ResolvedModule | undefined)[]; + /** @deprecated supply resolveModuleNameLiterals instead for resolution that can handle newer resolution modes like nodenext */ + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; /** * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it */ getModuleResolutionCache?(): ModuleResolutionCache | undefined; /** + * @deprecated supply resolveTypeReferenceDirectiveReferences instead for resolution that can handle newer resolution modes like nodenext + * * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode | undefined, resolutionInfo?: TypeReferenceDirectiveResolutionInfo): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode): (ResolvedTypeReferenceDirective | undefined)[]; + resolveModuleNameLiterals?(moduleLiterals: readonly StringLiteralLike[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile: SourceFile, reusedNames: readonly StringLiteralLike[] | undefined): readonly ResolvedModuleWithFailedLookupLocations[]; + resolveTypeReferenceDirectiveReferences?(typeDirectiveReferences: readonly T[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile: SourceFile | undefined, reusedNames: readonly T[] | undefined): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[]; getEnvironmentVariable?(name: string): string | undefined; /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */ hasInvalidatedResolutions?(filePath: Path): boolean; @@ -9614,10 +9609,20 @@ declare namespace ts { trace?(s: string): void; /** If provided is used to get the environment variable */ getEnvironmentVariable?(name: string): string | undefined; - /** If provided, used to resolve the module names, otherwise typescript's default module resolution */ - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile, resolutionInfo?: ModuleResolutionInfo): (ResolvedModule | undefined)[]; - /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode, resolutionInfo?: TypeReferenceDirectiveResolutionInfo): (ResolvedTypeReferenceDirective | undefined)[]; + /** + * @deprecated supply resolveModuleNameLiterals instead for resolution that can handle newer resolution modes like nodenext + * + * If provided, used to resolve the module names, otherwise typescript's default module resolution + */ + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; + /** + * @deprecated supply resolveTypeReferenceDirectiveReferences instead for resolution that can handle newer resolution modes like nodenext + * + * If provided, used to resolve type reference directives, otherwise typescript's default resolution + */ + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode): (ResolvedTypeReferenceDirective | undefined)[]; + resolveModuleNameLiterals?(moduleLiterals: readonly StringLiteralLike[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile: SourceFile, reusedNames: readonly StringLiteralLike[] | undefined): readonly ResolvedModuleWithFailedLookupLocations[]; + resolveTypeReferenceDirectiveReferences?(typeDirectiveReferences: readonly T[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile: SourceFile | undefined, reusedNames: readonly T[] | undefined): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[]; /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */ hasInvalidatedResolutions?(filePath: Path): boolean; /** @@ -9849,9 +9854,13 @@ declare namespace ts { readFile(path: string, encoding?: string): string | undefined; fileExists(path: string): boolean; getTypeRootsVersion?(): number; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile, resolutionInfo?: ModuleResolutionInfo): (ResolvedModule | undefined)[]; + /** @deprecated supply resolveModuleNameLiterals instead for resolution that can handle newer resolution modes like nodenext */ + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string, resolutionMode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations | undefined; - resolveTypeReferenceDirectives?(typeDirectiveNames: string[] | FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode, resolutionInfo?: TypeReferenceDirectiveResolutionInfo): (ResolvedTypeReferenceDirective | undefined)[]; + /** @deprecated supply resolveTypeReferenceDirectiveReferences instead for resolution that can handle newer resolution modes like nodenext */ + resolveTypeReferenceDirectives?(typeDirectiveNames: string[] | FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode): (ResolvedTypeReferenceDirective | undefined)[]; + resolveModuleNameLiterals?(moduleLiterals: readonly StringLiteralLike[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile: SourceFile, reusedNames: readonly StringLiteralLike[] | undefined): readonly ResolvedModuleWithFailedLookupLocations[]; + resolveTypeReferenceDirectiveReferences?(typeDirectiveReferences: readonly T[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile: SourceFile | undefined, reusedNames: readonly T[] | undefined): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[]; getDirectories?(directoryName: string): string[]; /** * Gets a set of custom transformers to use during emit. diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 7bc06c330da..a097a08654d 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3382,14 +3382,7 @@ declare namespace ts { } interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; - readonly failedLookupLocations: string[]; } - interface ResolutionInfo { - names: readonly T[]; - reusedNames: readonly T[] | undefined; - } - type ModuleResolutionInfo = ResolutionInfo; - type TypeReferenceDirectiveResolutionInfo = ResolutionInfo; interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; getSourceFileByPath?(fileName: string, path: Path, languageVersionOrOptions: ScriptTarget | CreateSourceFileOptions, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; @@ -3402,15 +3395,20 @@ declare namespace ts { useCaseSensitiveFileNames(): boolean; getNewLine(): string; readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile, resolutionInfo?: ModuleResolutionInfo): (ResolvedModule | undefined)[]; + /** @deprecated supply resolveModuleNameLiterals instead for resolution that can handle newer resolution modes like nodenext */ + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; /** * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it */ getModuleResolutionCache?(): ModuleResolutionCache | undefined; /** + * @deprecated supply resolveTypeReferenceDirectiveReferences instead for resolution that can handle newer resolution modes like nodenext + * * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode | undefined, resolutionInfo?: TypeReferenceDirectiveResolutionInfo): (ResolvedTypeReferenceDirective | undefined)[]; + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode): (ResolvedTypeReferenceDirective | undefined)[]; + resolveModuleNameLiterals?(moduleLiterals: readonly StringLiteralLike[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile: SourceFile, reusedNames: readonly StringLiteralLike[] | undefined): readonly ResolvedModuleWithFailedLookupLocations[]; + resolveTypeReferenceDirectiveReferences?(typeDirectiveReferences: readonly T[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile: SourceFile | undefined, reusedNames: readonly T[] | undefined): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[]; getEnvironmentVariable?(name: string): string | undefined; /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */ hasInvalidatedResolutions?(filePath: Path): boolean; @@ -5678,10 +5676,20 @@ declare namespace ts { trace?(s: string): void; /** If provided is used to get the environment variable */ getEnvironmentVariable?(name: string): string | undefined; - /** If provided, used to resolve the module names, otherwise typescript's default module resolution */ - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile, resolutionInfo?: ModuleResolutionInfo): (ResolvedModule | undefined)[]; - /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ - resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode, resolutionInfo?: TypeReferenceDirectiveResolutionInfo): (ResolvedTypeReferenceDirective | undefined)[]; + /** + * @deprecated supply resolveModuleNameLiterals instead for resolution that can handle newer resolution modes like nodenext + * + * If provided, used to resolve the module names, otherwise typescript's default module resolution + */ + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; + /** + * @deprecated supply resolveTypeReferenceDirectiveReferences instead for resolution that can handle newer resolution modes like nodenext + * + * If provided, used to resolve type reference directives, otherwise typescript's default resolution + */ + resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode): (ResolvedTypeReferenceDirective | undefined)[]; + resolveModuleNameLiterals?(moduleLiterals: readonly StringLiteralLike[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile: SourceFile, reusedNames: readonly StringLiteralLike[] | undefined): readonly ResolvedModuleWithFailedLookupLocations[]; + resolveTypeReferenceDirectiveReferences?(typeDirectiveReferences: readonly T[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile: SourceFile | undefined, reusedNames: readonly T[] | undefined): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[]; /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */ hasInvalidatedResolutions?(filePath: Path): boolean; /** @@ -5986,9 +5994,13 @@ declare namespace ts { readFile(path: string, encoding?: string): string | undefined; fileExists(path: string): boolean; getTypeRootsVersion?(): number; - resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile, resolutionInfo?: ModuleResolutionInfo): (ResolvedModule | undefined)[]; + /** @deprecated supply resolveModuleNameLiterals instead for resolution that can handle newer resolution modes like nodenext */ + resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string, resolutionMode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations | undefined; - resolveTypeReferenceDirectives?(typeDirectiveNames: string[] | FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode, resolutionInfo?: TypeReferenceDirectiveResolutionInfo): (ResolvedTypeReferenceDirective | undefined)[]; + /** @deprecated supply resolveTypeReferenceDirectiveReferences instead for resolution that can handle newer resolution modes like nodenext */ + resolveTypeReferenceDirectives?(typeDirectiveNames: string[] | FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: ResolutionMode): (ResolvedTypeReferenceDirective | undefined)[]; + resolveModuleNameLiterals?(moduleLiterals: readonly StringLiteralLike[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile: SourceFile, reusedNames: readonly StringLiteralLike[] | undefined): readonly ResolvedModuleWithFailedLookupLocations[]; + resolveTypeReferenceDirectiveReferences?(typeDirectiveReferences: readonly T[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile: SourceFile | undefined, reusedNames: readonly T[] | undefined): readonly ResolvedTypeReferenceDirectiveWithFailedLookupLocations[]; getDirectories?(directoryName: string): string[]; /** * Gets a set of custom transformers to use during emit. 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 520a6a54583..7fc2f4fe640 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 @@ -13,10 +13,7 @@ Resolution:: { "resolvedFileName": "/root/folder2/file2.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "./file3" from /root/folder2/file2.ts @@ -25,10 +22,7 @@ Resolution:: { "resolvedFileName": "/root/folder2/file3.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "/root/folder1/file1" from /root/folder2/file2.ts @@ -37,10 +31,7 @@ Resolution:: { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "folder2/file2" from /root/folder1/file1.ts @@ -49,10 +40,7 @@ Resolution:: { "resolvedFileName": "/root/folder2/file2.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "./file3" from /root/folder2/file2.ts @@ -61,10 +49,7 @@ Resolution:: { "resolvedFileName": "/root/folder2/file3.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "/root/folder1/file1" from /root/folder2/file2.ts @@ -73,10 +58,7 @@ Resolution:: { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } //// [/root/folder1/file1.ts] @@ -94,10 +76,7 @@ Resolution:: { "resolvedFileName": "/root/folder2/file2.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "./file3" from /root/folder2/file2.ts with host that doesnt have directoryExists @@ -106,10 +85,7 @@ Resolution:: { "resolvedFileName": "/root/folder2/file3.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "/root/folder1/file1" from /root/folder2/file2.ts with host that doesnt have directoryExists @@ -118,10 +94,7 @@ Resolution:: { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "folder2/file2" from /root/folder1/file1.ts with host that doesnt have directoryExists @@ -130,10 +103,7 @@ Resolution:: { "resolvedFileName": "/root/folder2/file2.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "./file3" from /root/folder2/file2.ts with host that doesnt have directoryExists @@ -142,10 +112,7 @@ Resolution:: { "resolvedFileName": "/root/folder2/file3.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "/root/folder1/file1" from /root/folder2/file2.ts with host that doesnt have directoryExists @@ -154,8 +121,5 @@ Resolution:: { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } diff --git a/tests/baselines/reference/moduleResolution/classic-baseUrl-path-mappings.js b/tests/baselines/reference/moduleResolution/classic-baseUrl-path-mappings.js index 67446c13fdf..48a7deab2e2 100644 --- a/tests/baselines/reference/moduleResolution/classic-baseUrl-path-mappings.js +++ b/tests/baselines/reference/moduleResolution/classic-baseUrl-path-mappings.js @@ -13,10 +13,7 @@ Resolution:: { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "folder1/file2" from /root/folder1/main.ts with host that doesnt have directoryExists @@ -30,9 +27,7 @@ Resolution:: { "/root/folder1/file2.ts", "/root/folder1/file2.tsx", "/root/folder1/file2.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "/rooted/folder1/file2" from /root/folder1/main.ts with host that doesnt have directoryExists @@ -41,10 +36,7 @@ Resolution:: { "resolvedFileName": "/root/generated/folder1/file2.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "folder1/file3" from /root/folder1/main.ts with host that doesnt have directoryExists @@ -67,7 +59,5 @@ Resolution:: { "/root/folder1/file3.ts", "/root/folder1/file3.tsx", "/root/folder1/file3.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } diff --git a/tests/baselines/reference/moduleResolution/classic-baseUrl.js b/tests/baselines/reference/moduleResolution/classic-baseUrl.js index ac6b67c8bb1..9d1587a3c7b 100644 --- a/tests/baselines/reference/moduleResolution/classic-baseUrl.js +++ b/tests/baselines/reference/moduleResolution/classic-baseUrl.js @@ -13,10 +13,7 @@ Resolution:: { "resolvedFileName": "/root/x/m1.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "m2" from /root/a/b/main.ts @@ -39,9 +36,7 @@ Resolution:: { "/root/m2.ts", "/root/m2.tsx", "/root/m2.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } //// [/root/a/b/main.ts] @@ -59,10 +54,7 @@ Resolution:: { "resolvedFileName": "/root/x/m1.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "m2" from /root/a/b/main.ts with host that doesnt have directoryExists @@ -85,7 +77,5 @@ Resolution:: { "/root/m2.ts", "/root/m2.tsx", "/root/m2.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } diff --git a/tests/baselines/reference/moduleResolution/classic-rootDirs.js b/tests/baselines/reference/moduleResolution/classic-rootDirs.js index 40cb12c8eab..7e7d2178995 100644 --- a/tests/baselines/reference/moduleResolution/classic-rootDirs.js +++ b/tests/baselines/reference/moduleResolution/classic-rootDirs.js @@ -21,9 +21,7 @@ Resolution:: { "/root/folder1/file2.ts", "/root/folder1/file2.tsx", "/root/folder1/file2.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "../folder1/file1" from /root/generated/folder2/file3.ts with host that doesnt have directoryExists @@ -37,9 +35,7 @@ Resolution:: { "/root/generated/folder1/file1.ts", "/root/generated/folder1/file1.tsx", "/root/generated/folder1/file1.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "folder1/file1_1" from /root/generated/folder2/file3.ts with host that doesnt have directoryExists @@ -59,7 +55,5 @@ Resolution:: { "/root/folder1/file1_1.ts", "/root/folder1/file1_1.tsx", "/root/folder1/file1_1.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } diff --git a/tests/baselines/reference/moduleResolution/nested-node-module.js b/tests/baselines/reference/moduleResolution/nested-node-module.js index ba9c0a14807..3edb344426c 100644 --- a/tests/baselines/reference/moduleResolution/nested-node-module.js +++ b/tests/baselines/reference/moduleResolution/nested-node-module.js @@ -21,8 +21,7 @@ Resolution:: { ], "affectingLocations": [ "/root/src/libs/guid/package.json" - ], - "resolutionDiagnostics": [] + ] } //// [/root/src/app.ts] @@ -48,6 +47,5 @@ Resolution:: { ], "affectingLocations": [ "/root/src/libs/guid/package.json" - ], - "resolutionDiagnostics": [] + ] } diff --git a/tests/baselines/reference/moduleResolution/node-baseUrl-path-mappings.js b/tests/baselines/reference/moduleResolution/node-baseUrl-path-mappings.js index d28fcbea219..a117b795cc2 100644 --- a/tests/baselines/reference/moduleResolution/node-baseUrl-path-mappings.js +++ b/tests/baselines/reference/moduleResolution/node-baseUrl-path-mappings.js @@ -25,10 +25,7 @@ Resolution:: { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "folder1/file2" from /root/folder1/main.ts @@ -46,9 +43,7 @@ Resolution:: { "/root/folder1/file2/index.ts", "/root/folder1/file2/index.tsx", "/root/folder1/file2/index.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "/rooted/folder1/file2" from /root/folder1/main.ts @@ -57,10 +52,7 @@ Resolution:: { "resolvedFileName": "/root/generated/folder1/file2.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "folder2/file3" from /root/folder1/main.ts @@ -84,9 +76,7 @@ Resolution:: { "/root/generated/folder2/file3/package.json", "/root/generated/folder2/file3/index.ts", "/root/generated/folder2/file3/index.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "folder2/file4" from /root/folder1/main.ts @@ -110,8 +100,7 @@ Resolution:: { ], "affectingLocations": [ "/root/generated/folder2/file4/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "somefolder/file5" from /root/folder1/main.ts @@ -128,9 +117,7 @@ Resolution:: { "/root/someanotherfolder/file5/package.json", "/root/someanotherfolder/file5/index.ts", "/root/someanotherfolder/file5/index.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "file6" from /root/folder1/main.ts @@ -166,9 +153,7 @@ Resolution:: { "/root/folder1/node_modules/@types/file6.d.ts", "/root/folder1/node_modules/@types/file6/index.d.ts", "/root/node_modules/file6/package.json" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } //// [/root/folder1/file1.ts] @@ -198,10 +183,7 @@ Resolution:: { "resolvedFileName": "/root/folder1/file1.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "folder1/file2" from /root/folder1/main.ts with host that doesnt have directoryExists @@ -219,9 +201,7 @@ Resolution:: { "/root/folder1/file2/index.ts", "/root/folder1/file2/index.tsx", "/root/folder1/file2/index.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "/rooted/folder1/file2" from /root/folder1/main.ts with host that doesnt have directoryExists @@ -230,10 +210,7 @@ Resolution:: { "resolvedFileName": "/root/generated/folder1/file2.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "folder2/file3" from /root/folder1/main.ts with host that doesnt have directoryExists @@ -257,9 +234,7 @@ Resolution:: { "/root/generated/folder2/file3/package.json", "/root/generated/folder2/file3/index.ts", "/root/generated/folder2/file3/index.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "folder2/file4" from /root/folder1/main.ts with host that doesnt have directoryExists @@ -283,8 +258,7 @@ Resolution:: { ], "affectingLocations": [ "/root/generated/folder2/file4/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "somefolder/file5" from /root/folder1/main.ts with host that doesnt have directoryExists @@ -301,9 +275,7 @@ Resolution:: { "/root/someanotherfolder/file5/package.json", "/root/someanotherfolder/file5/index.ts", "/root/someanotherfolder/file5/index.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "file6" from /root/folder1/main.ts with host that doesnt have directoryExists @@ -339,7 +311,5 @@ Resolution:: { "/root/folder1/node_modules/@types/file6.d.ts", "/root/folder1/node_modules/@types/file6/index.d.ts", "/root/node_modules/file6/package.json" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } diff --git a/tests/baselines/reference/moduleResolution/node-baseUrl.js b/tests/baselines/reference/moduleResolution/node-baseUrl.js index 9b786b1bb6e..230672d2b95 100644 --- a/tests/baselines/reference/moduleResolution/node-baseUrl.js +++ b/tests/baselines/reference/moduleResolution/node-baseUrl.js @@ -22,10 +22,7 @@ Resolution:: { "resolvedFileName": "/root/m1.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "m2" from /root/a/b/main.ts @@ -42,9 +39,7 @@ Resolution:: { "/root/m2/package.json", "/root/m2/index.ts", "/root/m2/index.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "m3" from /root/a/b/main.ts @@ -61,8 +56,7 @@ Resolution:: { ], "affectingLocations": [ "/root/m3/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "m4" from /root/a/b/main.ts @@ -101,9 +95,7 @@ Resolution:: { "/root/a/node_modules/@types/m4.d.ts", "/root/a/node_modules/@types/m4/index.d.ts", "/root/node_modules/m4/package.json" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } //// [/root/a/b/main.ts] @@ -130,10 +122,7 @@ Resolution:: { "resolvedFileName": "/root/m1.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "m2" from /root/a/b/main.ts with host that doesnt have directoryExists @@ -150,9 +139,7 @@ Resolution:: { "/root/m2/package.json", "/root/m2/index.ts", "/root/m2/index.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "m3" from /root/a/b/main.ts with host that doesnt have directoryExists @@ -169,8 +156,7 @@ Resolution:: { ], "affectingLocations": [ "/root/m3/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "m4" from /root/a/b/main.ts with host that doesnt have directoryExists @@ -209,7 +195,5 @@ Resolution:: { "/root/a/node_modules/@types/m4.d.ts", "/root/a/node_modules/@types/m4/index.d.ts", "/root/node_modules/m4/package.json" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } diff --git a/tests/baselines/reference/moduleResolution/node-rootDirs.js b/tests/baselines/reference/moduleResolution/node-rootDirs.js index 49fd78c947f..dc033c530c7 100644 --- a/tests/baselines/reference/moduleResolution/node-rootDirs.js +++ b/tests/baselines/reference/moduleResolution/node-rootDirs.js @@ -25,9 +25,7 @@ Resolution:: { "/root/folder1/file2/index.ts", "/root/folder1/file2/index.tsx", "/root/folder1/file2/index.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "../folder1/file1" from /root/generated/folder2/file3.ts @@ -45,9 +43,7 @@ Resolution:: { "/root/generated/folder1/file1/index.ts", "/root/generated/folder1/file1/index.tsx", "/root/generated/folder1/file1/index.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "../folder1/file1_1" from /root/generated/folder2/file3.ts @@ -71,9 +67,7 @@ Resolution:: { "/root/folder1/file1_1/package.json", "/root/folder1/file1_1/index.ts", "/root/folder1/file1_1/index.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } //// [/root/folder1/file1.ts] @@ -103,9 +97,7 @@ Resolution:: { "/root/folder1/file2/index.ts", "/root/folder1/file2/index.tsx", "/root/folder1/file2/index.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "../folder1/file1" from /root/generated/folder2/file3.ts with host that doesnt have directoryExists @@ -123,9 +115,7 @@ Resolution:: { "/root/generated/folder1/file1/index.ts", "/root/generated/folder1/file1/index.tsx", "/root/generated/folder1/file1/index.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "../folder1/file1_1" from /root/generated/folder2/file3.ts with host that doesnt have directoryExists @@ -149,7 +139,5 @@ Resolution:: { "/root/folder1/file1_1/package.json", "/root/folder1/file1_1/index.ts", "/root/folder1/file1_1/index.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } 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 8ca68184a2e..14229a28387 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 @@ -48,9 +48,7 @@ Resolution:: { "/a/node_modules/foo.d.ts", "/a/node_modules/foo/index.ts", "/a/node_modules/foo/index.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "foo" from /a/node_modules/b/c/node_modules/d/e.ts with host that doesnt have directoryExists @@ -103,7 +101,5 @@ Resolution:: { "/a/node_modules/foo.d.ts", "/a/node_modules/foo/index.ts", "/a/node_modules/foo/index.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } 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 da517407b2b..9fc065864bb 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 @@ -33,9 +33,7 @@ Resolution:: { "/a/b/c/node_modules/@types/foo.d.ts", "/a/b/c/node_modules/@types/foo/index.d.ts", "/a/b/node_modules/foo/package.json" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "foo" from /a/b/c/d/e.ts with host that doesnt have directoryExists @@ -73,7 +71,5 @@ Resolution:: { "/a/b/c/node_modules/@types/foo.d.ts", "/a/b/c/node_modules/@types/foo/index.d.ts", "/a/b/node_modules/foo/package.json" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } 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 25338e92e47..48bf3770870 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 @@ -35,9 +35,7 @@ Resolution:: { "/a/b/node_modules/foo/package.json", "/a/b/node_modules/foo.ts", "/a/b/node_modules/foo.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "foo" from /a/b/c/d/e.ts with host that doesnt have directoryExists @@ -77,7 +75,5 @@ Resolution:: { "/a/b/node_modules/foo/package.json", "/a/b/node_modules/foo.ts", "/a/b/node_modules/foo.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } diff --git a/tests/baselines/reference/moduleResolution/non-relative-preserveSymlinks.js b/tests/baselines/reference/moduleResolution/non-relative-preserveSymlinks.js index ef68b82c1ed..5668982afcc 100644 --- a/tests/baselines/reference/moduleResolution/non-relative-preserveSymlinks.js +++ b/tests/baselines/reference/moduleResolution/non-relative-preserveSymlinks.js @@ -24,8 +24,7 @@ Resolution:: { ], "affectingLocations": [ "/app/node_modules/linked/package.json" - ], - "resolutionDiagnostics": [] + ] } //// [/linked/index.d.ts] @@ -53,6 +52,5 @@ Resolution:: { ], "affectingLocations": [ "/app/node_modules/linked/package.json" - ], - "resolutionDiagnostics": [] + ] } 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 6c209264fec..5ed2351fe02 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 @@ -34,8 +34,7 @@ Resolution:: { ], "affectingLocations": [ "/app/node_modules/linked/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "linked" from /app/lib/main.ts @@ -76,6 +75,5 @@ Resolution:: { ], "affectingLocations": [ "/app/node_modules/linked/package.json" - ], - "resolutionDiagnostics": [] + ] } 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 905354c32cd..dcc6faae386 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 @@ -32,8 +32,7 @@ Resolution:: { ], "affectingLocations": [ "/sub/node_modules/a/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "a" from /sub/foo.ts @@ -62,8 +61,7 @@ Resolution:: { ], "affectingLocations": [ "/sub/node_modules/a/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "a" from /foo.ts @@ -84,7 +82,5 @@ Resolution:: { "/node_modules/a.jsx", "/node_modules/a/index.js", "/node_modules/a/index.jsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } 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 441de892edc..d13fa757ba9 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 @@ -30,8 +30,7 @@ Resolution:: { ], "affectingLocations": [ "/a/b/foo/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "./foo" from /a/b/c.ts with host that doesnt have directoryExists @@ -66,6 +65,5 @@ Resolution:: { ], "affectingLocations": [ "/a/b/foo/package.json" - ], - "resolutionDiagnostics": [] + ] } 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 1313664721b..f23570eb035 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 @@ -36,8 +36,7 @@ Resolution:: { ], "affectingLocations": [ "/node_modules/b/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "b" from /a/b.ts with typings: ["a","b"] with host that doesnt have directoryExists @@ -78,8 +77,7 @@ Resolution:: { ], "affectingLocations": [ "/node_modules/b/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "b" from /a/b.ts with typings: {"a":"b"} @@ -120,8 +118,7 @@ Resolution:: { ], "affectingLocations": [ "/node_modules/b/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "b" from /a/b.ts with typings: {"a":"b"} with host that doesnt have directoryExists @@ -162,8 +159,7 @@ Resolution:: { ], "affectingLocations": [ "/node_modules/b/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "b" from /a/b.ts with typings: true @@ -204,8 +200,7 @@ Resolution:: { ], "affectingLocations": [ "/node_modules/b/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "b" from /a/b.ts with typings: true with host that doesnt have directoryExists @@ -246,8 +241,7 @@ Resolution:: { ], "affectingLocations": [ "/node_modules/b/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "b" from /a/b.ts with typings: null @@ -288,8 +282,7 @@ Resolution:: { ], "affectingLocations": [ "/node_modules/b/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "b" from /a/b.ts with typings: null with host that doesnt have directoryExists @@ -330,8 +323,7 @@ Resolution:: { ], "affectingLocations": [ "/node_modules/b/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "b" from /a/b.ts with typings: undefined @@ -372,8 +364,7 @@ Resolution:: { ], "affectingLocations": [ "/node_modules/b/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "b" from /a/b.ts with typings: undefined with host that doesnt have directoryExists @@ -414,6 +405,5 @@ Resolution:: { ], "affectingLocations": [ "/node_modules/b/package.json" - ], - "resolutionDiagnostics": [] + ] } 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 2c8937052e7..05cffbff74a 100644 --- a/tests/baselines/reference/moduleResolution/relative-module-name-as-directory.js +++ b/tests/baselines/reference/moduleResolution/relative-module-name-as-directory.js @@ -21,8 +21,7 @@ Resolution:: { ], "affectingLocations": [ "/a/b/c/bar/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "./bar" from /a/b/c/d.ts with typings: c/d/e.d.ts with host that doesnt have directoryExists @@ -48,8 +47,7 @@ Resolution:: { ], "affectingLocations": [ "/a/b/c/bar/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "../../bar" from /a/b/c/d.ts with typings: e.d.ts @@ -75,8 +73,7 @@ Resolution:: { ], "affectingLocations": [ "/a/bar/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "../../bar" from /a/b/c/d.ts with typings: e.d.ts with host that doesnt have directoryExists @@ -102,8 +99,7 @@ Resolution:: { ], "affectingLocations": [ "/a/bar/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "/bar" from /a/b/c/d.ts with typings: e.d.ts @@ -129,8 +125,7 @@ Resolution:: { ], "affectingLocations": [ "/bar/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "/bar" from /a/b/c/d.ts with typings: e.d.ts with host that doesnt have directoryExists @@ -156,8 +151,7 @@ Resolution:: { ], "affectingLocations": [ "/bar/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "c:/bar" from c:/a/b/c/d.ts with typings: e.d.ts @@ -183,8 +177,7 @@ Resolution:: { ], "affectingLocations": [ "c:/bar/package.json" - ], - "resolutionDiagnostics": [] + ] } Resolving "c:/bar" from c:/a/b/c/d.ts with typings: e.d.ts with host that doesnt have directoryExists @@ -210,6 +203,5 @@ Resolution:: { ], "affectingLocations": [ "c:/bar/package.json" - ], - "resolutionDiagnostics": [] + ] } 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 f39c056c2b0..a64b27f5761 100644 --- a/tests/baselines/reference/moduleResolution/relative-module-name-as-file.js +++ b/tests/baselines/reference/moduleResolution/relative-module-name-as-file.js @@ -11,10 +11,7 @@ Resolution:: { "resolvedFileName": "/foo/bar/foo.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "./foo" from /foo/bar/baz.ts when module has extension: .ts with host that doesnt have directoryExists @@ -29,10 +26,7 @@ Resolution:: { "resolvedFileName": "/foo/bar/foo.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "./foo" from /foo/bar/baz.ts when module has extension: .tsx @@ -50,9 +44,7 @@ Resolution:: { }, "failedLookupLocations": [ "/foo/bar/foo.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "./foo" from /foo/bar/baz.ts when module has extension: .tsx with host that doesnt have directoryExists @@ -70,9 +62,7 @@ Resolution:: { }, "failedLookupLocations": [ "/foo/bar/foo.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "./foo" from /foo/bar/baz.ts when module has extension: .d.ts @@ -91,9 +81,7 @@ Resolution:: { "failedLookupLocations": [ "/foo/bar/foo.ts", "/foo/bar/foo.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "./foo" from /foo/bar/baz.ts when module has extension: .d.ts with host that doesnt have directoryExists @@ -112,9 +100,7 @@ Resolution:: { "failedLookupLocations": [ "/foo/bar/foo.ts", "/foo/bar/foo.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } @@ -131,10 +117,7 @@ Resolution:: { "resolvedFileName": "/foo/foo.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "../foo" from /foo/bar/baz.ts when module has extension: .ts with host that doesnt have directoryExists @@ -149,10 +132,7 @@ Resolution:: { "resolvedFileName": "/foo/foo.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "../foo" from /foo/bar/baz.ts when module has extension: .tsx @@ -170,9 +150,7 @@ Resolution:: { }, "failedLookupLocations": [ "/foo/foo.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "../foo" from /foo/bar/baz.ts when module has extension: .tsx with host that doesnt have directoryExists @@ -190,9 +168,7 @@ Resolution:: { }, "failedLookupLocations": [ "/foo/foo.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "../foo" from /foo/bar/baz.ts when module has extension: .d.ts @@ -211,9 +187,7 @@ Resolution:: { "failedLookupLocations": [ "/foo/foo.ts", "/foo/foo.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "../foo" from /foo/bar/baz.ts when module has extension: .d.ts with host that doesnt have directoryExists @@ -232,9 +206,7 @@ Resolution:: { "failedLookupLocations": [ "/foo/foo.ts", "/foo/foo.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } @@ -251,10 +223,7 @@ Resolution:: { "resolvedFileName": "/foo.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "/foo" from /foo/bar/baz.ts when module has extension: .ts with host that doesnt have directoryExists @@ -269,10 +238,7 @@ Resolution:: { "resolvedFileName": "/foo.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "/foo" from /foo/bar/baz.ts when module has extension: .tsx @@ -290,9 +256,7 @@ Resolution:: { }, "failedLookupLocations": [ "/foo.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "/foo" from /foo/bar/baz.ts when module has extension: .tsx with host that doesnt have directoryExists @@ -310,9 +274,7 @@ Resolution:: { }, "failedLookupLocations": [ "/foo.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "/foo" from /foo/bar/baz.ts when module has extension: .d.ts @@ -331,9 +293,7 @@ Resolution:: { "failedLookupLocations": [ "/foo.ts", "/foo.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "/foo" from /foo/bar/baz.ts when module has extension: .d.ts with host that doesnt have directoryExists @@ -352,9 +312,7 @@ Resolution:: { "failedLookupLocations": [ "/foo.ts", "/foo.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } @@ -371,10 +329,7 @@ Resolution:: { "resolvedFileName": "c:/foo.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "c:/foo" from c:/foo/bar/baz.ts when module has extension: .ts with host that doesnt have directoryExists @@ -389,10 +344,7 @@ Resolution:: { "resolvedFileName": "c:/foo.ts", "extension": ".ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } Resolving "c:/foo" from c:/foo/bar/baz.ts when module has extension: .tsx @@ -410,9 +362,7 @@ Resolution:: { }, "failedLookupLocations": [ "c:/foo.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "c:/foo" from c:/foo/bar/baz.ts when module has extension: .tsx with host that doesnt have directoryExists @@ -430,9 +380,7 @@ Resolution:: { }, "failedLookupLocations": [ "c:/foo.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "c:/foo" from c:/foo/bar/baz.ts when module has extension: .d.ts @@ -451,9 +399,7 @@ Resolution:: { "failedLookupLocations": [ "c:/foo.ts", "c:/foo.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } Resolving "c:/foo" from c:/foo/bar/baz.ts when module has extension: .d.ts with host that doesnt have directoryExists @@ -472,8 +418,6 @@ Resolution:: { "failedLookupLocations": [ "c:/foo.ts", "c:/foo.tsx" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } diff --git a/tests/baselines/reference/moduleResolution/type-reference-from-primary-location.js b/tests/baselines/reference/moduleResolution/type-reference-from-primary-location.js index b00b634abd1..282c0bb60a3 100644 --- a/tests/baselines/reference/moduleResolution/type-reference-from-primary-location.js +++ b/tests/baselines/reference/moduleResolution/type-reference-from-primary-location.js @@ -13,9 +13,7 @@ Resolution:: { }, "failedLookupLocations": [ "/root/src/types/lib/package.json" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } //// [/root/src/app.ts] @@ -34,11 +32,9 @@ Resolution:: { "resolvedFileName": "/root/src/types/lib/typings/lib.d.ts", "isExternalLibraryImport": false }, - "failedLookupLocations": [], "affectingLocations": [ "/root/src/types/lib/package.json" - ], - "resolutionDiagnostics": [] + ] } //// [/root/src/app.ts] @@ -59,9 +55,7 @@ Resolution:: { "/root/src/types/lib/index.d.ts", "/root/src/node_modules/lib/package.json", "/root/src/node_modules/lib.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } //// [/root/src/app.ts] @@ -87,8 +81,7 @@ Resolution:: { ], "affectingLocations": [ "/root/src/node_modules/lib/package.json" - ], - "resolutionDiagnostics": [] + ] } //// [/root/src/app.ts] @@ -112,9 +105,7 @@ Resolution:: { "/root/src/node_modules/lib/index.d.ts", "/root/src/node_modules/@types/lib/package.json", "/root/src/node_modules/@types/lib.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } //// [/root/src/app.ts] @@ -143,6 +134,5 @@ Resolution:: { ], "affectingLocations": [ "/root/src/node_modules/@types/lib/package.json" - ], - "resolutionDiagnostics": [] + ] } diff --git a/tests/baselines/reference/moduleResolution/type-reference-from-secondary-location.js b/tests/baselines/reference/moduleResolution/type-reference-from-secondary-location.js index 04c64b7a7d7..8990d303378 100644 --- a/tests/baselines/reference/moduleResolution/type-reference-from-secondary-location.js +++ b/tests/baselines/reference/moduleResolution/type-reference-from-secondary-location.js @@ -21,9 +21,7 @@ Resolution:: { "/root/src/node_modules/@types/lib.d.ts", "/root/src/node_modules/@types/lib/index.d.ts", "/root/node_modules/lib/package.json" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } //// [/root/src/app.ts] @@ -50,9 +48,7 @@ Resolution:: { "/root/src/node_modules/@types/lib/index.d.ts", "/root/node_modules/lib/package.json", "/root/node_modules/lib.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } //// [/root/src/app.ts] @@ -84,8 +80,7 @@ Resolution:: { ], "affectingLocations": [ "/root/node_modules/lib/package.json" - ], - "resolutionDiagnostics": [] + ] } //// [/root/src/app.ts] @@ -115,9 +110,7 @@ Resolution:: { "/root/node_modules/lib/index.d.ts", "/root/node_modules/@types/lib/package.json", "/root/node_modules/@types/lib.d.ts" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } //// [/root/src/app.ts] @@ -152,6 +145,5 @@ Resolution:: { ], "affectingLocations": [ "/root/node_modules/@types/lib/package.json" - ], - "resolutionDiagnostics": [] + ] } diff --git a/tests/baselines/reference/moduleResolution/type-reference-overrides-secondary-location.js b/tests/baselines/reference/moduleResolution/type-reference-overrides-secondary-location.js index 2ada3050866..ef5afa43c6c 100644 --- a/tests/baselines/reference/moduleResolution/type-reference-overrides-secondary-location.js +++ b/tests/baselines/reference/moduleResolution/type-reference-overrides-secondary-location.js @@ -16,7 +16,5 @@ Resolution:: { }, "failedLookupLocations": [ "/root/src/types/lib/package.json" - ], - "affectingLocations": [], - "resolutionDiagnostics": [] + ] } diff --git a/tests/baselines/reference/moduleResolution/typeReferenceDirective-is-relative-and-in-a-sibling-folder.js b/tests/baselines/reference/moduleResolution/typeReferenceDirective-is-relative-and-in-a-sibling-folder.js index 38621203099..2aed4527ff9 100644 --- a/tests/baselines/reference/moduleResolution/typeReferenceDirective-is-relative-and-in-a-sibling-folder.js +++ b/tests/baselines/reference/moduleResolution/typeReferenceDirective-is-relative-and-in-a-sibling-folder.js @@ -10,10 +10,7 @@ Resolution:: { "primary": false, "resolvedFileName": "/root/src/typedefs/filesystem.d.ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } //// [/root/src/background/app.ts] @@ -28,8 +25,5 @@ Resolution:: { "primary": false, "resolvedFileName": "/root/src/typedefs/filesystem.d.ts", "isExternalLibraryImport": false - }, - "failedLookupLocations": [], - "affectingLocations": [], - "resolutionDiagnostics": [] + } } diff --git a/tests/baselines/reference/reuseProgramStructure/can-reuse-ambient-module-declarations-from-non-modified-files.js b/tests/baselines/reference/reuseProgramStructure/can-reuse-ambient-module-declarations-from-non-modified-files.js index 00a341ac02d..4b30d8f8165 100644 --- a/tests/baselines/reference/reuseProgramStructure/can-reuse-ambient-module-declarations-from-non-modified-files.js +++ b/tests/baselines/reference/reuseProgramStructure/can-reuse-ambient-module-declarations-from-non-modified-files.js @@ -4,7 +4,34 @@ File: /a/b/app.ts import * as fs from 'fs' resolvedModules: -fs: undefined +fs: { + "failedLookupLocations": [ + "/a/b/fs.ts", + "/a/b/fs.tsx", + "/a/b/fs.d.ts", + "/a/fs.ts", + "/a/fs.tsx", + "/a/fs.d.ts", + "/fs.ts", + "/fs.tsx", + "/fs.d.ts", + "/a/b/node_modules/@types/fs/package.json", + "/a/b/node_modules/@types/fs.d.ts", + "/a/b/node_modules/@types/fs/index.d.ts", + "/a/node_modules/@types/fs/package.json", + "/a/node_modules/@types/fs.d.ts", + "/a/node_modules/@types/fs/index.d.ts", + "/node_modules/@types/fs/package.json", + "/node_modules/@types/fs.d.ts", + "/node_modules/@types/fs/index.d.ts", + "/a/b/fs.js", + "/a/b/fs.jsx", + "/a/fs.js", + "/a/fs.jsx", + "/fs.js", + "/fs.jsx" + ] +} resolvedTypeReferenceDirectiveNames: undefined File: /a/b/node.d.ts @@ -53,7 +80,34 @@ File: /a/b/app.ts import * as fs from 'fs' var x = 1; resolvedModules: -fs: undefined +fs: { + "failedLookupLocations": [ + "/a/b/fs.ts", + "/a/b/fs.tsx", + "/a/b/fs.d.ts", + "/a/fs.ts", + "/a/fs.tsx", + "/a/fs.d.ts", + "/fs.ts", + "/fs.tsx", + "/fs.d.ts", + "/a/b/node_modules/@types/fs/package.json", + "/a/b/node_modules/@types/fs.d.ts", + "/a/b/node_modules/@types/fs/index.d.ts", + "/a/node_modules/@types/fs/package.json", + "/a/node_modules/@types/fs.d.ts", + "/a/node_modules/@types/fs/index.d.ts", + "/node_modules/@types/fs/package.json", + "/node_modules/@types/fs.d.ts", + "/node_modules/@types/fs/index.d.ts", + "/a/b/fs.js", + "/a/b/fs.jsx", + "/a/fs.js", + "/a/fs.jsx", + "/fs.js", + "/fs.jsx" + ] +} resolvedTypeReferenceDirectiveNames: undefined File: /a/b/node.d.ts @@ -76,7 +130,34 @@ File: /a/b/app.ts import * as fs from 'fs' var y = 1; resolvedModules: -fs: undefined +fs: { + "failedLookupLocations": [ + "/a/b/fs.ts", + "/a/b/fs.tsx", + "/a/b/fs.d.ts", + "/a/fs.ts", + "/a/fs.tsx", + "/a/fs.d.ts", + "/fs.ts", + "/fs.tsx", + "/fs.d.ts", + "/a/b/node_modules/@types/fs/package.json", + "/a/b/node_modules/@types/fs.d.ts", + "/a/b/node_modules/@types/fs/index.d.ts", + "/a/node_modules/@types/fs/package.json", + "/a/node_modules/@types/fs.d.ts", + "/a/node_modules/@types/fs/index.d.ts", + "/node_modules/@types/fs/package.json", + "/node_modules/@types/fs.d.ts", + "/node_modules/@types/fs/index.d.ts", + "/a/b/fs.js", + "/a/b/fs.jsx", + "/a/fs.js", + "/a/fs.jsx", + "/fs.js", + "/fs.jsx" + ] +} resolvedTypeReferenceDirectiveNames: undefined File: /a/b/node.d.ts 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 5a34206454f..83f3d24b636 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 @@ -50,15 +50,22 @@ export let BB = B; declare module './b1' { interface B { y: string; } } resolvedModules: ./b1: { - "resolvedFileName": "b1.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b1.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: typerefs1: { - "primary": true, - "resolvedFileName": "node_modules/@types/typerefs1/index.d.ts", - "isExternalLibraryImport": false + "resolvedTypeReferenceDirective": { + "primary": true, + "resolvedFileName": "node_modules/@types/typerefs1/index.d.ts", + "isExternalLibraryImport": false + }, + "failedLookupLocations": [ + "node_modules/@types/typerefs1/package.json" + ] } File: f2.ts @@ -69,20 +76,29 @@ import { BB } from './f1'; (new BB).x; (new BB).y; resolvedModules: ./b2: { - "resolvedFileName": "b2.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b2.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } ./f1: { - "resolvedFileName": "f1.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "f1.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: typerefs2: { - "primary": true, - "resolvedFileName": "node_modules/@types/typerefs2/index.d.ts", - "isExternalLibraryImport": false + "resolvedTypeReferenceDirective": { + "primary": true, + "resolvedFileName": "node_modules/@types/typerefs2/index.d.ts", + "isExternalLibraryImport": false + }, + "failedLookupLocations": [ + "node_modules/@types/typerefs2/package.json" + ] } ======== Resolving type reference directive 'typerefs1', containing file 'f1.ts', root directory 'node_modules/@types'. ======== @@ -168,15 +184,22 @@ export let BB = B; declare module './b1' { interface B { y: string; } } resolvedModules: ./b1: { - "resolvedFileName": "b1.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b1.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: typerefs1: { - "primary": true, - "resolvedFileName": "node_modules/@types/typerefs1/index.d.ts", - "isExternalLibraryImport": false + "resolvedTypeReferenceDirective": { + "primary": true, + "resolvedFileName": "node_modules/@types/typerefs1/index.d.ts", + "isExternalLibraryImport": false + }, + "failedLookupLocations": [ + "node_modules/@types/typerefs1/package.json" + ] } File: f2.ts @@ -187,20 +210,29 @@ import { BB } from './f1'; (new BB).x; (new BB).y; resolvedModules: ./b2: { - "resolvedFileName": "b2.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b2.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } ./f1: { - "resolvedFileName": "f1.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "f1.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: typerefs2: { - "primary": true, - "resolvedFileName": "node_modules/@types/typerefs2/index.d.ts", - "isExternalLibraryImport": false + "resolvedTypeReferenceDirective": { + "primary": true, + "resolvedFileName": "node_modules/@types/typerefs2/index.d.ts", + "isExternalLibraryImport": false + }, + "failedLookupLocations": [ + "node_modules/@types/typerefs2/package.json" + ] } ======== Resolving type reference directive 'typerefs1', containing file 'f1.ts', root directory 'node_modules/@types'. ======== @@ -275,9 +307,11 @@ export let BB = B; declare module './b1' { interface B { y: string; } } resolvedModules: ./b1: { - "resolvedFileName": "b1.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b1.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: undefined @@ -289,20 +323,29 @@ import { BB } from './f1'; (new BB).x; (new BB).y; resolvedModules: ./b2: { - "resolvedFileName": "b2.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b2.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } ./f1: { - "resolvedFileName": "f1.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "f1.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: typerefs2: { - "primary": true, - "resolvedFileName": "node_modules/@types/typerefs2/index.d.ts", - "isExternalLibraryImport": false + "resolvedTypeReferenceDirective": { + "primary": true, + "resolvedFileName": "node_modules/@types/typerefs2/index.d.ts", + "isExternalLibraryImport": false + }, + "failedLookupLocations": [ + "node_modules/@types/typerefs2/package.json" + ] } ======== Resolving module './b1' from 'f1.ts'. ======== @@ -372,9 +415,11 @@ export let BB = B; declare module './b1' { interface B { y: string; } } resolvedModules: ./b1: { - "resolvedFileName": "b1.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b1.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: undefined @@ -386,20 +431,29 @@ import { BB } from './f1'; (new BB).x; (new BB).y; resolvedModules: ./b2: { - "resolvedFileName": "b2.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b2.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } ./f1: { - "resolvedFileName": "f1.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "f1.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: typerefs2: { - "primary": true, - "resolvedFileName": "node_modules/@types/typerefs2/index.d.ts", - "isExternalLibraryImport": false + "resolvedTypeReferenceDirective": { + "primary": true, + "resolvedFileName": "node_modules/@types/typerefs2/index.d.ts", + "isExternalLibraryImport": false + }, + "failedLookupLocations": [ + "node_modules/@types/typerefs2/package.json" + ] } ======== Resolving module './b1' from 'f1.ts'. ======== @@ -468,9 +522,11 @@ import { B } from './b1'; declare module './b1' { interface B { y: string; } } resolvedModules: ./b1: { - "resolvedFileName": "b1.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b1.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: undefined @@ -482,20 +538,29 @@ import { BB } from './f1'; (new BB).x; (new BB).y; resolvedModules: ./b2: { - "resolvedFileName": "b2.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b2.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } ./f1: { - "resolvedFileName": "f1.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "f1.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: typerefs2: { - "primary": true, - "resolvedFileName": "node_modules/@types/typerefs2/index.d.ts", - "isExternalLibraryImport": false + "resolvedTypeReferenceDirective": { + "primary": true, + "resolvedFileName": "node_modules/@types/typerefs2/index.d.ts", + "isExternalLibraryImport": false + }, + "failedLookupLocations": [ + "node_modules/@types/typerefs2/package.json" + ] } ======== Resolving module './b1' from 'f1.ts'. ======== @@ -562,9 +627,11 @@ import { B } from './b1'; resolvedModules: ./b1: { - "resolvedFileName": "b1.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b1.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: undefined @@ -576,20 +643,29 @@ import { BB } from './f1'; (new BB).x; (new BB).y; resolvedModules: ./b2: { - "resolvedFileName": "b2.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b2.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } ./f1: { - "resolvedFileName": "f1.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "f1.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: typerefs2: { - "primary": true, - "resolvedFileName": "node_modules/@types/typerefs2/index.d.ts", - "isExternalLibraryImport": false + "resolvedTypeReferenceDirective": { + "primary": true, + "resolvedFileName": "node_modules/@types/typerefs2/index.d.ts", + "isExternalLibraryImport": false + }, + "failedLookupLocations": [ + "node_modules/@types/typerefs2/package.json" + ] } ======== Resolving module './b1' from 'f1.ts'. ======== @@ -668,20 +744,29 @@ import { BB } from './f1'; (new BB).x; (new BB).y; resolvedModules: ./b2: { - "resolvedFileName": "b2.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b2.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } ./f1: { - "resolvedFileName": "f1.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "f1.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: typerefs2: { - "primary": true, - "resolvedFileName": "node_modules/@types/typerefs2/index.d.ts", - "isExternalLibraryImport": false + "resolvedTypeReferenceDirective": { + "primary": true, + "resolvedFileName": "node_modules/@types/typerefs2/index.d.ts", + "isExternalLibraryImport": false + }, + "failedLookupLocations": [ + "node_modules/@types/typerefs2/package.json" + ] } Reusing resolution of type reference directive 'typerefs2' from 'f2.ts' of old program, it was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts'. 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 b401d6e54f8..1ab1a4b919c 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 @@ -12,14 +12,23 @@ 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" - } + "resolvedModule": { + "resolvedFileName": "/node_modules/b/internal.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true, + "packageId": { + "name": "b", + "subModuleName": "internal.d.ts", + "version": "1.2.3" + } + }, + "failedLookupLocations": [ + "/node_modules/b/internal.ts", + "/node_modules/b/internal.tsx" + ], + "affectingLocations": [ + "/node_modules/b/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -29,14 +38,26 @@ 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" - } + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true, + "packageId": { + "name": "b", + "subModuleName": "index.d.ts", + "version": "1.2.3" + } + }, + "failedLookupLocations": [ + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -60,14 +81,23 @@ 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" - } + "resolvedModule": { + "resolvedFileName": "/node_modules/b/internal.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true, + "packageId": { + "name": "b", + "subModuleName": "internal.d.ts", + "version": "1.2.3" + } + }, + "failedLookupLocations": [ + "/node_modules/b/internal.ts", + "/node_modules/b/internal.tsx" + ], + "affectingLocations": [ + "/node_modules/b/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -77,14 +107,26 @@ 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" - } + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true, + "packageId": { + "name": "b", + "subModuleName": "index.d.ts", + "version": "1.2.3" + } + }, + "failedLookupLocations": [ + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/change-affects-imports.js b/tests/baselines/reference/reuseProgramStructure/change-affects-imports.js index 5bec4091c46..edc9d673707 100644 --- a/tests/baselines/reference/reuseProgramStructure/change-affects-imports.js +++ b/tests/baselines/reference/reuseProgramStructure/change-affects-imports.js @@ -23,7 +23,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.ts"] @@ -40,9 +51,11 @@ import x from 'b' var z = 1; resolvedModules: b: { - "resolvedFileName": "b.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: undefined @@ -63,7 +76,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.ts"] diff --git a/tests/baselines/reference/reuseProgramStructure/change-affects-tripleslash-references.js b/tests/baselines/reference/reuseProgramStructure/change-affects-tripleslash-references.js index fe4e063743f..ccb5fb4735f 100644 --- a/tests/baselines/reference/reuseProgramStructure/change-affects-tripleslash-references.js +++ b/tests/baselines/reference/reuseProgramStructure/change-affects-tripleslash-references.js @@ -23,7 +23,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.ts"] diff --git a/tests/baselines/reference/reuseProgramStructure/change-affects-type-directives.js b/tests/baselines/reference/reuseProgramStructure/change-affects-type-directives.js index 654346e12fd..01de928c937 100644 --- a/tests/baselines/reference/reuseProgramStructure/change-affects-type-directives.js +++ b/tests/baselines/reference/reuseProgramStructure/change-affects-type-directives.js @@ -23,7 +23,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.ts"] @@ -57,7 +68,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs1: undefined +typerefs1: { + "failedLookupLocations": [ + "node_modules/@types/typerefs1/package.json", + "node_modules/@types/typerefs1/index.d.ts", + "node_modules/typerefs1/package.json", + "node_modules/typerefs1.d.ts", + "node_modules/typerefs1/index.d.ts", + "node_modules/@types/typerefs1/package.json", + "node_modules/@types/typerefs1.d.ts", + "node_modules/@types/typerefs1/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.ts"] diff --git a/tests/baselines/reference/reuseProgramStructure/change-affects-type-references.js b/tests/baselines/reference/reuseProgramStructure/change-affects-type-references.js index 8c82d49cc27..e13a7eb95fd 100644 --- a/tests/baselines/reference/reuseProgramStructure/change-affects-type-references.js +++ b/tests/baselines/reference/reuseProgramStructure/change-affects-type-references.js @@ -23,7 +23,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.ts"] @@ -58,7 +69,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.ts"] diff --git a/tests/baselines/reference/reuseProgramStructure/change-does-not-affect-imports-or-type-refs.js b/tests/baselines/reference/reuseProgramStructure/change-does-not-affect-imports-or-type-refs.js index 41485398e0a..102fa9c3086 100644 --- a/tests/baselines/reference/reuseProgramStructure/change-does-not-affect-imports-or-type-refs.js +++ b/tests/baselines/reference/reuseProgramStructure/change-does-not-affect-imports-or-type-refs.js @@ -23,7 +23,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.ts"] @@ -58,7 +69,18 @@ File: a.ts var x = 100 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.ts"] diff --git a/tests/baselines/reference/reuseProgramStructure/change-doesnot-affect-type-references.js b/tests/baselines/reference/reuseProgramStructure/change-doesnot-affect-type-references.js index 7f09fea8e27..1e7e9f8be90 100644 --- a/tests/baselines/reference/reuseProgramStructure/change-doesnot-affect-type-references.js +++ b/tests/baselines/reference/reuseProgramStructure/change-doesnot-affect-type-references.js @@ -23,7 +23,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.ts"] @@ -58,7 +69,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.ts"] diff --git a/tests/baselines/reference/reuseProgramStructure/config-path-changes.js b/tests/baselines/reference/reuseProgramStructure/config-path-changes.js index 32ea3faab6f..42f692e5bba 100644 --- a/tests/baselines/reference/reuseProgramStructure/config-path-changes.js +++ b/tests/baselines/reference/reuseProgramStructure/config-path-changes.js @@ -23,7 +23,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "/a/b/node_modules/@types/typerefs/package.json", + "/a/b/node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.ts"] @@ -58,7 +69,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "/a/c/node_modules/@types/typerefs/package.json", + "/a/c/node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.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 fc55897aee2..271483c51fd 100644 --- a/tests/baselines/reference/reuseProgramStructure/fetches-imports-after-npm-install.js +++ b/tests/baselines/reference/reuseProgramStructure/fetches-imports-after-npm-install.js @@ -4,7 +4,25 @@ File: file1.ts import * as a from "a"; const myX: number = a.x; resolvedModules: -a: undefined +a: { + "failedLookupLocations": [ + "node_modules/a/package.json", + "node_modules/a.ts", + "node_modules/a.tsx", + "node_modules/a.d.ts", + "node_modules/a/index.ts", + "node_modules/a/index.tsx", + "node_modules/a/index.d.ts", + "node_modules/@types/a/package.json", + "node_modules/@types/a.d.ts", + "node_modules/@types/a/index.d.ts", + "node_modules/a/package.json", + "node_modules/a.js", + "node_modules/a.jsx", + "node_modules/a/index.js", + "node_modules/a/index.jsx" + ] +} resolvedTypeReferenceDirectiveNames: undefined File: file2.ts @@ -55,9 +73,19 @@ import * as a from "a"; const myX: number = a.x; resolvedModules: a: { - "resolvedFileName": "node_modules/a/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "node_modules/a/package.json", + "node_modules/a.ts", + "node_modules/a.tsx", + "node_modules/a.d.ts", + "node_modules/a/index.ts", + "node_modules/a/index.tsx" + ] } resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/missing-file-is-created.js b/tests/baselines/reference/reuseProgramStructure/missing-file-is-created.js index c087d051aa2..33f09a3917b 100644 --- a/tests/baselines/reference/reuseProgramStructure/missing-file-is-created.js +++ b/tests/baselines/reference/reuseProgramStructure/missing-file-is-created.js @@ -23,7 +23,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts"] @@ -65,7 +76,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: [] diff --git a/tests/baselines/reference/reuseProgramStructure/missing-files-remain-missing.js b/tests/baselines/reference/reuseProgramStructure/missing-files-remain-missing.js index c1589a41e96..a31ec62764d 100644 --- a/tests/baselines/reference/reuseProgramStructure/missing-files-remain-missing.js +++ b/tests/baselines/reference/reuseProgramStructure/missing-files-remain-missing.js @@ -23,7 +23,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts"] @@ -58,7 +69,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts"] diff --git a/tests/baselines/reference/reuseProgramStructure/module-kind-changes.js b/tests/baselines/reference/reuseProgramStructure/module-kind-changes.js index 32ea3faab6f..2f2b2cc7689 100644 --- a/tests/baselines/reference/reuseProgramStructure/module-kind-changes.js +++ b/tests/baselines/reference/reuseProgramStructure/module-kind-changes.js @@ -23,7 +23,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.ts"] @@ -58,7 +69,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.ts"] diff --git a/tests/baselines/reference/reuseProgramStructure/redirect-no-change.js b/tests/baselines/reference/reuseProgramStructure/redirect-no-change.js index 958657d9d32..edd5b77800c 100644 --- a/tests/baselines/reference/reuseProgramStructure/redirect-no-change.js +++ b/tests/baselines/reference/reuseProgramStructure/redirect-no-change.js @@ -12,14 +12,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/a/node_modules/x.ts", + "/node_modules/a/node_modules/x.tsx", + "/node_modules/a/node_modules/x.d.ts", + "/node_modules/a/node_modules/x/index.ts", + "/node_modules/a/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/a/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -36,14 +48,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/b/node_modules/x.ts", + "/node_modules/b/node_modules/x.tsx", + "/node_modules/b/node_modules/x.d.ts", + "/node_modules/b/node_modules/x/index.ts", + "/node_modules/b/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -53,14 +77,34 @@ import { a } from "a"; import { b } from "b"; a(b) resolvedModules: a: { - "resolvedFileName": "/node_modules/a/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/package.json", + "/node_modules/a.ts", + "/node_modules/a.tsx", + "/node_modules/a.d.ts", + "/node_modules/a/index.ts", + "/node_modules/a/index.tsx" + ] } b: { - "resolvedFileName": "/node_modules/b/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/b/package.json", + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -84,14 +128,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/a/node_modules/x.ts", + "/node_modules/a/node_modules/x.tsx", + "/node_modules/a/node_modules/x.d.ts", + "/node_modules/a/node_modules/x/index.ts", + "/node_modules/a/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/a/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -108,14 +164,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/b/node_modules/x.ts", + "/node_modules/b/node_modules/x.tsx", + "/node_modules/b/node_modules/x.d.ts", + "/node_modules/b/node_modules/x/index.ts", + "/node_modules/b/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -125,14 +193,34 @@ 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 + "resolvedModule": { + "resolvedFileName": "/node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/package.json", + "/node_modules/a.ts", + "/node_modules/a.tsx", + "/node_modules/a.d.ts", + "/node_modules/a/index.ts", + "/node_modules/a/index.tsx" + ] } b: { - "resolvedFileName": "/node_modules/b/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/b/package.json", + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ] } 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 fe339b6def2..6af47acec2e 100644 --- a/tests/baselines/reference/reuseProgramStructure/redirect-previous-duplicate-packages.js +++ b/tests/baselines/reference/reuseProgramStructure/redirect-previous-duplicate-packages.js @@ -12,14 +12,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/a/node_modules/x.ts", + "/node_modules/a/node_modules/x.tsx", + "/node_modules/a/node_modules/x.d.ts", + "/node_modules/a/node_modules/x/index.ts", + "/node_modules/a/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/a/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -36,14 +48,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/b/node_modules/x.ts", + "/node_modules/b/node_modules/x.tsx", + "/node_modules/b/node_modules/x.d.ts", + "/node_modules/b/node_modules/x/index.ts", + "/node_modules/b/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -53,14 +77,34 @@ import { a } from "a"; import { b } from "b"; a(b) resolvedModules: a: { - "resolvedFileName": "/node_modules/a/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/package.json", + "/node_modules/a.ts", + "/node_modules/a.tsx", + "/node_modules/a.d.ts", + "/node_modules/a/index.ts", + "/node_modules/a/index.tsx" + ] } b: { - "resolvedFileName": "/node_modules/b/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/b/package.json", + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -86,14 +130,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/a/node_modules/x.ts", + "/node_modules/a/node_modules/x.tsx", + "/node_modules/a/node_modules/x.d.ts", + "/node_modules/a/node_modules/x/index.ts", + "/node_modules/a/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/a/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -110,14 +166,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/b/node_modules/x.ts", + "/node_modules/b/node_modules/x.tsx", + "/node_modules/b/node_modules/x.d.ts", + "/node_modules/b/node_modules/x/index.ts", + "/node_modules/b/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -127,14 +195,34 @@ import { a } from "a"; import { b } from "b"; a(b) resolvedModules: a: { - "resolvedFileName": "/node_modules/a/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/package.json", + "/node_modules/a.ts", + "/node_modules/a.tsx", + "/node_modules/a.d.ts", + "/node_modules/a/index.ts", + "/node_modules/a/index.tsx" + ] } b: { - "resolvedFileName": "/node_modules/b/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/b/package.json", + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ] } resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/redirect-target-changes.js b/tests/baselines/reference/reuseProgramStructure/redirect-target-changes.js index ff9fb81eac1..4afced0c95b 100644 --- a/tests/baselines/reference/reuseProgramStructure/redirect-target-changes.js +++ b/tests/baselines/reference/reuseProgramStructure/redirect-target-changes.js @@ -12,14 +12,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/a/node_modules/x.ts", + "/node_modules/a/node_modules/x.tsx", + "/node_modules/a/node_modules/x.d.ts", + "/node_modules/a/node_modules/x/index.ts", + "/node_modules/a/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/a/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -36,14 +48,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/b/node_modules/x.ts", + "/node_modules/b/node_modules/x.tsx", + "/node_modules/b/node_modules/x.d.ts", + "/node_modules/b/node_modules/x/index.ts", + "/node_modules/b/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -53,14 +77,34 @@ import { a } from "a"; import { b } from "b"; a(b) resolvedModules: a: { - "resolvedFileName": "/node_modules/a/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/package.json", + "/node_modules/a.ts", + "/node_modules/a.tsx", + "/node_modules/a.d.ts", + "/node_modules/a/index.ts", + "/node_modules/a/index.tsx" + ] } b: { - "resolvedFileName": "/node_modules/b/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/b/package.json", + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -84,9 +128,21 @@ 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 + "resolvedModule": { + "resolvedFileName": "/node_modules/a/node_modules/x/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/node_modules/x.ts", + "/node_modules/a/node_modules/x.tsx", + "/node_modules/a/node_modules/x.d.ts", + "/node_modules/a/node_modules/x/index.ts", + "/node_modules/a/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/a/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -103,14 +159,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/b/node_modules/x.ts", + "/node_modules/b/node_modules/x.tsx", + "/node_modules/b/node_modules/x.d.ts", + "/node_modules/b/node_modules/x/index.ts", + "/node_modules/b/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -120,14 +188,34 @@ import { a } from "a"; import { b } from "b"; a(b) resolvedModules: a: { - "resolvedFileName": "/node_modules/a/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/package.json", + "/node_modules/a.ts", + "/node_modules/a.tsx", + "/node_modules/a.d.ts", + "/node_modules/a/index.ts", + "/node_modules/a/index.tsx" + ] } b: { - "resolvedFileName": "/node_modules/b/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/b/package.json", + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ] } resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/redirect-underlying-changes.js b/tests/baselines/reference/reuseProgramStructure/redirect-underlying-changes.js index a6179a71915..f8d4c09bc12 100644 --- a/tests/baselines/reference/reuseProgramStructure/redirect-underlying-changes.js +++ b/tests/baselines/reference/reuseProgramStructure/redirect-underlying-changes.js @@ -12,14 +12,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/a/node_modules/x.ts", + "/node_modules/a/node_modules/x.tsx", + "/node_modules/a/node_modules/x.d.ts", + "/node_modules/a/node_modules/x/index.ts", + "/node_modules/a/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/a/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -36,14 +48,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/b/node_modules/x.ts", + "/node_modules/b/node_modules/x.tsx", + "/node_modules/b/node_modules/x.d.ts", + "/node_modules/b/node_modules/x/index.ts", + "/node_modules/b/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -53,14 +77,34 @@ import { a } from "a"; import { b } from "b"; a(b) resolvedModules: a: { - "resolvedFileName": "/node_modules/a/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/package.json", + "/node_modules/a.ts", + "/node_modules/a.tsx", + "/node_modules/a.d.ts", + "/node_modules/a/index.ts", + "/node_modules/a/index.tsx" + ] } b: { - "resolvedFileName": "/node_modules/b/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/b/package.json", + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -84,14 +128,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/a/node_modules/x.ts", + "/node_modules/a/node_modules/x.tsx", + "/node_modules/a/node_modules/x.d.ts", + "/node_modules/a/node_modules/x/index.ts", + "/node_modules/a/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/a/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -108,14 +164,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/b/node_modules/x.ts", + "/node_modules/b/node_modules/x.tsx", + "/node_modules/b/node_modules/x.d.ts", + "/node_modules/b/node_modules/x/index.ts", + "/node_modules/b/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -125,14 +193,34 @@ import { a } from "a"; import { b } from "b"; a(b) resolvedModules: a: { - "resolvedFileName": "/node_modules/a/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/package.json", + "/node_modules/a.ts", + "/node_modules/a.tsx", + "/node_modules/a.d.ts", + "/node_modules/a/index.ts", + "/node_modules/a/index.tsx" + ] } b: { - "resolvedFileName": "/node_modules/b/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/b/package.json", + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ] } 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 958657d9d32..edd5b77800c 100644 --- a/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-no-change.js +++ b/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-no-change.js @@ -12,14 +12,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/a/node_modules/x.ts", + "/node_modules/a/node_modules/x.tsx", + "/node_modules/a/node_modules/x.d.ts", + "/node_modules/a/node_modules/x/index.ts", + "/node_modules/a/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/a/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -36,14 +48,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/b/node_modules/x.ts", + "/node_modules/b/node_modules/x.tsx", + "/node_modules/b/node_modules/x.d.ts", + "/node_modules/b/node_modules/x/index.ts", + "/node_modules/b/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -53,14 +77,34 @@ import { a } from "a"; import { b } from "b"; a(b) resolvedModules: a: { - "resolvedFileName": "/node_modules/a/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/package.json", + "/node_modules/a.ts", + "/node_modules/a.tsx", + "/node_modules/a.d.ts", + "/node_modules/a/index.ts", + "/node_modules/a/index.tsx" + ] } b: { - "resolvedFileName": "/node_modules/b/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/b/package.json", + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -84,14 +128,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/a/node_modules/x.ts", + "/node_modules/a/node_modules/x.tsx", + "/node_modules/a/node_modules/x.d.ts", + "/node_modules/a/node_modules/x/index.ts", + "/node_modules/a/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/a/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -108,14 +164,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/b/node_modules/x.ts", + "/node_modules/b/node_modules/x.tsx", + "/node_modules/b/node_modules/x.d.ts", + "/node_modules/b/node_modules/x/index.ts", + "/node_modules/b/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -125,14 +193,34 @@ 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 + "resolvedModule": { + "resolvedFileName": "/node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/package.json", + "/node_modules/a.ts", + "/node_modules/a.tsx", + "/node_modules/a.d.ts", + "/node_modules/a/index.ts", + "/node_modules/a/index.tsx" + ] } b: { - "resolvedFileName": "/node_modules/b/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/b/package.json", + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ] } 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 fe339b6def2..6af47acec2e 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 @@ -12,14 +12,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/a/node_modules/x.ts", + "/node_modules/a/node_modules/x.tsx", + "/node_modules/a/node_modules/x.d.ts", + "/node_modules/a/node_modules/x/index.ts", + "/node_modules/a/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/a/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -36,14 +48,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/b/node_modules/x.ts", + "/node_modules/b/node_modules/x.tsx", + "/node_modules/b/node_modules/x.d.ts", + "/node_modules/b/node_modules/x/index.ts", + "/node_modules/b/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -53,14 +77,34 @@ import { a } from "a"; import { b } from "b"; a(b) resolvedModules: a: { - "resolvedFileName": "/node_modules/a/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/package.json", + "/node_modules/a.ts", + "/node_modules/a.tsx", + "/node_modules/a.d.ts", + "/node_modules/a/index.ts", + "/node_modules/a/index.tsx" + ] } b: { - "resolvedFileName": "/node_modules/b/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/b/package.json", + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -86,14 +130,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/a/node_modules/x.ts", + "/node_modules/a/node_modules/x.tsx", + "/node_modules/a/node_modules/x.d.ts", + "/node_modules/a/node_modules/x/index.ts", + "/node_modules/a/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/a/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -110,14 +166,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/b/node_modules/x.ts", + "/node_modules/b/node_modules/x.tsx", + "/node_modules/b/node_modules/x.d.ts", + "/node_modules/b/node_modules/x/index.ts", + "/node_modules/b/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -127,14 +195,34 @@ import { a } from "a"; import { b } from "b"; a(b) resolvedModules: a: { - "resolvedFileName": "/node_modules/a/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/package.json", + "/node_modules/a.ts", + "/node_modules/a.tsx", + "/node_modules/a.d.ts", + "/node_modules/a/index.ts", + "/node_modules/a/index.tsx" + ] } b: { - "resolvedFileName": "/node_modules/b/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/b/package.json", + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ] } 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 ff9fb81eac1..4afced0c95b 100644 --- a/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-target-changes.js +++ b/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-target-changes.js @@ -12,14 +12,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/a/node_modules/x.ts", + "/node_modules/a/node_modules/x.tsx", + "/node_modules/a/node_modules/x.d.ts", + "/node_modules/a/node_modules/x/index.ts", + "/node_modules/a/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/a/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -36,14 +48,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/b/node_modules/x.ts", + "/node_modules/b/node_modules/x.tsx", + "/node_modules/b/node_modules/x.d.ts", + "/node_modules/b/node_modules/x/index.ts", + "/node_modules/b/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -53,14 +77,34 @@ import { a } from "a"; import { b } from "b"; a(b) resolvedModules: a: { - "resolvedFileName": "/node_modules/a/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/package.json", + "/node_modules/a.ts", + "/node_modules/a.tsx", + "/node_modules/a.d.ts", + "/node_modules/a/index.ts", + "/node_modules/a/index.tsx" + ] } b: { - "resolvedFileName": "/node_modules/b/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/b/package.json", + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -84,9 +128,21 @@ 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 + "resolvedModule": { + "resolvedFileName": "/node_modules/a/node_modules/x/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/node_modules/x.ts", + "/node_modules/a/node_modules/x.tsx", + "/node_modules/a/node_modules/x.d.ts", + "/node_modules/a/node_modules/x/index.ts", + "/node_modules/a/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/a/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -103,14 +159,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/b/node_modules/x.ts", + "/node_modules/b/node_modules/x.tsx", + "/node_modules/b/node_modules/x.d.ts", + "/node_modules/b/node_modules/x/index.ts", + "/node_modules/b/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -120,14 +188,34 @@ import { a } from "a"; import { b } from "b"; a(b) resolvedModules: a: { - "resolvedFileName": "/node_modules/a/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/package.json", + "/node_modules/a.ts", + "/node_modules/a.tsx", + "/node_modules/a.d.ts", + "/node_modules/a/index.ts", + "/node_modules/a/index.tsx" + ] } b: { - "resolvedFileName": "/node_modules/b/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/b/package.json", + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ] } 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 a6179a71915..f8d4c09bc12 100644 --- a/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-underlying-changes.js +++ b/tests/baselines/reference/reuseProgramStructure/redirect-with-getSourceFileByPath-underlying-changes.js @@ -12,14 +12,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/a/node_modules/x.ts", + "/node_modules/a/node_modules/x.tsx", + "/node_modules/a/node_modules/x.d.ts", + "/node_modules/a/node_modules/x/index.ts", + "/node_modules/a/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/a/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -36,14 +48,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/b/node_modules/x.ts", + "/node_modules/b/node_modules/x.tsx", + "/node_modules/b/node_modules/x.d.ts", + "/node_modules/b/node_modules/x/index.ts", + "/node_modules/b/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -53,14 +77,34 @@ import { a } from "a"; import { b } from "b"; a(b) resolvedModules: a: { - "resolvedFileName": "/node_modules/a/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/package.json", + "/node_modules/a.ts", + "/node_modules/a.tsx", + "/node_modules/a.d.ts", + "/node_modules/a/index.ts", + "/node_modules/a/index.tsx" + ] } b: { - "resolvedFileName": "/node_modules/b/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/b/package.json", + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -84,14 +128,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/a/node_modules/x.ts", + "/node_modules/a/node_modules/x.tsx", + "/node_modules/a/node_modules/x.d.ts", + "/node_modules/a/node_modules/x/index.ts", + "/node_modules/a/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/a/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -108,14 +164,26 @@ 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" - } + "resolvedModule": { + "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" + } + }, + "failedLookupLocations": [ + "/node_modules/b/node_modules/x.ts", + "/node_modules/b/node_modules/x.tsx", + "/node_modules/b/node_modules/x.d.ts", + "/node_modules/b/node_modules/x/index.ts", + "/node_modules/b/node_modules/x/index.tsx" + ], + "affectingLocations": [ + "/node_modules/b/node_modules/x/package.json" + ] } resolvedTypeReferenceDirectiveNames: undefined @@ -125,14 +193,34 @@ import { a } from "a"; import { b } from "b"; a(b) resolvedModules: a: { - "resolvedFileName": "/node_modules/a/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/a/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/a/package.json", + "/node_modules/a.ts", + "/node_modules/a.tsx", + "/node_modules/a.d.ts", + "/node_modules/a/index.ts", + "/node_modules/a/index.tsx" + ] } b: { - "resolvedFileName": "/node_modules/b/index.d.ts", - "extension": ".d.ts", - "isExternalLibraryImport": true + "resolvedModule": { + "resolvedFileName": "/node_modules/b/index.d.ts", + "extension": ".d.ts", + "isExternalLibraryImport": true + }, + "failedLookupLocations": [ + "/node_modules/b/package.json", + "/node_modules/b.ts", + "/node_modules/b.tsx", + "/node_modules/b.d.ts", + "/node_modules/b/index.ts", + "/node_modules/b/index.tsx" + ] } 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 09d7d0cdf04..4cb70b6e9ac 100644 --- a/tests/baselines/reference/reuseProgramStructure/resolution-cache-follows-imports.js +++ b/tests/baselines/reference/reuseProgramStructure/resolution-cache-follows-imports.js @@ -12,9 +12,11 @@ import {_} from 'b' var x = 1 resolvedModules: b: { - "resolvedFileName": "b.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: undefined @@ -39,9 +41,11 @@ import {_} from 'b' var x = 2 resolvedModules: b: { - "resolvedFileName": "b.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: undefined @@ -82,11 +86,24 @@ import x from 'b' var x = 2 resolvedModules: b: { - "resolvedFileName": "b.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "b.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } +} +c: { + "failedLookupLocations": [ + "c.ts", + "c.tsx", + "c.d.ts", + "node_modules/@types/c/package.json", + "node_modules/@types/c.d.ts", + "node_modules/@types/c/index.d.ts", + "c.js", + "c.jsx" + ] } -c: undefined resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/resolved-type-directives-cache-follows-type-directives.js b/tests/baselines/reference/reuseProgramStructure/resolved-type-directives-cache-follows-type-directives.js index 909c2056a97..4f4075a6bdb 100644 --- a/tests/baselines/reference/reuseProgramStructure/resolved-type-directives-cache-follows-type-directives.js +++ b/tests/baselines/reference/reuseProgramStructure/resolved-type-directives-cache-follows-type-directives.js @@ -13,9 +13,14 @@ var x = $ resolvedModules: undefined resolvedTypeReferenceDirectiveNames: typedefs: { - "primary": true, - "resolvedFileName": "/types/typedefs/index.d.ts", - "isExternalLibraryImport": false + "resolvedTypeReferenceDirective": { + "primary": true, + "resolvedFileName": "/types/typedefs/index.d.ts", + "isExternalLibraryImport": false + }, + "failedLookupLocations": [ + "/types/typedefs/package.json" + ] } @@ -39,9 +44,14 @@ var x = 2 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: typedefs: { - "primary": true, - "resolvedFileName": "/types/typedefs/index.d.ts", - "isExternalLibraryImport": false + "resolvedTypeReferenceDirective": { + "primary": true, + "resolvedFileName": "/types/typedefs/index.d.ts", + "isExternalLibraryImport": false + }, + "failedLookupLocations": [ + "/types/typedefs/package.json" + ] } @@ -81,11 +91,27 @@ var x = 2 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: typedefs: { - "primary": true, - "resolvedFileName": "/types/typedefs/index.d.ts", - "isExternalLibraryImport": false + "resolvedTypeReferenceDirective": { + "primary": true, + "resolvedFileName": "/types/typedefs/index.d.ts", + "isExternalLibraryImport": false + }, + "failedLookupLocations": [ + "/types/typedefs/package.json" + ] +} +typedefs2: { + "failedLookupLocations": [ + "/types/typedefs2/package.json", + "/types/typedefs2/index.d.ts", + "/node_modules/typedefs2/package.json", + "/node_modules/typedefs2.d.ts", + "/node_modules/typedefs2/index.d.ts", + "/node_modules/@types/typedefs2/package.json", + "/node_modules/@types/typedefs2.d.ts", + "/node_modules/@types/typedefs2/index.d.ts" + ] } -typedefs2: undefined MissingPaths:: ["lib.d.ts"] 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 ab8bf598964..362434f1daf 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 @@ -5,9 +5,11 @@ File: /a.ts import * as a from "a"; resolvedModules: a: { - "resolvedFileName": "/a.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "/a.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: undefined @@ -24,9 +26,11 @@ File: /a.ts import * as aa from "a"; resolvedModules: a: { - "resolvedFileName": "/a.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "/a.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/reuseProgramStructure/rootdir-changes.js b/tests/baselines/reference/reuseProgramStructure/rootdir-changes.js index 56d1a9aa679..563eddd3f96 100644 --- a/tests/baselines/reference/reuseProgramStructure/rootdir-changes.js +++ b/tests/baselines/reference/reuseProgramStructure/rootdir-changes.js @@ -23,7 +23,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.ts"] @@ -60,7 +71,18 @@ File: a.ts var x = 1 resolvedModules: undefined resolvedTypeReferenceDirectiveNames: -typerefs: undefined +typerefs: { + "failedLookupLocations": [ + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs/index.d.ts", + "node_modules/typerefs/package.json", + "node_modules/typerefs.d.ts", + "node_modules/typerefs/index.d.ts", + "node_modules/@types/typerefs/package.json", + "node_modules/@types/typerefs.d.ts", + "node_modules/@types/typerefs/index.d.ts" + ] +} MissingPaths:: ["non-existing-file.ts","lib.d.ts"] diff --git a/tests/baselines/reference/reuseProgramStructure/works-with-updated-SourceFiles.js b/tests/baselines/reference/reuseProgramStructure/works-with-updated-SourceFiles.js index e8b12c1ae16..90c3cb70935 100644 --- a/tests/baselines/reference/reuseProgramStructure/works-with-updated-SourceFiles.js +++ b/tests/baselines/reference/reuseProgramStructure/works-with-updated-SourceFiles.js @@ -5,9 +5,11 @@ File: /a.ts import * as a from "a";a; resolvedModules: a: { - "resolvedFileName": "/a.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "/a.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: undefined @@ -25,9 +27,11 @@ File: /a.ts import * as a from "a";a; resolvedModules: a: { - "resolvedFileName": "/a.ts", - "extension": ".ts", - "isExternalLibraryImport": false + "resolvedModule": { + "resolvedFileName": "/a.ts", + "extension": ".ts", + "isExternalLibraryImport": false + } } resolvedTypeReferenceDirectiveNames: undefined diff --git a/tests/baselines/reference/tscWatch/moduleResolution/diagnostics-from-cache.js b/tests/baselines/reference/tscWatch/moduleResolution/diagnostics-from-cache.js index b440517a7d2..7e384a4e5a5 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/diagnostics-from-cache.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/diagnostics-from-cache.js @@ -11,6 +11,10 @@ me.thing() export function thing(): void {} +//// [/user/username/projects/myproject/index2.ts] +export function thing(): void {} + + //// [/a/lib/lib.d.ts] /// interface Boolean {} @@ -28,7 +32,7 @@ interface Array { length: number; [n: number]: T; } /a/lib/tsc.js -w --traceResolution Output:: >> Screen clear -[12:00:23 AM] Starting compilation in watch mode... +[12:00:25 AM] Starting compilation in watch mode... Found 'package.json' at '/user/username/projects/myproject/package.json'. ======== Resolving module '@this/package' from '/user/username/projects/myproject/index.ts'. ======== @@ -40,27 +44,30 @@ Using 'exports' subpath '.' with target './dist/index.js'. File '/user/username/projects/myproject/index.ts' exist - use it as a name resolution result. Resolving real path for '/user/username/projects/myproject/index.ts', result '/user/username/projects/myproject/index.ts'. ======== Module name '@this/package' was successfully resolved to '/user/username/projects/myproject/index.ts'. ======== +File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist. error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file '/user/username/projects/myproject/package.json'. Supply the `rootDir` compiler option to disambiguate. -[12:00:34 AM] Found 1 error. Watching for file changes. +[12:00:40 AM] Found 1 error. Watching for file changes. -Program root files: ["/user/username/projects/myproject/index.ts"] +Program root files: ["/user/username/projects/myproject/index.ts","/user/username/projects/myproject/index2.ts"] Program options: {"moduleResolution":99,"outDir":"/user/username/projects/myproject/dist","declaration":true,"declarationDir":"/user/username/projects/myproject/types","watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} Program structureReused: Not Program files:: /a/lib/lib.d.ts /user/username/projects/myproject/index.ts +/user/username/projects/myproject/index2.ts No cached semantic diagnostics in the builder:: Shape signatures in builder refreshed for:: /a/lib/lib.d.ts (used version) /user/username/projects/myproject/index.ts (computed .d.ts during emit) +/user/username/projects/myproject/index2.ts (computed .d.ts during emit) PolledWatches:: /user/username/projects/myproject/node_modules/@types: @@ -71,6 +78,8 @@ FsWatches:: {} /user/username/projects/myproject/index.ts: {} +/user/username/projects/myproject/index2.ts: + {} /a/lib/lib.d.ts: {} /user/username/projects/myproject/package.json: @@ -96,3 +105,89 @@ exports.thing = thing; export declare function thing(): void; +//// [/user/username/projects/myproject/dist/index2.js] +"use strict"; +exports.__esModule = true; +exports.thing = void 0; +function thing() { } +exports.thing = thing; + + +//// [/user/username/projects/myproject/types/index2.d.ts] +export declare function thing(): void; + + + +Change:: Add import to index2 + +Input:: +//// [/user/username/projects/myproject/index2.ts] +import * as me from "./index.js";export function thing(): void {} + + + +Output:: +>> Screen clear +[12:00:43 AM] File change detected. Starting incremental compilation... + +File '/a/lib/package.json' does not exist according to earlier cached lookups. +File '/a/package.json' does not exist according to earlier cached lookups. +File '/package.json' does not exist according to earlier cached lookups. +File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. +File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. +File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. +Reusing resolution of module '@this/package' from '/user/username/projects/myproject/index.ts' of old program, it was successfully resolved to '/user/username/projects/myproject/index.ts'. +File '/user/username/projects/myproject/package.json' exists according to earlier cached lookups. +======== Resolving module './index.js' from '/user/username/projects/myproject/index2.ts'. ======== +Explicitly specified module resolution kind: 'NodeNext'. +Resolving in ESM mode with conditions 'node', 'import', 'types'. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/index.js', target file types: TypeScript, JavaScript, Declaration. +File name '/user/username/projects/myproject/index.js' has a '.js' extension - stripping it. +File '/user/username/projects/myproject/index.ts' exist - use it as a name resolution result. +======== Module name './index.js' was successfully resolved to '/user/username/projects/myproject/index.ts'. ======== +File '/a/lib/package.json' does not exist according to earlier cached lookups. +File '/a/package.json' does not exist according to earlier cached lookups. +File '/package.json' does not exist according to earlier cached lookups. +error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file '/user/username/projects/myproject/package.json'. Supply the `rootDir` compiler option to disambiguate. + +[12:00:50 AM] Found 1 error. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/index.ts","/user/username/projects/myproject/index2.ts"] +Program options: {"moduleResolution":99,"outDir":"/user/username/projects/myproject/dist","declaration":true,"declarationDir":"/user/username/projects/myproject/types","watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program structureReused: SafeModules +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/index.ts +/user/username/projects/myproject/index2.ts + +No cached semantic diagnostics in the builder:: + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/index2.ts (computed .d.ts) + +PolledWatches:: +/user/username/projects/myproject/node_modules/@types: + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/myproject/tsconfig.json: + {} +/user/username/projects/myproject/index.ts: + {} +/user/username/projects/myproject/index2.ts: + {} +/a/lib/lib.d.ts: + {} +/user/username/projects/myproject/package.json: + {} + +FsWatchesRecursive:: +/user/username/projects/myproject: + {} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/dist/index2.js] file written with same contents +//// [/user/username/projects/myproject/types/index2.d.ts] file written with same contents