From 9e4cd0ba1a13b8a7baf5f737cd662b5b65a0ccd7 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 15 Apr 2021 16:59:37 -0700 Subject: [PATCH 1/6] Make the module resolution cache apis for updating compiler options or clearing it --- src/compiler/moduleNameResolver.ts | 44 +++++++++++++++++-- src/compiler/resolutionCache.ts | 3 +- src/compiler/tsbuildPublic.ts | 38 +--------------- .../reference/api/tsserverlibrary.d.ts | 6 +++ tests/baselines/reference/api/typescript.d.ts | 6 +++ 5 files changed, 56 insertions(+), 41 deletions(-) diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 5348db0973d88..fb1651e2f4ad3 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -443,7 +443,12 @@ namespace ts { */ export interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; - /*@internal*/ directoryToModuleNameMap: CacheWithRedirects>; + clear(): void; + /** + * Updates with the current compilerOptions the cache will operate with. + * This updates the redirects map as well if needed so module resolutions are cached if they can across the projects + */ + update(options: CompilerOptions): void; } /** @@ -452,7 +457,6 @@ namespace ts { */ export interface NonRelativeModuleNameResolutionCache { getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache; - /*@internal*/ moduleNameToDirectoryMap: CacheWithRedirects; } export interface PerModuleNameCache { @@ -528,7 +532,41 @@ namespace ts { currentDirectory: string, getCanonicalFileName: GetCanonicalFileName): ModuleResolutionCache { - return { getOrCreateCacheForDirectory, getOrCreateCacheForModuleName, directoryToModuleNameMap, moduleNameToDirectoryMap }; + return { + getOrCreateCacheForDirectory, + getOrCreateCacheForModuleName, + clear, + update, + }; + + function clear() { + directoryToModuleNameMap.clear(); + moduleNameToDirectoryMap.clear(); + } + + function update(options: CompilerOptions) { + if (!options.configFile) return; + if (directoryToModuleNameMap.redirectsMap.size === 0) { + // The own map will be for projectCompilerOptions + Debug.assert(moduleNameToDirectoryMap.redirectsMap.size === 0); + Debug.assert(directoryToModuleNameMap.ownMap.size === 0); + Debug.assert(moduleNameToDirectoryMap.ownMap.size === 0); + directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.ownMap); + moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.ownMap); + } + else { + // Set correct own map + Debug.assert(moduleNameToDirectoryMap.redirectsMap.size > 0); + const ref: ResolvedProjectReference = { + sourceFile: options.configFile, + commandLine: { options } as ParsedCommandLine + }; + directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); + moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); + } + directoryToModuleNameMap.setOwnOptions(options); + moduleNameToDirectoryMap.setOwnOptions(options); + } function getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference) { const path = toPath(directoryName, currentDirectory, getCanonicalFileName); diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts index 68c32d26c5930..65dde198c286a 100644 --- a/src/compiler/resolutionCache.ts +++ b/src/compiler/resolutionCache.ts @@ -284,8 +284,7 @@ namespace ts { } function clearPerDirectoryResolutions() { - perDirectoryResolvedModuleNames.clear(); - nonRelativeModuleNameCache.clear(); + moduleResolutionCache.clear(); perDirectoryResolvedTypeReferenceDirectives.clear(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); diff --git a/src/compiler/tsbuildPublic.ts b/src/compiler/tsbuildPublic.ts index d642f79a12447..0ba733248266b 100644 --- a/src/compiler/tsbuildPublic.ts +++ b/src/compiler/tsbuildPublic.ts @@ -558,10 +558,7 @@ namespace ts { compilerHost.getSourceFile = cache.originalGetSourceFile; state.readFileWithCache = cache.originalReadFileWithCache; extendedConfigCache.clear(); - if (moduleResolutionCache) { - moduleResolutionCache.directoryToModuleNameMap.clear(); - moduleResolutionCache.moduleNameToDirectoryMap.clear(); - } + moduleResolutionCache?.clear(); state.cache = undefined; } @@ -842,7 +839,7 @@ namespace ts { const { host, compilerHost } = state; state.projectCompilerOptions = config.options; // Update module resolution cache if needed - updateModuleResolutionCache(state, project, config); + state.moduleResolutionCache?.update(config.options); // Create program program = host.createProgram( @@ -1306,37 +1303,6 @@ namespace ts { return { buildResult, step: BuildStep.QueueReferencingProjects }; } - function updateModuleResolutionCache( - state: SolutionBuilderState, - proj: ResolvedConfigFileName, - config: ParsedCommandLine - ) { - if (!state.moduleResolutionCache) return; - - // Update module resolution cache if needed - const { moduleResolutionCache } = state; - const projPath = toPath(state, proj); - if (moduleResolutionCache.directoryToModuleNameMap.redirectsMap.size === 0) { - // The own map will be for projectCompilerOptions - Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size === 0); - moduleResolutionCache.directoryToModuleNameMap.redirectsMap.set(projPath, moduleResolutionCache.directoryToModuleNameMap.ownMap); - moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.set(projPath, moduleResolutionCache.moduleNameToDirectoryMap.ownMap); - } - else { - // Set correct own map - Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size > 0); - - const ref: ResolvedProjectReference = { - sourceFile: config.options.configFile!, - commandLine: config - }; - moduleResolutionCache.directoryToModuleNameMap.setOwnMap(moduleResolutionCache.directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); - moduleResolutionCache.moduleNameToDirectoryMap.setOwnMap(moduleResolutionCache.moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); - } - moduleResolutionCache.directoryToModuleNameMap.setOwnOptions(config.options); - moduleResolutionCache.moduleNameToDirectoryMap.setOwnOptions(config.options); - } - function checkConfigFileUpToDateStatus(state: SolutionBuilderState, configFile: string, oldestOutputFileTime: Date, oldestOutputFileName: string): Status.OutOfDateWithSelf | undefined { // Check tsconfig time const tsconfigTime = getModifiedTime(state.host, configFile); diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index d692f38089939..b52222142dcc8 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -4729,6 +4729,12 @@ declare namespace ts { */ interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; + clear(): void; + /** + * Updates with the current compilerOptions the cache will operate with. + * This updates the redirects map as well if needed so module resolutions are cached if they can across the projects + */ + update(options: CompilerOptions): void; } /** * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index c6a45829f4910..efacca17e7cc4 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -4729,6 +4729,12 @@ declare namespace ts { */ interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; + clear(): void; + /** + * Updates with the current compilerOptions the cache will operate with. + * This updates the redirects map as well if needed so module resolutions are cached if they can across the projects + */ + update(options: CompilerOptions): void; } /** * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory From 55f0eecf43e4c0a988d3e79645eb51866c2b9637 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 19 Apr 2021 13:27:00 -0700 Subject: [PATCH 2/6] Cache package.json lookup results from module resolution --- src/compiler/diagnosticMessages.json | 8 +++ src/compiler/moduleNameResolver.ts | 69 +++++++++++++++---- src/compiler/program.ts | 15 +++- src/compiler/resolutionCache.ts | 8 ++- src/compiler/tsbuildPublic.ts | 11 ++- .../unittests/reuseProgramStructure.ts | 2 +- .../reference/api/tsserverlibrary.d.ts | 27 +++++--- tests/baselines/reference/api/typescript.d.ts | 27 +++++--- 8 files changed, 128 insertions(+), 39 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 270c1b7da3437..a25a5510f9e2e 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -5041,6 +5041,14 @@ "code": 6387, "reportsDeprecated": true }, + "Using cached result of 'package.json' at '{0}' that indicates it was found.": { + "category": "Message", + "code": 6388 + }, + "Using cached result of 'package.json' at '{0}' that indicates it was not found.": { + "category": "Message", + "code": 6389 + }, "The expected type comes from property '{0}' which is declared here on type '{1}'": { "category": "Message", diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index fb1651e2f4ad3..8e6838b793b86 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -101,9 +101,11 @@ namespace ts { traceEnabled: boolean; failedLookupLocations: Push; resultFromCache?: ResolvedModuleWithFailedLookupLocations; + packageJsonInfoCache: PackageJsonInfoCache | undefined; } /** Just the fields that we use for module resolution. */ + /*@internal*/ interface PackageJsonPathFields { typings?: string; types?: string; @@ -179,6 +181,7 @@ namespace ts { return typesVersions; } + /*@internal*/ interface VersionPaths { version: string; paths: MapLike; @@ -281,13 +284,13 @@ namespace ts { * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference): ResolvedTypeReferenceDirectiveWithFailedLookupLocations { + export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, packageJsonInfoCache?: PackageJsonInfoCache): ResolvedTypeReferenceDirectiveWithFailedLookupLocations { const traceEnabled = isTraceEnabled(options, host); if (redirectedReference) { options = redirectedReference.commandLine.options; } const failedLookupLocations: string[] = []; - const moduleResolutionState: ModuleResolutionState = { compilerOptions: options, host, traceEnabled, failedLookupLocations }; + const moduleResolutionState: ModuleResolutionState = { compilerOptions: options, host, traceEnabled, failedLookupLocations, packageJsonInfoCache }; const typeRoots = getEffectiveTypeRoots(options, host); if (traceEnabled) { @@ -441,7 +444,7 @@ namespace ts { * Cached module resolutions per containing directory. * This assumes that any module id will have the same resolution for sibling files located in the same folder. */ - export interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { + export interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache, PackageJsonInfoCache { getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; clear(): void; /** @@ -455,10 +458,16 @@ namespace ts { * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. */ - export interface NonRelativeModuleNameResolutionCache { + export interface NonRelativeModuleNameResolutionCache extends PackageJsonInfoCache { getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache; } + export interface PackageJsonInfoCache { + /*@internal*/ getPackageJsonInfo(packageJsonPath: string): PackageJsonInfo | boolean | undefined; + /*@internal*/ setPackageJsonInfo(packageJsonPath: string, info: PackageJsonInfo | boolean): void; + clear(): void; + } + export interface PerModuleNameCache { get(directory: string): ResolvedModuleWithFailedLookupLocations | undefined; set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; @@ -525,14 +534,29 @@ namespace ts { } } + export function createPackageJsonInfoCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): PackageJsonInfoCache { + let cache: ESMap | undefined; + return { getPackageJsonInfo, setPackageJsonInfo, clear }; + function getPackageJsonInfo(packageJsonPath: string) { + return cache?.get(toPath(packageJsonPath, currentDirectory, getCanonicalFileName)); + } + function setPackageJsonInfo(packageJsonPath: string, info: PackageJsonInfo | boolean) { + (cache ||= new Map()).set(toPath(packageJsonPath, currentDirectory, getCanonicalFileName), info); + } + function clear() { + cache = undefined; + } + } + /*@internal*/ export function createModuleResolutionCacheWithMaps( directoryToModuleNameMap: CacheWithRedirects>, moduleNameToDirectoryMap: CacheWithRedirects, currentDirectory: string, getCanonicalFileName: GetCanonicalFileName): ModuleResolutionCache { - + const packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName); return { + ...packageJsonInfoCache, getOrCreateCacheForDirectory, getOrCreateCacheForModuleName, clear, @@ -542,6 +566,7 @@ namespace ts { function clear() { directoryToModuleNameMap.clear(); moduleNameToDirectoryMap.clear(); + packageJsonInfoCache.clear(); } function update(options: CompilerOptions) { @@ -969,7 +994,7 @@ namespace ts { const traceEnabled = isTraceEnabled(compilerOptions, host); const failedLookupLocations: string[] = []; - const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations }; + const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations, packageJsonInfoCache: cache }; const result = forEach(extensions, ext => tryResolve(ext)); return createResolvedModuleWithFailedLookupLocations(result?.value?.resolved, result?.value?.isExternalLibraryImport, failedLookupLocations, state.resultFromCache); @@ -1175,6 +1200,7 @@ namespace ts { return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths)); } + /*@internal*/ interface PackageJsonInfo { packageDirectory: string; packageJsonContent: PackageJsonPathFields; @@ -1183,21 +1209,40 @@ namespace ts { function getPackageJsonInfo(packageDirectory: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PackageJsonInfo | undefined { const { host, traceEnabled } = state; - const directoryExists = !onlyRecordFailures && directoryProbablyExists(packageDirectory, host); const packageJsonPath = combinePaths(packageDirectory, "package.json"); + if (onlyRecordFailures) { + state.failedLookupLocations.push(packageJsonPath); + return undefined; + } + + const existing = state.packageJsonInfoCache?.getPackageJsonInfo(packageJsonPath); + if (existing !== undefined) { + if (typeof existing !== "boolean") { + if (traceEnabled) trace(host, Diagnostics.Using_cached_result_of_package_json_at_0_that_indicates_it_was_found, packageJsonPath); + return existing; + } + else { + if (existing && traceEnabled) trace(host, Diagnostics.Using_cached_result_of_package_json_at_0_that_indicates_it_was_not_found, packageJsonPath); + state.failedLookupLocations.push(packageJsonPath); + return undefined; + } + } + const directoryExists = directoryProbablyExists(packageDirectory, host); if (directoryExists && host.fileExists(packageJsonPath)) { const packageJsonContent = readJson(packageJsonPath, host) as PackageJson; if (traceEnabled) { trace(host, Diagnostics.Found_package_json_at_0, packageJsonPath); } const versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state); - return { packageDirectory, packageJsonContent, versionPaths }; + const result = { packageDirectory, packageJsonContent, versionPaths }; + state.packageJsonInfoCache?.setPackageJsonInfo(packageJsonPath, result); + return result; } else { if (directoryExists && traceEnabled) { trace(host, Diagnostics.File_0_does_not_exist, packageJsonPath); } - + state.packageJsonInfoCache?.setPackageJsonInfo(packageJsonPath, directoryExists); // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results state.failedLookupLocations.push(packageJsonPath); } @@ -1486,7 +1531,7 @@ namespace ts { export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations { const traceEnabled = isTraceEnabled(compilerOptions, host); const failedLookupLocations: string[] = []; - const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations }; + const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations, packageJsonInfoCache: cache }; const containingDirectory = getDirectoryPath(containingFile); const resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); @@ -1530,13 +1575,13 @@ namespace ts { * This is the minumum code needed to expose that functionality; the rest is in the host. */ /* @internal */ - export function loadModuleFromGlobalCache(moduleName: string, projectName: string | undefined, compilerOptions: CompilerOptions, host: ModuleResolutionHost, globalCache: string): ResolvedModuleWithFailedLookupLocations { + export function loadModuleFromGlobalCache(moduleName: string, projectName: string | undefined, compilerOptions: CompilerOptions, host: ModuleResolutionHost, globalCache: string, packageJsonInfoCache: PackageJsonInfoCache): ResolvedModuleWithFailedLookupLocations { const traceEnabled = isTraceEnabled(compilerOptions, host); if (traceEnabled) { trace(host, Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache); } const failedLookupLocations: string[] = []; - const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations }; + const state: ModuleResolutionState = { compilerOptions, host, traceEnabled, failedLookupLocations, packageJsonInfoCache }; const resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false); return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache); } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 29231b7fa5786..6f3fb4eeb1092 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -843,6 +843,7 @@ namespace ts { let _compilerOptionsObjectLiteralSyntax: ObjectLiteralExpression | false | undefined; let moduleResolutionCache: ModuleResolutionCache | undefined; + let packageJsonInfoCache: PackageJsonInfoCache | undefined; let actualResolveModuleNamesWorker: (moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference) => ResolvedModuleFull[]; const hasInvalidatedResolution = host.hasInvalidatedResolution || returnFalse; if (host.resolveModuleNames) { @@ -857,7 +858,7 @@ namespace ts { }); } else { - moduleResolutionCache = createModuleResolutionCache(currentDirectory, x => host.getCanonicalFileName(x), options); + moduleResolutionCache = createModuleResolutionCache(currentDirectory, getCanonicalFileName, options); const loader = (moduleName: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule!; // TODO: GH#18217 actualResolveModuleNamesWorker = (moduleNames, containingFile, _reusedNames, redirectedReference) => loadWithLocalCache(Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader); } @@ -867,7 +868,15 @@ namespace ts { actualResolveTypeReferenceDirectiveNamesWorker = (typeDirectiveNames, containingFile, redirectedReference) => host.resolveTypeReferenceDirectives!(Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); } else { - const loader = (typesRef: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective!; // TODO: GH#18217 + packageJsonInfoCache = moduleResolutionCache || createPackageJsonInfoCache(currentDirectory, getCanonicalFileName); + const loader = (typesRef: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveTypeReferenceDirective( + typesRef, + containingFile, + options, + host, + redirectedReference, + packageJsonInfoCache, + ).resolvedTypeReferenceDirective!; // TODO: GH#18217 actualResolveTypeReferenceDirectiveNamesWorker = (typeReferenceDirectiveNames, containingFile, redirectedReference) => loadWithLocalCache(Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader); } @@ -1036,6 +1045,8 @@ namespace ts { ); } + packageJsonInfoCache = undefined; + // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts index 65dde198c286a..28ebf28e52739 100644 --- a/src/compiler/resolutionCache.ts +++ b/src/compiler/resolutionCache.ts @@ -319,7 +319,9 @@ namespace ts { resolutionHost.projectName, compilerOptions, host, - globalCache); + globalCache, + moduleResolutionCache, + ); if (resolvedModule) { // Modify existing resolution so its saved in the directory cache as well (primaryResult.resolvedModule as any) = resolvedModule; @@ -332,6 +334,10 @@ namespace ts { return primaryResult; } + function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference): CachedResolvedTypeReferenceDirectiveWithFailedLookupLocations { + return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, moduleResolutionCache); + } + interface ResolveNamesWithLocalCacheInput { names: readonly string[]; containingFile: string; diff --git a/src/compiler/tsbuildPublic.ts b/src/compiler/tsbuildPublic.ts index 0ba733248266b..65a889cc277f8 100644 --- a/src/compiler/tsbuildPublic.ts +++ b/src/compiler/tsbuildPublic.ts @@ -238,6 +238,7 @@ namespace ts { readonly compilerHost: CompilerHost; readonly moduleResolutionCache: ModuleResolutionCache | undefined; + readonly packageJsonInfoCache: PackageJsonInfoCache | undefined; // Mutable state buildOrder: AnyBuildOrder | undefined; @@ -275,11 +276,17 @@ namespace ts { compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives); const moduleResolutionCache = !compilerHost.resolveModuleNames ? createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined; + const packageJsonInfoCache = !compilerHost.resolveTypeReferenceDirectives ? moduleResolutionCache || createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) : undefined; if (!compilerHost.resolveModuleNames) { const loader = (moduleName: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule!; compilerHost.resolveModuleNames = (moduleNames, containingFile, _reusedNames, redirectedReference) => loadWithLocalCache(Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader); } + if (!compilerHost.resolveTypeReferenceDirectives) { + const loader = (moduleName: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.packageJsonInfoCache).resolvedTypeReferenceDirective!; + compilerHost.resolveTypeReferenceDirectives = (typeReferenceDirectiveNames, containingFile, redirectedReference) => + loadWithLocalCache(Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader); + } const { watchFile, watchDirectory, writeLog } = createWatchFactory(hostWithWatch, options); @@ -310,6 +317,7 @@ namespace ts { compilerHost, moduleResolutionCache, + packageJsonInfoCache, // Mutable state buildOrder: undefined, @@ -548,7 +556,7 @@ namespace ts { function disableCache(state: SolutionBuilderState) { if (!state.cache) return; - const { cache, host, compilerHost, extendedConfigCache, moduleResolutionCache } = state; + const { cache, host, compilerHost, extendedConfigCache, moduleResolutionCache, packageJsonInfoCache } = state; host.readFile = cache.originalReadFile; host.fileExists = cache.originalFileExists; @@ -559,6 +567,7 @@ namespace ts { state.readFileWithCache = cache.originalReadFileWithCache; extendedConfigCache.clear(); moduleResolutionCache?.clear(); + packageJsonInfoCache?.clear(); state.cache = undefined; } diff --git a/src/testRunner/unittests/reuseProgramStructure.ts b/src/testRunner/unittests/reuseProgramStructure.ts index 173113f134dcc..6f185b75312d8 100644 --- a/src/testRunner/unittests/reuseProgramStructure.ts +++ b/src/testRunner/unittests/reuseProgramStructure.ts @@ -474,7 +474,7 @@ namespace ts { "File 'node_modules/@types/a.d.ts' does not exist.", "File 'node_modules/@types/a/index.d.ts' does not exist.", "Loading module 'a' from 'node_modules' folder, target file type 'JavaScript'.", - "File 'node_modules/a/package.json' does not exist.", + "Using cached result of 'package.json' at 'node_modules/a/package.json' that indicates it was not found.", "File 'node_modules/a.js' does not exist.", "File 'node_modules/a.jsx' does not exist.", "File 'node_modules/a/index.js' does not exist.", diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index b52222142dcc8..f5edd8edc5330 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -4707,13 +4707,13 @@ declare namespace ts { export {}; } declare namespace ts { - function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; + export function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, packageJsonInfoCache?: PackageJsonInfoCache): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; /** * Given a set of options, returns the set of type directive names * that should be included for this program automatically. @@ -4722,12 +4722,12 @@ declare namespace ts { * More type directives might appear in the program later as a result of loading actual source files; * this list is only the set of defaults that are implicitly included. */ - function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; + export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; /** * Cached module resolutions per containing directory. * This assumes that any module id will have the same resolution for sibling files located in the same folder. */ - interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { + export interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache, PackageJsonInfoCache { getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; clear(): void; /** @@ -4740,18 +4740,23 @@ declare namespace ts { * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. */ - interface NonRelativeModuleNameResolutionCache { + export interface NonRelativeModuleNameResolutionCache extends PackageJsonInfoCache { getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache; } - interface PerModuleNameCache { + export interface PackageJsonInfoCache { + clear(): void; + } + export interface PerModuleNameCache { get(directory: string): ResolvedModuleWithFailedLookupLocations | undefined; set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; } - function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache; - function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache; + export function createPackageJsonInfoCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): PackageJsonInfoCache; + export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; + export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export {}; } declare namespace ts { /** diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index efacca17e7cc4..f409cccf55149 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -4707,13 +4707,13 @@ declare namespace ts { export {}; } declare namespace ts { - function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; + export function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, packageJsonInfoCache?: PackageJsonInfoCache): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; /** * Given a set of options, returns the set of type directive names * that should be included for this program automatically. @@ -4722,12 +4722,12 @@ declare namespace ts { * More type directives might appear in the program later as a result of loading actual source files; * this list is only the set of defaults that are implicitly included. */ - function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; + export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; /** * Cached module resolutions per containing directory. * This assumes that any module id will have the same resolution for sibling files located in the same folder. */ - interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache { + export interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache, PackageJsonInfoCache { getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; clear(): void; /** @@ -4740,18 +4740,23 @@ declare namespace ts { * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. */ - interface NonRelativeModuleNameResolutionCache { + export interface NonRelativeModuleNameResolutionCache extends PackageJsonInfoCache { getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache; } - interface PerModuleNameCache { + export interface PackageJsonInfoCache { + clear(): void; + } + export interface PerModuleNameCache { get(directory: string): ResolvedModuleWithFailedLookupLocations | undefined; set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; } - function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache; - function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; - function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache; + export function createPackageJsonInfoCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): PackageJsonInfoCache; + export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; + export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; + export {}; } declare namespace ts { /** From 116b9b33ccac72aac65f25cbd9615ea42644b007 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 19 Apr 2021 15:24:49 -0700 Subject: [PATCH 3/6] Use per directory cache for type reference directive resolution as well --- src/compiler/diagnosticMessages.json | 24 +- src/compiler/moduleNameResolver.ts | 236 ++++++++++++------ src/compiler/program.ts | 8 +- src/compiler/resolutionCache.ts | 18 +- src/compiler/tsbuildPublic.ts | 12 +- .../reference/api/tsserverlibrary.d.ts | 15 +- tests/baselines/reference/api/typescript.d.ts | 15 +- 7 files changed, 222 insertions(+), 106 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index a25a5510f9e2e..5fa04cff3bcf9 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4849,6 +4849,22 @@ "category": "Error", "code": 6238 }, + "Using cached result of 'package.json' at '{0}' that indicates it was found.": { + "category": "Message", + "code": 6239 + }, + "Using cached result of 'package.json' at '{0}' that indicates it was not found.": { + "category": "Message", + "code": 6240 + }, + "Resolution for type reference directive '{0}' was found in cache from location '{1}'.": { + "category": "Message", + "code": 6241 + }, + "======== Resolving type reference directive '{0}', containing file '{1}'. ========": { + "category": "Message", + "code": 6242 + }, "Projects to reference": { "category": "Message", @@ -5041,14 +5057,6 @@ "code": 6387, "reportsDeprecated": true }, - "Using cached result of 'package.json' at '{0}' that indicates it was found.": { - "category": "Message", - "code": 6388 - }, - "Using cached result of 'package.json' at '{0}' that indicates it was not found.": { - "category": "Message", - "code": 6389 - }, "The expected type comes from property '{0}' which is declared here on type '{1}'": { "category": "Message", diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 8e6838b793b86..f59b265652ad7 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -284,13 +284,24 @@ namespace ts { * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, packageJsonInfoCache?: PackageJsonInfoCache): ResolvedTypeReferenceDirectiveWithFailedLookupLocations { + export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, cache?: TypeReferenceDirectiveResolutionCache): ResolvedTypeReferenceDirectiveWithFailedLookupLocations { const traceEnabled = isTraceEnabled(options, host); if (redirectedReference) { options = redirectedReference.commandLine.options; } - const failedLookupLocations: string[] = []; - const moduleResolutionState: ModuleResolutionState = { compilerOptions: options, host, traceEnabled, failedLookupLocations, packageJsonInfoCache }; + + const containingDirectory = containingFile ? getDirectoryPath(containingFile) : undefined; + const perFolderCache = containingDirectory ? cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference) : undefined; + let result = perFolderCache && perFolderCache.get(typeReferenceDirectiveName); + if (result) { + if (traceEnabled) { + trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1, typeReferenceDirectiveName, containingFile); + if (redirectedReference) trace(host, Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName); + trace(host, Diagnostics.Resolution_for_type_reference_directive_0_was_found_in_cache_from_location_1, typeReferenceDirectiveName, containingDirectory); + traceResult(result); + } + return result; + } const typeRoots = getEffectiveTypeRoots(options, host); if (traceEnabled) { @@ -315,6 +326,8 @@ namespace ts { } } + const failedLookupLocations: string[] = []; + const moduleResolutionState: ModuleResolutionState = { compilerOptions: options, host, traceEnabled, failedLookupLocations, packageJsonInfoCache: cache }; let resolved = primaryLookup(); let primary = true; if (!resolved) { @@ -326,18 +339,24 @@ namespace ts { if (resolved) { const { fileName, packageId } = resolved; const resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled); - if (traceEnabled) { - if (packageId) { - trace(host, Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, resolvedFileName, packageIdToString(packageId), primary); - } - else { - trace(host, Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary); - } - } resolvedTypeReferenceDirective = { primary, resolvedFileName, packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) }; } + result = { resolvedTypeReferenceDirective, failedLookupLocations }; + perFolderCache?.set(typeReferenceDirectiveName, result); + if (traceEnabled) traceResult(result); + return result; - return { resolvedTypeReferenceDirective, failedLookupLocations }; + function traceResult(result: ResolvedTypeReferenceDirectiveWithFailedLookupLocations) { + if (!result.resolvedTypeReferenceDirective?.resolvedFileName) { + trace(host, Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); + } + else if (result.resolvedTypeReferenceDirective.packageId) { + trace(host, Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, packageIdToString(result.resolvedTypeReferenceDirective.packageId), result.resolvedTypeReferenceDirective.primary); + } + else { + trace(host, Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, result.resolvedTypeReferenceDirective.resolvedFileName, result.resolvedTypeReferenceDirective.primary); + } + } function primaryLookup(): PathAndPackageId | undefined { // Check primary library paths @@ -381,11 +400,7 @@ namespace ts { const { path: candidate } = normalizePathAndParts(combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)); result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true); } - const resolvedFile = resolvedTypeScriptOnly(result); - if (!resolvedFile && traceEnabled) { - trace(host, Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName); - } - return resolvedFile; + return resolvedTypeScriptOnly(result); } else { if (traceEnabled) { @@ -440,12 +455,15 @@ namespace ts { return result; } + export interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache, PackageJsonInfoCache { + } + /** - * Cached module resolutions per containing directory. + * Cached resolutions per containing directory. * This assumes that any module id will have the same resolution for sibling files located in the same folder. */ - export interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache, PackageJsonInfoCache { - getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; + export interface PerDirectoryResolutionCache { + getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; clear(): void; /** * Updates with the current compilerOptions the cache will operate with. @@ -454,6 +472,10 @@ namespace ts { update(options: CompilerOptions): void; } + export interface ModuleResolutionCache extends PerDirectoryResolutionCache, NonRelativeModuleNameResolutionCache, PackageJsonInfoCache { + getPackageJsonInfoCache(): PackageJsonInfoCache; + } + /** * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. @@ -473,16 +495,6 @@ namespace ts { set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; } - export function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache { - return createModuleResolutionCacheWithMaps( - createCacheWithRedirects(options), - createCacheWithRedirects(options), - currentDirectory, - getCanonicalFileName - ); - } - - /*@internal*/ export interface CacheWithRedirects { ownMap: ESMap; @@ -534,7 +546,7 @@ namespace ts { } } - export function createPackageJsonInfoCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): PackageJsonInfoCache { + function createPackageJsonInfoCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): PackageJsonInfoCache { let cache: ESMap | undefined; return { getPackageJsonInfo, setPackageJsonInfo, clear }; function getPackageJsonInfo(packageJsonPath: string) { @@ -548,69 +560,111 @@ namespace ts { } } + function getOrCreateCache(cacheWithRedirects: CacheWithRedirects, redirectedReference: ResolvedProjectReference | undefined, key: string, create: () => T): T { + const cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); + let result = cache.get(key); + if (!result) { + result = create(); + cache.set(key, result); + } + return result; + } + + function updateRedirectsMap( + options: CompilerOptions, + directoryToModuleNameMap: CacheWithRedirects>, + moduleNameToDirectoryMap?: CacheWithRedirects + ) { + if (!options.configFile) return; + if (directoryToModuleNameMap.redirectsMap.size === 0) { + // The own map will be for projectCompilerOptions + Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size === 0); + Debug.assert(directoryToModuleNameMap.ownMap.size === 0); + Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.ownMap.size === 0); + directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.ownMap); + moduleNameToDirectoryMap?.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.ownMap); + } + else { + // Set correct own map + Debug.assert(!moduleNameToDirectoryMap || moduleNameToDirectoryMap.redirectsMap.size > 0); + const ref: ResolvedProjectReference = { + sourceFile: options.configFile, + commandLine: { options } as ParsedCommandLine + }; + directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); + moduleNameToDirectoryMap?.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); + } + directoryToModuleNameMap.setOwnOptions(options); + moduleNameToDirectoryMap?.setOwnOptions(options); + } + + function createPerDirectoryResolutionCache(currentDirectory: string, getCanonicalFileName: GetCanonicalFileName, directoryToModuleNameMap: CacheWithRedirects>): PerDirectoryResolutionCache { + return { + getOrCreateCacheForDirectory, + clear, + update, + }; + + function clear() { + directoryToModuleNameMap.clear(); + } + + function update(options: CompilerOptions) { + updateRedirectsMap(options, directoryToModuleNameMap); + } + + function getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference) { + const path = toPath(directoryName, currentDirectory, getCanonicalFileName); + return getOrCreateCache>(directoryToModuleNameMap, redirectedReference, path, () => new Map()); + } + } + + export function createModuleResolutionCache( + currentDirectory: string, + getCanonicalFileName: (s: string) => string, + options?: CompilerOptions + ): ModuleResolutionCache; /*@internal*/ - export function createModuleResolutionCacheWithMaps( + export function createModuleResolutionCache( + currentDirectory: string, + getCanonicalFileName: GetCanonicalFileName, + options: undefined, directoryToModuleNameMap: CacheWithRedirects>, moduleNameToDirectoryMap: CacheWithRedirects, + ): ModuleResolutionCache; + export function createModuleResolutionCache( currentDirectory: string, - getCanonicalFileName: GetCanonicalFileName): ModuleResolutionCache { + getCanonicalFileName: GetCanonicalFileName, + options?: CompilerOptions, + directoryToModuleNameMap?: CacheWithRedirects>, + moduleNameToDirectoryMap?: CacheWithRedirects, + ): ModuleResolutionCache { + const preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap ||= createCacheWithRedirects(options)); + moduleNameToDirectoryMap ||= createCacheWithRedirects(options); const packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName); + return { ...packageJsonInfoCache, - getOrCreateCacheForDirectory, + ...preDirectoryResolutionCache, getOrCreateCacheForModuleName, clear, update, + getPackageJsonInfoCache: () => packageJsonInfoCache, }; function clear() { - directoryToModuleNameMap.clear(); - moduleNameToDirectoryMap.clear(); + preDirectoryResolutionCache.clear(); + moduleNameToDirectoryMap!.clear(); packageJsonInfoCache.clear(); } function update(options: CompilerOptions) { - if (!options.configFile) return; - if (directoryToModuleNameMap.redirectsMap.size === 0) { - // The own map will be for projectCompilerOptions - Debug.assert(moduleNameToDirectoryMap.redirectsMap.size === 0); - Debug.assert(directoryToModuleNameMap.ownMap.size === 0); - Debug.assert(moduleNameToDirectoryMap.ownMap.size === 0); - directoryToModuleNameMap.redirectsMap.set(options.configFile.path, directoryToModuleNameMap.ownMap); - moduleNameToDirectoryMap.redirectsMap.set(options.configFile.path, moduleNameToDirectoryMap.ownMap); - } - else { - // Set correct own map - Debug.assert(moduleNameToDirectoryMap.redirectsMap.size > 0); - const ref: ResolvedProjectReference = { - sourceFile: options.configFile, - commandLine: { options } as ParsedCommandLine - }; - directoryToModuleNameMap.setOwnMap(directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref)); - moduleNameToDirectoryMap.setOwnMap(moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref)); - } - directoryToModuleNameMap.setOwnOptions(options); - moduleNameToDirectoryMap.setOwnOptions(options); - } - - function getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference) { - const path = toPath(directoryName, currentDirectory, getCanonicalFileName); - return getOrCreateCache>(directoryToModuleNameMap, redirectedReference, path, () => new Map()); + updateRedirectsMap(options, directoryToModuleNameMap!, moduleNameToDirectoryMap); } function getOrCreateCacheForModuleName(nonRelativeModuleName: string, redirectedReference?: ResolvedProjectReference): PerModuleNameCache { Debug.assert(!isExternalModuleNameRelative(nonRelativeModuleName)); - return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache); - } - - function getOrCreateCache(cacheWithRedirects: CacheWithRedirects, redirectedReference: ResolvedProjectReference | undefined, key: string, create: () => T): T { - const cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); - let result = cache.get(key); - if (!result) { - result = create(); - cache.set(key, result); - } - return result; + return getOrCreateCache(moduleNameToDirectoryMap!, redirectedReference, nonRelativeModuleName, createPerModuleNameCache); } function createPerModuleNameCache(): PerModuleNameCache { @@ -686,6 +740,42 @@ namespace ts { } } + export function createTypeReferenceDirectiveResolutionCache( + currentDirectory: string, + getCanonicalFileName: (s: string) => string, + options?: CompilerOptions, + packageJsonInfoCache?: PackageJsonInfoCache, + ): TypeReferenceDirectiveResolutionCache; + /*@internal*/ + export function createTypeReferenceDirectiveResolutionCache( + currentDirectory: string, + getCanonicalFileName: GetCanonicalFileName, + options: undefined, + packageJsonInfoCache: PackageJsonInfoCache | undefined, + directoryToModuleNameMap: CacheWithRedirects>, + ): TypeReferenceDirectiveResolutionCache; + export function createTypeReferenceDirectiveResolutionCache( + currentDirectory: string, + getCanonicalFileName: GetCanonicalFileName, + options?: CompilerOptions, + packageJsonInfoCache?: PackageJsonInfoCache | undefined, + directoryToModuleNameMap?: CacheWithRedirects>, + ): TypeReferenceDirectiveResolutionCache { + const preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap ||= createCacheWithRedirects(options)); + packageJsonInfoCache ||= createPackageJsonInfoCache(currentDirectory, getCanonicalFileName); + + return { + ...packageJsonInfoCache, + ...preDirectoryResolutionCache, + clear, + }; + + function clear() { + preDirectoryResolutionCache.clear(); + packageJsonInfoCache!.clear(); + } + } + export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined { const containingDirectory = getDirectoryPath(containingFile); const perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 6f3fb4eeb1092..869202fe2ed5c 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -843,7 +843,7 @@ namespace ts { let _compilerOptionsObjectLiteralSyntax: ObjectLiteralExpression | false | undefined; let moduleResolutionCache: ModuleResolutionCache | undefined; - let packageJsonInfoCache: PackageJsonInfoCache | undefined; + let typeReferenceDirectiveResolutionCache: TypeReferenceDirectiveResolutionCache | undefined; let actualResolveModuleNamesWorker: (moduleNames: string[], containingFile: string, reusedNames?: string[], redirectedReference?: ResolvedProjectReference) => ResolvedModuleFull[]; const hasInvalidatedResolution = host.hasInvalidatedResolution || returnFalse; if (host.resolveModuleNames) { @@ -868,14 +868,14 @@ namespace ts { actualResolveTypeReferenceDirectiveNamesWorker = (typeDirectiveNames, containingFile, redirectedReference) => host.resolveTypeReferenceDirectives!(Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); } else { - packageJsonInfoCache = moduleResolutionCache || createPackageJsonInfoCache(currentDirectory, getCanonicalFileName); + typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache?.getPackageJsonInfoCache()); const loader = (typesRef: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveTypeReferenceDirective( typesRef, containingFile, options, host, redirectedReference, - packageJsonInfoCache, + typeReferenceDirectiveResolutionCache, ).resolvedTypeReferenceDirective!; // TODO: GH#18217 actualResolveTypeReferenceDirectiveNamesWorker = (typeReferenceDirectiveNames, containingFile, redirectedReference) => loadWithLocalCache(Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader); } @@ -1045,7 +1045,7 @@ namespace ts { ); } - packageJsonInfoCache = undefined; + typeReferenceDirectiveResolutionCache = undefined; // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts index 28ebf28e52739..cb7de929e70f9 100644 --- a/src/compiler/resolutionCache.ts +++ b/src/compiler/resolutionCache.ts @@ -166,15 +166,23 @@ namespace ts { const resolvedModuleNames = new Map>(); const perDirectoryResolvedModuleNames: CacheWithRedirects> = createCacheWithRedirects(); const nonRelativeModuleNameCache: CacheWithRedirects = createCacheWithRedirects(); - const moduleResolutionCache = createModuleResolutionCacheWithMaps( + const moduleResolutionCache = createModuleResolutionCache( + getCurrentDirectory(), + resolutionHost.getCanonicalFileName, + /*options*/ undefined, perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, - getCurrentDirectory(), - resolutionHost.getCanonicalFileName ); const resolvedTypeReferenceDirectives = new Map>(); const perDirectoryResolvedTypeReferenceDirectives: CacheWithRedirects> = createCacheWithRedirects(); + const typeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache( + getCurrentDirectory(), + resolutionHost.getCanonicalFileName, + /*options*/ undefined, + moduleResolutionCache.getPackageJsonInfoCache(), + perDirectoryResolvedTypeReferenceDirectives + ); /** * These are the extensions that failed lookup files will have by default, @@ -285,7 +293,7 @@ namespace ts { function clearPerDirectoryResolutions() { moduleResolutionCache.clear(); - perDirectoryResolvedTypeReferenceDirectives.clear(); + typeReferenceDirectiveResolutionCache.clear(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); } @@ -335,7 +343,7 @@ namespace ts { } function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference): CachedResolvedTypeReferenceDirectiveWithFailedLookupLocations { - return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, moduleResolutionCache); + return ts.resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, typeReferenceDirectiveResolutionCache); } interface ResolveNamesWithLocalCacheInput { diff --git a/src/compiler/tsbuildPublic.ts b/src/compiler/tsbuildPublic.ts index 65a889cc277f8..1e9c5ec23a6a9 100644 --- a/src/compiler/tsbuildPublic.ts +++ b/src/compiler/tsbuildPublic.ts @@ -238,7 +238,7 @@ namespace ts { readonly compilerHost: CompilerHost; readonly moduleResolutionCache: ModuleResolutionCache | undefined; - readonly packageJsonInfoCache: PackageJsonInfoCache | undefined; + readonly typeReferenceDirectiveResolutionCache: TypeReferenceDirectiveResolutionCache | undefined; // Mutable state buildOrder: AnyBuildOrder | undefined; @@ -276,14 +276,14 @@ namespace ts { compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives); const moduleResolutionCache = !compilerHost.resolveModuleNames ? createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined; - const packageJsonInfoCache = !compilerHost.resolveTypeReferenceDirectives ? moduleResolutionCache || createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) : undefined; + const typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache?.getPackageJsonInfoCache()) : undefined; if (!compilerHost.resolveModuleNames) { const loader = (moduleName: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule!; compilerHost.resolveModuleNames = (moduleNames, containingFile, _reusedNames, redirectedReference) => loadWithLocalCache(Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader); } if (!compilerHost.resolveTypeReferenceDirectives) { - const loader = (moduleName: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.packageJsonInfoCache).resolvedTypeReferenceDirective!; + const loader = (moduleName: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective!; compilerHost.resolveTypeReferenceDirectives = (typeReferenceDirectiveNames, containingFile, redirectedReference) => loadWithLocalCache(Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader); } @@ -317,7 +317,7 @@ namespace ts { compilerHost, moduleResolutionCache, - packageJsonInfoCache, + typeReferenceDirectiveResolutionCache, // Mutable state buildOrder: undefined, @@ -556,7 +556,7 @@ namespace ts { function disableCache(state: SolutionBuilderState) { if (!state.cache) return; - const { cache, host, compilerHost, extendedConfigCache, moduleResolutionCache, packageJsonInfoCache } = state; + const { cache, host, compilerHost, extendedConfigCache, moduleResolutionCache, typeReferenceDirectiveResolutionCache } = state; host.readFile = cache.originalReadFile; host.fileExists = cache.originalFileExists; @@ -567,7 +567,7 @@ namespace ts { state.readFileWithCache = cache.originalReadFileWithCache; extendedConfigCache.clear(); moduleResolutionCache?.clear(); - packageJsonInfoCache?.clear(); + typeReferenceDirectiveResolutionCache?.clear(); state.cache = undefined; } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index f5edd8edc5330..9fe75059b2590 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -4713,7 +4713,7 @@ declare namespace ts { * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, packageJsonInfoCache?: PackageJsonInfoCache): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, cache?: TypeReferenceDirectiveResolutionCache): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; /** * Given a set of options, returns the set of type directive names * that should be included for this program automatically. @@ -4723,12 +4723,14 @@ declare namespace ts { * this list is only the set of defaults that are implicitly included. */ export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; + export interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache, PackageJsonInfoCache { + } /** - * Cached module resolutions per containing directory. + * Cached resolutions per containing directory. * This assumes that any module id will have the same resolution for sibling files located in the same folder. */ - export interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache, PackageJsonInfoCache { - getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; + export interface PerDirectoryResolutionCache { + getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; clear(): void; /** * Updates with the current compilerOptions the cache will operate with. @@ -4736,6 +4738,9 @@ declare namespace ts { */ update(options: CompilerOptions): void; } + export interface ModuleResolutionCache extends PerDirectoryResolutionCache, NonRelativeModuleNameResolutionCache, PackageJsonInfoCache { + getPackageJsonInfoCache(): PackageJsonInfoCache; + } /** * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. @@ -4751,7 +4756,7 @@ declare namespace ts { set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; } export function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache; - export function createPackageJsonInfoCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): PackageJsonInfoCache; + export function createTypeReferenceDirectiveResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions, packageJsonInfoCache?: PackageJsonInfoCache): TypeReferenceDirectiveResolutionCache; export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index f409cccf55149..44f89d9061b35 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -4713,7 +4713,7 @@ declare namespace ts { * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups * is assumed to be the same as root directory of the project. */ - export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, packageJsonInfoCache?: PackageJsonInfoCache): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; + export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost, redirectedReference?: ResolvedProjectReference, cache?: TypeReferenceDirectiveResolutionCache): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; /** * Given a set of options, returns the set of type directive names * that should be included for this program automatically. @@ -4723,12 +4723,14 @@ declare namespace ts { * this list is only the set of defaults that are implicitly included. */ export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; + export interface TypeReferenceDirectiveResolutionCache extends PerDirectoryResolutionCache, PackageJsonInfoCache { + } /** - * Cached module resolutions per containing directory. + * Cached resolutions per containing directory. * This assumes that any module id will have the same resolution for sibling files located in the same folder. */ - export interface ModuleResolutionCache extends NonRelativeModuleNameResolutionCache, PackageJsonInfoCache { - getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; + export interface PerDirectoryResolutionCache { + getOrCreateCacheForDirectory(directoryName: string, redirectedReference?: ResolvedProjectReference): Map; clear(): void; /** * Updates with the current compilerOptions the cache will operate with. @@ -4736,6 +4738,9 @@ declare namespace ts { */ update(options: CompilerOptions): void; } + export interface ModuleResolutionCache extends PerDirectoryResolutionCache, NonRelativeModuleNameResolutionCache, PackageJsonInfoCache { + getPackageJsonInfoCache(): PackageJsonInfoCache; + } /** * Stored map from non-relative module name to a table: directory -> result of module lookup in this directory * We support only non-relative module names because resolution of relative module names is usually more deterministic and thus less expensive. @@ -4751,7 +4756,7 @@ declare namespace ts { set(directory: string, result: ResolvedModuleWithFailedLookupLocations): void; } export function createModuleResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions): ModuleResolutionCache; - export function createPackageJsonInfoCache(currentDirectory: string, getCanonicalFileName: (s: string) => string): PackageJsonInfoCache; + export function createTypeReferenceDirectiveResolutionCache(currentDirectory: string, getCanonicalFileName: (s: string) => string, options?: CompilerOptions, packageJsonInfoCache?: PackageJsonInfoCache): TypeReferenceDirectiveResolutionCache; export function resolveModuleNameFromCache(moduleName: string, containingFile: string, cache: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations | undefined; export function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; From 4466eb47e0e101f083746845a48b4f35eaf1a72c Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Tue, 20 Apr 2021 05:35:19 +0000 Subject: [PATCH 4/6] Update Baselines and/or Applied Lint Fixes --- ...kage_relativeImportWithinPackage.trace.json | 3 +-- ...lativeImportWithinPackage_scoped.trace.json | 3 +-- .../importWithTrailingSlash.trace.json | 2 +- .../reference/library-reference-1.trace.json | 7 ++----- .../reference/library-reference-10.trace.json | 9 ++------- .../reference/library-reference-2.trace.json | 3 +-- .../reference/library-reference-6.trace.json | 2 +- .../reference/library-reference-8.trace.json | 18 ++++++------------ ...xNodeModuleJsDepthDefaultsToZero.trace.json | 2 +- ...ageIdWithRelativeAndAbsolutePath.trace.json | 3 +-- ...olutionWithExtensions_unexpected.trace.json | 3 +-- ...lutionWithExtensions_unexpected2.trace.json | 3 +-- ...ithExtensions_withAmbientPresent.trace.json | 2 +- ...solutionWithExtensions_withPaths.trace.json | 2 +- ...ionWithSymlinks_preserveSymlinks.trace.json | 4 ++-- ...ion_packageJson_yesAtPackageRoot.trace.json | 5 ++--- ...sAtPackageRoot_fakeScopedPackage.trace.json | 5 ++--- .../reference/packageJsonMain.trace.json | 9 +++------ .../packageJsonMain_isNonRecursive.trace.json | 3 +-- ...withExtension_MapedToNodeModules.trace.json | 2 +- ...tResolveJsonModuleAndPathMapping.trace.json | 2 +- .../requireOfJsonFile_PathMapping.trace.json | 4 ++-- .../reference/scopedPackages.trace.json | 2 +- .../typeReferenceDirectives1.trace.json | 7 ++----- .../typeReferenceDirectives10.trace.json | 7 ++----- .../typeReferenceDirectives12.trace.json | 7 ++----- .../typeReferenceDirectives13.trace.json | 7 ++----- .../typeReferenceDirectives3.trace.json | 7 ++----- .../typeReferenceDirectives4.trace.json | 7 ++----- .../typeReferenceDirectives5.trace.json | 7 ++----- .../typeReferenceDirectives6.trace.json | 7 ++----- .../typeReferenceDirectives7.trace.json | 7 ++----- .../typeReferenceDirectives9.trace.json | 7 ++----- .../typesVersions.ambientModules.trace.json | 6 ++---- .../typesVersions.multiFile.trace.json | 3 +-- ...sVersionsDeclarationEmit.ambient.trace.json | 6 ++---- ...ersionsDeclarationEmit.multiFile.trace.json | 3 +-- ...mit.multiFileBackReferenceToSelf.trace.json | 15 ++++++--------- ...multiFileBackReferenceToUnmapped.trace.json | 6 ++---- .../reference/typingsLookup1.trace.json | 7 ++----- .../reference/typingsLookup3.trace.json | 7 ++----- .../reference/typingsLookup4.trace.json | 12 ++++-------- .../reference/typingsLookupAmd.trace.json | 2 +- 43 files changed, 79 insertions(+), 156 deletions(-) diff --git a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json index 8711f881de8db..ccbfc9d2a1293 100644 --- a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json +++ b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json @@ -27,8 +27,7 @@ "File '/node_modules/foo/index.ts' does not exist.", "File '/node_modules/foo/index.tsx' does not exist.", "File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.", - "Found 'package.json' at '/node_modules/foo/package.json'.", - "'package.json' does not have a 'typesVersions' field.", + "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was found.", "======== Module name './index' was successfully resolved to '/node_modules/foo/index.d.ts' with Package ID 'foo/index.d.ts@1.2.3'. ========", "======== Resolving module 'foo' from '/node_modules/a/index.d.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", diff --git a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json index 2a4b74ad5550f..382b7d1db0015 100644 --- a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json +++ b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json @@ -27,8 +27,7 @@ "File '/node_modules/@foo/bar/index.ts' does not exist.", "File '/node_modules/@foo/bar/index.tsx' does not exist.", "File '/node_modules/@foo/bar/index.d.ts' exist - use it as a name resolution result.", - "Found 'package.json' at '/node_modules/@foo/bar/package.json'.", - "'package.json' does not have a 'typesVersions' field.", + "Using cached result of 'package.json' at '/node_modules/@foo/bar/package.json' that indicates it was found.", "======== Module name './index' was successfully resolved to '/node_modules/@foo/bar/index.d.ts' with Package ID '@foo/bar/index.d.ts@1.2.3'. ========", "======== Resolving module '@foo/bar' from '/node_modules/a/index.d.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", diff --git a/tests/baselines/reference/importWithTrailingSlash.trace.json b/tests/baselines/reference/importWithTrailingSlash.trace.json index 3efe8c1ba5161..c2b8ed1fe1250 100644 --- a/tests/baselines/reference/importWithTrailingSlash.trace.json +++ b/tests/baselines/reference/importWithTrailingSlash.trace.json @@ -18,7 +18,7 @@ "======== Resolving module '../' from '/a/b/test.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module as file / folder, candidate module location '/a/', target file type 'TypeScript'.", - "File '/a/package.json' does not exist.", + "Using cached result of 'package.json' at '/a/package.json' that indicates it was not found.", "File '/a/index.ts' exist - use it as a name resolution result.", "======== Module name '../' was successfully resolved to '/a/index.ts'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/library-reference-1.trace.json b/tests/baselines/reference/library-reference-1.trace.json index b09781aa3f435..03dea210c7155 100644 --- a/tests/baselines/reference/library-reference-1.trace.json +++ b/tests/baselines/reference/library-reference-1.trace.json @@ -5,10 +5,7 @@ "File 'types/jquery/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for 'types/jquery/index.d.ts', result '/src/types/jquery/index.d.ts'.", "======== Type reference directive 'jquery' was successfully resolved to '/src/types/jquery/index.d.ts', primary: true. ========", - "======== Resolving type reference directive 'jquery', containing file '/src/__inferred type names__.ts', root directory 'types'. ========", - "Resolving with primary search path 'types'.", - "File 'types/jquery/package.json' does not exist.", - "File 'types/jquery/index.d.ts' exist - use it as a name resolution result.", - "Resolving real path for 'types/jquery/index.d.ts', result '/src/types/jquery/index.d.ts'.", + "======== Resolving type reference directive 'jquery', containing file '/src/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'jquery' was found in cache from location '/src'.", "======== Type reference directive 'jquery' was successfully resolved to '/src/types/jquery/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/library-reference-10.trace.json b/tests/baselines/reference/library-reference-10.trace.json index 92b5b03507978..ac5bacd893326 100644 --- a/tests/baselines/reference/library-reference-10.trace.json +++ b/tests/baselines/reference/library-reference-10.trace.json @@ -7,12 +7,7 @@ "File 'types/jquery/jquery.d.ts' exist - use it as a name resolution result.", "Resolving real path for 'types/jquery/jquery.d.ts', result '/foo/types/jquery/jquery.d.ts'.", "======== Type reference directive 'jquery' was successfully resolved to '/foo/types/jquery/jquery.d.ts', primary: true. ========", - "======== Resolving type reference directive 'jquery', containing file '/foo/__inferred type names__.ts', root directory './types'. ========", - "Resolving with primary search path './types'.", - "Found 'package.json' at './types/jquery/package.json'.", - "'package.json' does not have a 'typesVersions' field.", - "'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.", - "File 'types/jquery/jquery.d.ts' exist - use it as a name resolution result.", - "Resolving real path for 'types/jquery/jquery.d.ts', result '/foo/types/jquery/jquery.d.ts'.", + "======== Resolving type reference directive 'jquery', containing file '/foo/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'jquery' was found in cache from location '/foo'.", "======== Type reference directive 'jquery' was successfully resolved to '/foo/types/jquery/jquery.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/library-reference-2.trace.json b/tests/baselines/reference/library-reference-2.trace.json index d4f509900056d..66826dcee9627 100644 --- a/tests/baselines/reference/library-reference-2.trace.json +++ b/tests/baselines/reference/library-reference-2.trace.json @@ -10,8 +10,7 @@ "======== Type reference directive 'jquery' was successfully resolved to '/types/jquery/jquery.d.ts', primary: true. ========", "======== Resolving type reference directive 'jquery', containing file '/test/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", - "Found 'package.json' at '/types/jquery/package.json'.", - "'package.json' does not have a 'typesVersions' field.", + "Using cached result of 'package.json' at '/types/jquery/package.json' that indicates it was found.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.", "File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/library-reference-6.trace.json b/tests/baselines/reference/library-reference-6.trace.json index 3c682db6af7dd..3be5c97f9a945 100644 --- a/tests/baselines/reference/library-reference-6.trace.json +++ b/tests/baselines/reference/library-reference-6.trace.json @@ -7,7 +7,7 @@ "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/@types/alpha/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'alpha', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", - "File '/node_modules/@types/alpha/package.json' does not exist.", + "Using cached result of 'package.json' at '/node_modules/@types/alpha/package.json' that indicates it was not found.", "File '/node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/alpha/index.d.ts', result '/node_modules/@types/alpha/index.d.ts'.", "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/@types/alpha/index.d.ts', primary: true. ========" diff --git a/tests/baselines/reference/library-reference-8.trace.json b/tests/baselines/reference/library-reference-8.trace.json index 794df2daa7a82..3f34a34cb9e69 100644 --- a/tests/baselines/reference/library-reference-8.trace.json +++ b/tests/baselines/reference/library-reference-8.trace.json @@ -13,26 +13,20 @@ "======== Type reference directive 'beta' was successfully resolved to '/test/types/beta/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'beta', containing file '/test/types/alpha/index.d.ts', root directory '/test/types'. ========", "Resolving with primary search path '/test/types'.", - "File '/test/types/beta/package.json' does not exist.", + "Using cached result of 'package.json' at '/test/types/beta/package.json' that indicates it was not found.", "File '/test/types/beta/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/test/types/beta/index.d.ts', result '/test/types/beta/index.d.ts'.", "======== Type reference directive 'beta' was successfully resolved to '/test/types/beta/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'alpha', containing file '/test/types/beta/index.d.ts', root directory '/test/types'. ========", "Resolving with primary search path '/test/types'.", - "File '/test/types/alpha/package.json' does not exist.", + "Using cached result of 'package.json' at '/test/types/alpha/package.json' that indicates it was not found.", "File '/test/types/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/test/types/alpha/index.d.ts', result '/test/types/alpha/index.d.ts'.", "======== Type reference directive 'alpha' was successfully resolved to '/test/types/alpha/index.d.ts', primary: true. ========", - "======== Resolving type reference directive 'alpha', containing file '/test/__inferred type names__.ts', root directory '/test/types'. ========", - "Resolving with primary search path '/test/types'.", - "File '/test/types/alpha/package.json' does not exist.", - "File '/test/types/alpha/index.d.ts' exist - use it as a name resolution result.", - "Resolving real path for '/test/types/alpha/index.d.ts', result '/test/types/alpha/index.d.ts'.", + "======== Resolving type reference directive 'alpha', containing file '/test/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'alpha' was found in cache from location '/test'.", "======== Type reference directive 'alpha' was successfully resolved to '/test/types/alpha/index.d.ts', primary: true. ========", - "======== Resolving type reference directive 'beta', containing file '/test/__inferred type names__.ts', root directory '/test/types'. ========", - "Resolving with primary search path '/test/types'.", - "File '/test/types/beta/package.json' does not exist.", - "File '/test/types/beta/index.d.ts' exist - use it as a name resolution result.", - "Resolving real path for '/test/types/beta/index.d.ts', result '/test/types/beta/index.d.ts'.", + "======== Resolving type reference directive 'beta', containing file '/test/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'beta' was found in cache from location '/test'.", "======== Type reference directive 'beta' was successfully resolved to '/test/types/beta/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json index 56bbee705bf7e..859712ebcac95 100644 --- a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json +++ b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json @@ -11,7 +11,7 @@ "File '/node_modules/shortid/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'shortid' from 'node_modules' folder, target file type 'JavaScript'.", - "File '/node_modules/shortid/package.json' does not exist.", + "Using cached result of 'package.json' at '/node_modules/shortid/package.json' that indicates it was not found.", "File '/node_modules/shortid.js' does not exist.", "File '/node_modules/shortid.jsx' does not exist.", "File '/node_modules/shortid/index.js' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/moduleResolutionPackageIdWithRelativeAndAbsolutePath.trace.json b/tests/baselines/reference/moduleResolutionPackageIdWithRelativeAndAbsolutePath.trace.json index e3d7b5dea54a4..45433da89f459 100644 --- a/tests/baselines/reference/moduleResolutionPackageIdWithRelativeAndAbsolutePath.trace.json +++ b/tests/baselines/reference/moduleResolutionPackageIdWithRelativeAndAbsolutePath.trace.json @@ -54,8 +54,7 @@ "File '/project/node_modules/troublesome-lib/lib/Option.ts' does not exist.", "File '/project/node_modules/troublesome-lib/lib/Option.tsx' does not exist.", "File '/project/node_modules/troublesome-lib/lib/Option.d.ts' exist - use it as a name resolution result.", - "Found 'package.json' at '/project/node_modules/troublesome-lib/package.json'.", - "'package.json' does not have a 'typesVersions' field.", + "Using cached result of 'package.json' at '/project/node_modules/troublesome-lib/package.json' that indicates it was found.", "======== Module name './Option' was successfully resolved to '/project/node_modules/troublesome-lib/lib/Option.d.ts' with Package ID 'troublesome-lib/lib/Option.d.ts@1.17.1'. ========", "======== Resolving module 'troublesome-lib/lib/Option' from '/shared/lib/app.d.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json index 28e150aa34579..691dcabbc6bf4 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json @@ -22,8 +22,7 @@ "File '/node_modules/normalize.css/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'normalize.css' from 'node_modules' folder, target file type 'JavaScript'.", - "Found 'package.json' at '/node_modules/normalize.css/package.json'.", - "'package.json' does not have a 'typesVersions' field.", + "Using cached result of 'package.json' at '/node_modules/normalize.css/package.json' that indicates it was found.", "File '/node_modules/normalize.css.js' does not exist.", "File '/node_modules/normalize.css.jsx' does not exist.", "'package.json' has 'main' field 'normalize.css' that references '/node_modules/normalize.css/normalize.css'.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json index a92c5953af3a2..facb2f8f172fe 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json @@ -25,8 +25,7 @@ "File '/node_modules/foo/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", - "Found 'package.json' at '/node_modules/foo/package.json'.", - "'package.json' does not have a 'typesVersions' field.", + "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was found.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", "'package.json' does not have a 'main' field.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json index 9a0d5e095a512..41f8daee2dd96 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json @@ -11,7 +11,7 @@ "File '/node_modules/js/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'js' from 'node_modules' folder, target file type 'JavaScript'.", - "File '/node_modules/js/package.json' does not exist.", + "Using cached result of 'package.json' at '/node_modules/js/package.json' that indicates it was not found.", "File '/node_modules/js.js' does not exist.", "File '/node_modules/js.jsx' does not exist.", "File '/node_modules/js/index.js' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_withPaths.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_withPaths.trace.json index f99d99800f434..e6df918dabbb8 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_withPaths.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_withPaths.trace.json @@ -25,7 +25,7 @@ "File '/node_modules/foo/lib/test.ts' does not exist.", "File '/node_modules/foo/lib/test.tsx' does not exist.", "File '/node_modules/foo/lib/test.d.ts' exist - use it as a name resolution result.", - "File '/node_modules/foo/package.json' does not exist.", + "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was not found.", "======== Module name 'foo/test' was successfully resolved to '/node_modules/foo/lib/test.d.ts'. ========", "======== Resolving module './relative.js' from '/test.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json b/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json index 73e6a1df99679..e85afdc6f3a5e 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json @@ -21,7 +21,7 @@ "======== Resolving module 'linked' from '/app/app.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'linked' from 'node_modules' folder, target file type 'TypeScript'.", - "File '/app/node_modules/linked/package.json' does not exist.", + "Using cached result of 'package.json' at '/app/node_modules/linked/package.json' that indicates it was not found.", "File '/app/node_modules/linked.ts' does not exist.", "File '/app/node_modules/linked.tsx' does not exist.", "File '/app/node_modules/linked.d.ts' does not exist.", @@ -44,7 +44,7 @@ "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'real' from 'node_modules' folder, target file type 'TypeScript'.", "Directory '/app/node_modules/linked2/node_modules' does not exist, skipping all lookups in it.", - "File '/app/node_modules/real/package.json' does not exist.", + "Using cached result of 'package.json' at '/app/node_modules/real/package.json' that indicates it was not found.", "File '/app/node_modules/real.ts' does not exist.", "File '/app/node_modules/real.tsx' does not exist.", "File '/app/node_modules/real.d.ts' does not exist.", diff --git a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot.trace.json b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot.trace.json index aafca116d0b68..5adc657ef49f7 100644 --- a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot.trace.json +++ b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot.trace.json @@ -21,9 +21,8 @@ "File '/node_modules/foo/bar/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo/bar' from 'node_modules' folder, target file type 'JavaScript'.", - "File '/node_modules/foo/bar/package.json' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'.", - "'package.json' does not have a 'typesVersions' field.", + "Using cached result of 'package.json' at '/node_modules/foo/bar/package.json' that indicates it was not found.", + "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was found.", "File '/node_modules/foo/bar.js' does not exist.", "File '/node_modules/foo/bar.jsx' does not exist.", "'package.json' does not have a 'main' field.", diff --git a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.trace.json b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.trace.json index f41b1ca07102a..c191b204b7d31 100644 --- a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.trace.json +++ b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.trace.json @@ -21,9 +21,8 @@ "File '/node_modules/foo/@bar/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo/@bar' from 'node_modules' folder, target file type 'JavaScript'.", - "File '/node_modules/foo/@bar/package.json' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'.", - "'package.json' does not have a 'typesVersions' field.", + "Using cached result of 'package.json' at '/node_modules/foo/@bar/package.json' that indicates it was not found.", + "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was found.", "File '/node_modules/foo/@bar.js' does not exist.", "File '/node_modules/foo/@bar.jsx' does not exist.", "'package.json' does not have a 'main' field.", diff --git a/tests/baselines/reference/packageJsonMain.trace.json b/tests/baselines/reference/packageJsonMain.trace.json index 2144b6eb15c49..93a7b60cfd73f 100644 --- a/tests/baselines/reference/packageJsonMain.trace.json +++ b/tests/baselines/reference/packageJsonMain.trace.json @@ -21,8 +21,7 @@ "File '/node_modules/foo/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", - "Found 'package.json' at '/node_modules/foo/package.json'.", - "'package.json' does not have a 'typesVersions' field.", + "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was found.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", "'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.", @@ -58,8 +57,7 @@ "File '/node_modules/bar/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'bar' from 'node_modules' folder, target file type 'JavaScript'.", - "Found 'package.json' at '/node_modules/bar/package.json'.", - "'package.json' does not have a 'typesVersions' field.", + "Using cached result of 'package.json' at '/node_modules/bar/package.json' that indicates it was found.", "File '/node_modules/bar.js' does not exist.", "File '/node_modules/bar.jsx' does not exist.", "'package.json' has 'main' field 'rab.js' that references '/node_modules/bar/rab.js'.", @@ -90,8 +88,7 @@ "File '/node_modules/baz/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'baz' from 'node_modules' folder, target file type 'JavaScript'.", - "Found 'package.json' at '/node_modules/baz/package.json'.", - "'package.json' does not have a 'typesVersions' field.", + "Using cached result of 'package.json' at '/node_modules/baz/package.json' that indicates it was found.", "File '/node_modules/baz.js' does not exist.", "File '/node_modules/baz.jsx' does not exist.", "'package.json' has 'main' field 'zab' that references '/node_modules/baz/zab'.", diff --git a/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json b/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json index 5bdd8a7e90c4b..7bd49b1ecd56b 100644 --- a/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json +++ b/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json @@ -23,8 +23,7 @@ "File '/node_modules/foo/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", - "Found 'package.json' at '/node_modules/foo/package.json'.", - "'package.json' does not have a 'typesVersions' field.", + "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was found.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", "'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.trace.json index b4aa0889de789..fb8637c521dd9 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.trace.json @@ -36,6 +36,6 @@ "File '/node_modules/foo/bar/foobar.js.jsx' does not exist.", "File name '/node_modules/foo/bar/foobar.js' has a '.js' extension - stripping it.", "File '/node_modules/foo/bar/foobar.js' exist - use it as a name resolution result.", - "File '/node_modules/foo/package.json' does not exist.", + "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was not found.", "======== Module name 'foo/bar/foobar.js' was successfully resolved to '/node_modules/foo/bar/foobar.js'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/requireOfJsonFileWithoutResolveJsonModuleAndPathMapping.trace.json b/tests/baselines/reference/requireOfJsonFileWithoutResolveJsonModuleAndPathMapping.trace.json index 400f05ead56d9..21b1881daa045 100644 --- a/tests/baselines/reference/requireOfJsonFileWithoutResolveJsonModuleAndPathMapping.trace.json +++ b/tests/baselines/reference/requireOfJsonFileWithoutResolveJsonModuleAndPathMapping.trace.json @@ -29,7 +29,7 @@ "Trying substitution 'src/types', candidate module location: 'src/types'.", "Loading module as file / folder, candidate module location '/src/types', target file type 'JavaScript'.", "Loading module 'foo/bar/foobar.json' from 'node_modules' folder, target file type 'JavaScript'.", - "File '/node_modules/foo/package.json' does not exist.", + "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was not found.", "File '/node_modules/foo/bar/foobar.json.js' does not exist.", "File '/node_modules/foo/bar/foobar.json.jsx' does not exist.", "======== Module name 'foo/bar/foobar.json' was not resolved. ========" diff --git a/tests/baselines/reference/requireOfJsonFile_PathMapping.trace.json b/tests/baselines/reference/requireOfJsonFile_PathMapping.trace.json index 53987c271425c..36af12924efd7 100644 --- a/tests/baselines/reference/requireOfJsonFile_PathMapping.trace.json +++ b/tests/baselines/reference/requireOfJsonFile_PathMapping.trace.json @@ -29,7 +29,7 @@ "Trying substitution 'src/types', candidate module location: 'src/types'.", "Loading module as file / folder, candidate module location '/src/types', target file type 'JavaScript'.", "Loading module 'foo/bar/foobar.json' from 'node_modules' folder, target file type 'JavaScript'.", - "File '/node_modules/foo/package.json' does not exist.", + "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was not found.", "File '/node_modules/foo/bar/foobar.json.js' does not exist.", "File '/node_modules/foo/bar/foobar.json.jsx' does not exist.", "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo/bar/foobar.json'.", @@ -38,6 +38,6 @@ "Trying substitution 'node_modules/*', candidate module location: 'node_modules/foo/bar/foobar.json'.", "Loading module as file / folder, candidate module location '/node_modules/foo/bar/foobar.json', target file type 'Json'.", "File '/node_modules/foo/bar/foobar.json' exist - use it as a name resolution result.", - "File '/node_modules/foo/package.json' does not exist.", + "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was not found.", "======== Module name 'foo/bar/foobar.json' was successfully resolved to '/node_modules/foo/bar/foobar.json'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/scopedPackages.trace.json b/tests/baselines/reference/scopedPackages.trace.json index 1844f8c6c8d8e..b377d5d8978e7 100644 --- a/tests/baselines/reference/scopedPackages.trace.json +++ b/tests/baselines/reference/scopedPackages.trace.json @@ -24,7 +24,7 @@ "Module resolution kind is not specified, using 'NodeJs'.", "Loading module '@be/bop/e/z' from 'node_modules' folder, target file type 'TypeScript'.", "Scoped package detected, looking in 'be__bop/e/z'", - "File '/node_modules/@types/be__bop/package.json' does not exist.", + "Using cached result of 'package.json' at '/node_modules/@types/be__bop/package.json' that indicates it was not found.", "File '/node_modules/@types/be__bop/e/z.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/be__bop/e/z.d.ts', result '/node_modules/@types/be__bop/e/z.d.ts'.", "======== Module name '@be/bop/e/z' was successfully resolved to '/node_modules/@types/be__bop/e/z.d.ts'. ========" diff --git a/tests/baselines/reference/typeReferenceDirectives1.trace.json b/tests/baselines/reference/typeReferenceDirectives1.trace.json index 64994ab00b573..8be3b668a2bd8 100644 --- a/tests/baselines/reference/typeReferenceDirectives1.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives1.trace.json @@ -5,10 +5,7 @@ "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", - "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", - "Resolving with primary search path '/types'.", - "File '/types/lib/package.json' does not exist.", - "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", - "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", + "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'lib' was found in cache from location '/'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectives10.trace.json b/tests/baselines/reference/typeReferenceDirectives10.trace.json index a91414a8ce189..ef7f8aca2b0a3 100644 --- a/tests/baselines/reference/typeReferenceDirectives10.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives10.trace.json @@ -12,10 +12,7 @@ "File '/ref.tsx' does not exist.", "File '/ref.d.ts' exist - use it as a name resolution result.", "======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========", - "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", - "Resolving with primary search path '/types'.", - "File '/types/lib/package.json' does not exist.", - "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", - "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", + "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'lib' was found in cache from location '/'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectives12.trace.json b/tests/baselines/reference/typeReferenceDirectives12.trace.json index 12f8d938c1d64..e9cbd4215822b 100644 --- a/tests/baselines/reference/typeReferenceDirectives12.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives12.trace.json @@ -18,10 +18,7 @@ "======== Resolving module './main' from '/mod1.ts'. ========", "Resolution for module './main' was found in cache from location '/'.", "======== Module name './main' was successfully resolved to '/main.ts'. ========", - "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", - "Resolving with primary search path '/types'.", - "File '/types/lib/package.json' does not exist.", - "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", - "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", + "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'lib' was found in cache from location '/'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectives13.trace.json b/tests/baselines/reference/typeReferenceDirectives13.trace.json index a91414a8ce189..ef7f8aca2b0a3 100644 --- a/tests/baselines/reference/typeReferenceDirectives13.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives13.trace.json @@ -12,10 +12,7 @@ "File '/ref.tsx' does not exist.", "File '/ref.d.ts' exist - use it as a name resolution result.", "======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========", - "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", - "Resolving with primary search path '/types'.", - "File '/types/lib/package.json' does not exist.", - "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", - "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", + "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'lib' was found in cache from location '/'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectives3.trace.json b/tests/baselines/reference/typeReferenceDirectives3.trace.json index 64994ab00b573..8be3b668a2bd8 100644 --- a/tests/baselines/reference/typeReferenceDirectives3.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives3.trace.json @@ -5,10 +5,7 @@ "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", - "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", - "Resolving with primary search path '/types'.", - "File '/types/lib/package.json' does not exist.", - "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", - "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", + "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'lib' was found in cache from location '/'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectives4.trace.json b/tests/baselines/reference/typeReferenceDirectives4.trace.json index 64994ab00b573..8be3b668a2bd8 100644 --- a/tests/baselines/reference/typeReferenceDirectives4.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives4.trace.json @@ -5,10 +5,7 @@ "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", - "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", - "Resolving with primary search path '/types'.", - "File '/types/lib/package.json' does not exist.", - "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", - "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", + "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'lib' was found in cache from location '/'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectives5.trace.json b/tests/baselines/reference/typeReferenceDirectives5.trace.json index a91414a8ce189..ef7f8aca2b0a3 100644 --- a/tests/baselines/reference/typeReferenceDirectives5.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives5.trace.json @@ -12,10 +12,7 @@ "File '/ref.tsx' does not exist.", "File '/ref.d.ts' exist - use it as a name resolution result.", "======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========", - "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", - "Resolving with primary search path '/types'.", - "File '/types/lib/package.json' does not exist.", - "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", - "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", + "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'lib' was found in cache from location '/'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectives6.trace.json b/tests/baselines/reference/typeReferenceDirectives6.trace.json index 64994ab00b573..8be3b668a2bd8 100644 --- a/tests/baselines/reference/typeReferenceDirectives6.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives6.trace.json @@ -5,10 +5,7 @@ "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", - "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", - "Resolving with primary search path '/types'.", - "File '/types/lib/package.json' does not exist.", - "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", - "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", + "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'lib' was found in cache from location '/'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectives7.trace.json b/tests/baselines/reference/typeReferenceDirectives7.trace.json index 64994ab00b573..8be3b668a2bd8 100644 --- a/tests/baselines/reference/typeReferenceDirectives7.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives7.trace.json @@ -5,10 +5,7 @@ "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========", - "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", - "Resolving with primary search path '/types'.", - "File '/types/lib/package.json' does not exist.", - "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", - "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", + "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'lib' was found in cache from location '/'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectives9.trace.json b/tests/baselines/reference/typeReferenceDirectives9.trace.json index 12f8d938c1d64..e9cbd4215822b 100644 --- a/tests/baselines/reference/typeReferenceDirectives9.trace.json +++ b/tests/baselines/reference/typeReferenceDirectives9.trace.json @@ -18,10 +18,7 @@ "======== Resolving module './main' from '/mod1.ts'. ========", "Resolution for module './main' was found in cache from location '/'.", "======== Module name './main' was successfully resolved to '/main.ts'. ========", - "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========", - "Resolving with primary search path '/types'.", - "File '/types/lib/package.json' does not exist.", - "File '/types/lib/index.d.ts' exist - use it as a name resolution result.", - "Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.", + "======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'lib' was found in cache from location '/'.", "======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typesVersions.ambientModules.trace.json b/tests/baselines/reference/typesVersions.ambientModules.trace.json index 53de9ae651ec6..1497d0c26428d 100644 --- a/tests/baselines/reference/typesVersions.ambientModules.trace.json +++ b/tests/baselines/reference/typesVersions.ambientModules.trace.json @@ -22,8 +22,7 @@ "======== Resolving module 'ext/other' from 'tests/cases/conformance/moduleResolution/main.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", - "Found 'package.json' at 'tests/cases/conformance/moduleResolution/node_modules/ext/package.json'.", - "'package.json' has a 'typesVersions' field with version-specific path mappings.", + "Using cached result of 'package.json' at 'tests/cases/conformance/moduleResolution/node_modules/ext/package.json' that indicates it was found.", "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", @@ -43,8 +42,7 @@ "Directory 'node_modules' does not exist, skipping all lookups in it.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "Loading module 'ext/other' from 'node_modules' folder, target file type 'JavaScript'.", - "Found 'package.json' at 'tests/cases/conformance/moduleResolution/node_modules/ext/package.json'.", - "'package.json' has a 'typesVersions' field with version-specific path mappings.", + "Using cached result of 'package.json' at 'tests/cases/conformance/moduleResolution/node_modules/ext/package.json' that indicates it was found.", "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", diff --git a/tests/baselines/reference/typesVersions.multiFile.trace.json b/tests/baselines/reference/typesVersions.multiFile.trace.json index d487d35294882..e4bf9273edbf5 100644 --- a/tests/baselines/reference/typesVersions.multiFile.trace.json +++ b/tests/baselines/reference/typesVersions.multiFile.trace.json @@ -22,8 +22,7 @@ "======== Resolving module 'ext/other' from 'tests/cases/conformance/moduleResolution/main.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", - "Found 'package.json' at 'tests/cases/conformance/moduleResolution/node_modules/ext/package.json'.", - "'package.json' has a 'typesVersions' field with version-specific path mappings.", + "Using cached result of 'package.json' at 'tests/cases/conformance/moduleResolution/node_modules/ext/package.json' that indicates it was found.", "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json index 97972b9d1f67c..5fd5d9ff7ef80 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json @@ -22,8 +22,7 @@ "======== Resolving module 'ext/other' from 'tests/cases/conformance/declarationEmit/main.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", - "Found 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json'.", - "'package.json' has a 'typesVersions' field with version-specific path mappings.", + "Using cached result of 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' that indicates it was found.", "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", @@ -43,8 +42,7 @@ "Directory 'node_modules' does not exist, skipping all lookups in it.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "Loading module 'ext/other' from 'node_modules' folder, target file type 'JavaScript'.", - "Found 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json'.", - "'package.json' has a 'typesVersions' field with version-specific path mappings.", + "Using cached result of 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' that indicates it was found.", "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json index 224839cf26dbe..dfbcd9f4dde6d 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json @@ -22,8 +22,7 @@ "======== Resolving module 'ext/other' from 'tests/cases/conformance/declarationEmit/main.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", - "Found 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json'.", - "'package.json' has a 'typesVersions' field with version-specific path mappings.", + "Using cached result of 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' that indicates it was found.", "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json index a89df5a6dfe9d..77e0315669d24 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json @@ -21,14 +21,12 @@ "File 'tests/cases/conformance/declarationEmit/node_modules/ext/other.ts' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/other.tsx' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/other.d.ts' exist - use it as a name resolution result.", - "Found 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json'.", - "'package.json' has a 'typesVersions' field with version-specific path mappings.", - "======== Module name '../other' was successfully resolved to 'tests/cases/conformance/declarationEmit/node_modules/ext/other.d.ts' with Package ID 'ext/other.d.ts@1.0.0'. ========", + "Using cached result of 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' that indicates it was found.", + "======== Module name '../other' was successfully resolved to 'tests/cases/conformance/declarationEmit/node_modules/ext/other.d.ts' with Package ID 'ext/ther.d.ts@1.0.0'. ========", "======== Resolving module 'ext' from 'tests/cases/conformance/declarationEmit/main.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'ext' from 'node_modules' folder, target file type 'TypeScript'.", - "Found 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json'.", - "'package.json' has a 'typesVersions' field with version-specific path mappings.", + "Using cached result of 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' that indicates it was found.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext.ts' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext.tsx' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext.d.ts' does not exist.", @@ -43,12 +41,11 @@ "File 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/index.tsx' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/index.d.ts', result 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/index.d.ts'.", - "======== Module name 'ext' was successfully resolved to 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/index.d.ts' with Package ID 'ext/ts3.1/index.d.ts@1.0.0'. ========", + "======== Module name 'ext' was successfully resolved to 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/index.d.ts' with Package ID 'ext/s3.1/index.d.ts@1.0.0'. ========", "======== Resolving module 'ext/other' from 'tests/cases/conformance/declarationEmit/main.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", - "Found 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json'.", - "'package.json' has a 'typesVersions' field with version-specific path mappings.", + "Using cached result of 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' that indicates it was found.", "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", @@ -56,5 +53,5 @@ "File 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/other.tsx' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/other.d.ts' exist - use it as a name resolution result.", "Resolving real path for 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/other.d.ts', result 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/other.d.ts'.", - "======== Module name 'ext/other' was successfully resolved to 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/other.d.ts' with Package ID 'ext/ts3.1/other.d.ts@1.0.0'. ========" + "======== Module name 'ext/other' was successfully resolved to 'tests/cases/conformance/declarationEmit/node_modules/ext/ts3.1/other.d.ts' with Package ID 'ext/s3.1/other.d.ts@1.0.0'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json index 7da95cd402c2f..b8c1843096f55 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json @@ -11,8 +11,7 @@ "======== Resolving module 'ext' from 'tests/cases/conformance/declarationEmit/main.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'ext' from 'node_modules' folder, target file type 'TypeScript'.", - "Found 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json'.", - "'package.json' has a 'typesVersions' field with version-specific path mappings.", + "Using cached result of 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' that indicates it was found.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext.ts' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext.tsx' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext.d.ts' does not exist.", @@ -31,8 +30,7 @@ "======== Resolving module 'ext/other' from 'tests/cases/conformance/declarationEmit/main.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", - "Found 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json'.", - "'package.json' has a 'typesVersions' field with version-specific path mappings.", + "Using cached result of 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' that indicates it was found.", "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/other.ts' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/other.tsx' does not exist.", diff --git a/tests/baselines/reference/typingsLookup1.trace.json b/tests/baselines/reference/typingsLookup1.trace.json index 9efcb84d49022..6914a6ea965bc 100644 --- a/tests/baselines/reference/typingsLookup1.trace.json +++ b/tests/baselines/reference/typingsLookup1.trace.json @@ -5,10 +5,7 @@ "File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/jquery/index.d.ts', result '/node_modules/@types/jquery/index.d.ts'.", "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========", - "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", - "Resolving with primary search path '/node_modules/@types'.", - "File '/node_modules/@types/jquery/package.json' does not exist.", - "File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.", - "Resolving real path for '/node_modules/@types/jquery/index.d.ts', result '/node_modules/@types/jquery/index.d.ts'.", + "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'jquery' was found in cache from location '/'.", "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typingsLookup3.trace.json b/tests/baselines/reference/typingsLookup3.trace.json index 9efcb84d49022..6914a6ea965bc 100644 --- a/tests/baselines/reference/typingsLookup3.trace.json +++ b/tests/baselines/reference/typingsLookup3.trace.json @@ -5,10 +5,7 @@ "File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/jquery/index.d.ts', result '/node_modules/@types/jquery/index.d.ts'.", "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========", - "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", - "Resolving with primary search path '/node_modules/@types'.", - "File '/node_modules/@types/jquery/package.json' does not exist.", - "File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.", - "Resolving real path for '/node_modules/@types/jquery/index.d.ts', result '/node_modules/@types/jquery/index.d.ts'.", + "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts'. ========", + "Resolution for type reference directive 'jquery' was found in cache from location '/'.", "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/typingsLookup4.trace.json b/tests/baselines/reference/typingsLookup4.trace.json index 3ce97d9d8c983..c14a1746e3702 100644 --- a/tests/baselines/reference/typingsLookup4.trace.json +++ b/tests/baselines/reference/typingsLookup4.trace.json @@ -65,16 +65,14 @@ "======== Module name 'mquery' was successfully resolved to '/node_modules/@types/mquery/mquery/index.tsx'. ========", "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", - "Found 'package.json' at '/node_modules/@types/jquery/package.json'.", - "'package.json' does not have a 'typesVersions' field.", + "Using cached result of 'package.json' at '/node_modules/@types/jquery/package.json' that indicates it was found.", "'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.", "File '/node_modules/@types/jquery/jquery.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/jquery/jquery.d.ts', result '/node_modules/@types/jquery/jquery.d.ts'.", "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/jquery.d.ts', primary: true. ========", "======== Resolving type reference directive 'kquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", - "Found 'package.json' at '/node_modules/@types/kquery/package.json'.", - "'package.json' does not have a 'typesVersions' field.", + "Using cached result of 'package.json' at '/node_modules/@types/kquery/package.json' that indicates it was found.", "'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.", "File '/node_modules/@types/kquery/kquery' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/@types/kquery/kquery', target file type 'TypeScript'.", @@ -85,8 +83,7 @@ "======== Type reference directive 'kquery' was successfully resolved to '/node_modules/@types/kquery/kquery.d.ts', primary: true. ========", "======== Resolving type reference directive 'lquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", - "Found 'package.json' at '/node_modules/@types/lquery/package.json'.", - "'package.json' does not have a 'typesVersions' field.", + "Using cached result of 'package.json' at '/node_modules/@types/lquery/package.json' that indicates it was found.", "'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.", "File '/node_modules/@types/lquery/lquery' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/@types/lquery/lquery', target file type 'TypeScript'.", @@ -95,8 +92,7 @@ "======== Type reference directive 'lquery' was successfully resolved to '/node_modules/@types/lquery/lquery.ts', primary: true. ========", "======== Resolving type reference directive 'mquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", - "Found 'package.json' at '/node_modules/@types/mquery/package.json'.", - "'package.json' does not have a 'typesVersions' field.", + "Using cached result of 'package.json' at '/node_modules/@types/mquery/package.json' that indicates it was found.", "'package.json' has 'typings' field 'mquery' that references '/node_modules/@types/mquery/mquery'.", "File '/node_modules/@types/mquery/mquery' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/@types/mquery/mquery', target file type 'TypeScript'.", diff --git a/tests/baselines/reference/typingsLookupAmd.trace.json b/tests/baselines/reference/typingsLookupAmd.trace.json index f18f63e7597b8..5b3fe5585ff7a 100644 --- a/tests/baselines/reference/typingsLookupAmd.trace.json +++ b/tests/baselines/reference/typingsLookupAmd.trace.json @@ -41,7 +41,7 @@ "======== Module name 'a' was successfully resolved to '/node_modules/@types/a/index.d.ts'. ========", "======== Resolving type reference directive 'a', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", - "File '/node_modules/@types/a/package.json' does not exist.", + "Using cached result of 'package.json' at '/node_modules/@types/a/package.json' that indicates it was not found.", "File '/node_modules/@types/a/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/a/index.d.ts', result '/node_modules/@types/a/index.d.ts'.", "======== Type reference directive 'a' was successfully resolved to '/node_modules/@types/a/index.d.ts', primary: true. ========" From c18c52c98ed8f87a0bb4fffc269e0dd33fa0a0d7 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 21 Apr 2021 17:40:36 -0700 Subject: [PATCH 5/6] Change trace according to feedback --- src/compiler/diagnosticMessages.json | 4 ++-- src/compiler/moduleNameResolver.ts | 4 ++-- src/testRunner/unittests/reuseProgramStructure.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 5fa04cff3bcf9..4070ce552b3db 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4849,11 +4849,11 @@ "category": "Error", "code": 6238 }, - "Using cached result of 'package.json' at '{0}' that indicates it was found.": { + "File '{0}' exists according to earlier cached lookups.": { "category": "Message", "code": 6239 }, - "Using cached result of 'package.json' at '{0}' that indicates it was not found.": { + "File '{0}' does not exist according to earlier cached lookups.": { "category": "Message", "code": 6240 }, diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index f59b265652ad7..93cf570d7962c 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1308,11 +1308,11 @@ namespace ts { const existing = state.packageJsonInfoCache?.getPackageJsonInfo(packageJsonPath); if (existing !== undefined) { if (typeof existing !== "boolean") { - if (traceEnabled) trace(host, Diagnostics.Using_cached_result_of_package_json_at_0_that_indicates_it_was_found, packageJsonPath); + if (traceEnabled) trace(host, Diagnostics.File_0_exists_according_to_earlier_cached_lookups, packageJsonPath); return existing; } else { - if (existing && traceEnabled) trace(host, Diagnostics.Using_cached_result_of_package_json_at_0_that_indicates_it_was_not_found, packageJsonPath); + if (existing && traceEnabled) trace(host, Diagnostics.File_0_does_not_exist_according_to_earlier_cached_lookups, packageJsonPath); state.failedLookupLocations.push(packageJsonPath); return undefined; } diff --git a/src/testRunner/unittests/reuseProgramStructure.ts b/src/testRunner/unittests/reuseProgramStructure.ts index 6f185b75312d8..379c8be11cc52 100644 --- a/src/testRunner/unittests/reuseProgramStructure.ts +++ b/src/testRunner/unittests/reuseProgramStructure.ts @@ -474,7 +474,7 @@ namespace ts { "File 'node_modules/@types/a.d.ts' does not exist.", "File 'node_modules/@types/a/index.d.ts' does not exist.", "Loading module 'a' from 'node_modules' folder, target file type 'JavaScript'.", - "Using cached result of 'package.json' at 'node_modules/a/package.json' that indicates it was not found.", + "File 'node_modules/a/package.json' does not exist according to earlier cached lookups.", "File 'node_modules/a.js' does not exist.", "File 'node_modules/a.jsx' does not exist.", "File 'node_modules/a/index.js' does not exist.", From 74993a2a64bb2e423b40204bb54ff749cdd4ef54 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Thu, 22 Apr 2021 00:54:27 +0000 Subject: [PATCH 6/6] Update Baselines and/or Applied Lint Fixes --- ...uplicatePackage_relativeImportWithinPackage.trace.json | 2 +- ...ePackage_relativeImportWithinPackage_scoped.trace.json | 2 +- .../reference/importWithTrailingSlash.trace.json | 2 +- tests/baselines/reference/library-reference-2.trace.json | 2 +- tests/baselines/reference/library-reference-6.trace.json | 2 +- tests/baselines/reference/library-reference-8.trace.json | 4 ++-- .../maxNodeModuleJsDepthDefaultsToZero.trace.json | 2 +- ...olutionPackageIdWithRelativeAndAbsolutePath.trace.json | 2 +- .../moduleResolutionWithExtensions_unexpected.trace.json | 2 +- .../moduleResolutionWithExtensions_unexpected2.trace.json | 2 +- ...ResolutionWithExtensions_withAmbientPresent.trace.json | 2 +- .../moduleResolutionWithExtensions_withPaths.trace.json | 2 +- ...duleResolutionWithSymlinks_preserveSymlinks.trace.json | 4 ++-- ...duleResolution_packageJson_yesAtPackageRoot.trace.json | 4 ++-- ...kageJson_yesAtPackageRoot_fakeScopedPackage.trace.json | 4 ++-- tests/baselines/reference/packageJsonMain.trace.json | 6 +++--- .../reference/packageJsonMain_isNonRecursive.trace.json | 2 +- ...Resolution_withExtension_MapedToNodeModules.trace.json | 2 +- ...nFileWithoutResolveJsonModuleAndPathMapping.trace.json | 2 +- .../reference/requireOfJsonFile_PathMapping.trace.json | 4 ++-- tests/baselines/reference/scopedPackages.trace.json | 2 +- .../reference/typesVersions.ambientModules.trace.json | 4 ++-- .../reference/typesVersions.multiFile.trace.json | 2 +- .../typesVersionsDeclarationEmit.ambient.trace.json | 4 ++-- .../typesVersionsDeclarationEmit.multiFile.trace.json | 2 +- ...eclarationEmit.multiFileBackReferenceToSelf.trace.json | 6 +++--- ...rationEmit.multiFileBackReferenceToUnmapped.trace.json | 4 ++-- tests/baselines/reference/typingsLookup4.trace.json | 8 ++++---- tests/baselines/reference/typingsLookupAmd.trace.json | 2 +- 29 files changed, 44 insertions(+), 44 deletions(-) diff --git a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json index ccbfc9d2a1293..e78a2c0c0e3d1 100644 --- a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json +++ b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json @@ -27,7 +27,7 @@ "File '/node_modules/foo/index.ts' does not exist.", "File '/node_modules/foo/index.tsx' does not exist.", "File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.", - "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was found.", + "File '/node_modules/foo/package.json' exists according to earlier cached lookups.", "======== Module name './index' was successfully resolved to '/node_modules/foo/index.d.ts' with Package ID 'foo/index.d.ts@1.2.3'. ========", "======== Resolving module 'foo' from '/node_modules/a/index.d.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", diff --git a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json index 382b7d1db0015..3bdf64db17097 100644 --- a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json +++ b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json @@ -27,7 +27,7 @@ "File '/node_modules/@foo/bar/index.ts' does not exist.", "File '/node_modules/@foo/bar/index.tsx' does not exist.", "File '/node_modules/@foo/bar/index.d.ts' exist - use it as a name resolution result.", - "Using cached result of 'package.json' at '/node_modules/@foo/bar/package.json' that indicates it was found.", + "File '/node_modules/@foo/bar/package.json' exists according to earlier cached lookups.", "======== Module name './index' was successfully resolved to '/node_modules/@foo/bar/index.d.ts' with Package ID '@foo/bar/index.d.ts@1.2.3'. ========", "======== Resolving module '@foo/bar' from '/node_modules/a/index.d.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", diff --git a/tests/baselines/reference/importWithTrailingSlash.trace.json b/tests/baselines/reference/importWithTrailingSlash.trace.json index c2b8ed1fe1250..fb77f85298840 100644 --- a/tests/baselines/reference/importWithTrailingSlash.trace.json +++ b/tests/baselines/reference/importWithTrailingSlash.trace.json @@ -18,7 +18,7 @@ "======== Resolving module '../' from '/a/b/test.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module as file / folder, candidate module location '/a/', target file type 'TypeScript'.", - "Using cached result of 'package.json' at '/a/package.json' that indicates it was not found.", + "File '/a/package.json' does not exist according to earlier cached lookups.", "File '/a/index.ts' exist - use it as a name resolution result.", "======== Module name '../' was successfully resolved to '/a/index.ts'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/library-reference-2.trace.json b/tests/baselines/reference/library-reference-2.trace.json index 66826dcee9627..da8ad8d4e5577 100644 --- a/tests/baselines/reference/library-reference-2.trace.json +++ b/tests/baselines/reference/library-reference-2.trace.json @@ -10,7 +10,7 @@ "======== Type reference directive 'jquery' was successfully resolved to '/types/jquery/jquery.d.ts', primary: true. ========", "======== Resolving type reference directive 'jquery', containing file '/test/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", - "Using cached result of 'package.json' at '/types/jquery/package.json' that indicates it was found.", + "File '/types/jquery/package.json' exists according to earlier cached lookups.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.", "File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/library-reference-6.trace.json b/tests/baselines/reference/library-reference-6.trace.json index 3be5c97f9a945..da7f6712612a2 100644 --- a/tests/baselines/reference/library-reference-6.trace.json +++ b/tests/baselines/reference/library-reference-6.trace.json @@ -7,7 +7,7 @@ "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/@types/alpha/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'alpha', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", - "Using cached result of 'package.json' at '/node_modules/@types/alpha/package.json' that indicates it was not found.", + "File '/node_modules/@types/alpha/package.json' does not exist according to earlier cached lookups.", "File '/node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/alpha/index.d.ts', result '/node_modules/@types/alpha/index.d.ts'.", "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/@types/alpha/index.d.ts', primary: true. ========" diff --git a/tests/baselines/reference/library-reference-8.trace.json b/tests/baselines/reference/library-reference-8.trace.json index 3f34a34cb9e69..4d5f694c93495 100644 --- a/tests/baselines/reference/library-reference-8.trace.json +++ b/tests/baselines/reference/library-reference-8.trace.json @@ -13,13 +13,13 @@ "======== Type reference directive 'beta' was successfully resolved to '/test/types/beta/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'beta', containing file '/test/types/alpha/index.d.ts', root directory '/test/types'. ========", "Resolving with primary search path '/test/types'.", - "Using cached result of 'package.json' at '/test/types/beta/package.json' that indicates it was not found.", + "File '/test/types/beta/package.json' does not exist according to earlier cached lookups.", "File '/test/types/beta/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/test/types/beta/index.d.ts', result '/test/types/beta/index.d.ts'.", "======== Type reference directive 'beta' was successfully resolved to '/test/types/beta/index.d.ts', primary: true. ========", "======== Resolving type reference directive 'alpha', containing file '/test/types/beta/index.d.ts', root directory '/test/types'. ========", "Resolving with primary search path '/test/types'.", - "Using cached result of 'package.json' at '/test/types/alpha/package.json' that indicates it was not found.", + "File '/test/types/alpha/package.json' does not exist according to earlier cached lookups.", "File '/test/types/alpha/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/test/types/alpha/index.d.ts', result '/test/types/alpha/index.d.ts'.", "======== Type reference directive 'alpha' was successfully resolved to '/test/types/alpha/index.d.ts', primary: true. ========", diff --git a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json index 859712ebcac95..dd946d6fd425b 100644 --- a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json +++ b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json @@ -11,7 +11,7 @@ "File '/node_modules/shortid/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'shortid' from 'node_modules' folder, target file type 'JavaScript'.", - "Using cached result of 'package.json' at '/node_modules/shortid/package.json' that indicates it was not found.", + "File '/node_modules/shortid/package.json' does not exist according to earlier cached lookups.", "File '/node_modules/shortid.js' does not exist.", "File '/node_modules/shortid.jsx' does not exist.", "File '/node_modules/shortid/index.js' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/moduleResolutionPackageIdWithRelativeAndAbsolutePath.trace.json b/tests/baselines/reference/moduleResolutionPackageIdWithRelativeAndAbsolutePath.trace.json index 45433da89f459..4592160e8de3a 100644 --- a/tests/baselines/reference/moduleResolutionPackageIdWithRelativeAndAbsolutePath.trace.json +++ b/tests/baselines/reference/moduleResolutionPackageIdWithRelativeAndAbsolutePath.trace.json @@ -54,7 +54,7 @@ "File '/project/node_modules/troublesome-lib/lib/Option.ts' does not exist.", "File '/project/node_modules/troublesome-lib/lib/Option.tsx' does not exist.", "File '/project/node_modules/troublesome-lib/lib/Option.d.ts' exist - use it as a name resolution result.", - "Using cached result of 'package.json' at '/project/node_modules/troublesome-lib/package.json' that indicates it was found.", + "File '/project/node_modules/troublesome-lib/package.json' exists according to earlier cached lookups.", "======== Module name './Option' was successfully resolved to '/project/node_modules/troublesome-lib/lib/Option.d.ts' with Package ID 'troublesome-lib/lib/Option.d.ts@1.17.1'. ========", "======== Resolving module 'troublesome-lib/lib/Option' from '/shared/lib/app.d.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json index 691dcabbc6bf4..17dbc8b753044 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json @@ -22,7 +22,7 @@ "File '/node_modules/normalize.css/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'normalize.css' from 'node_modules' folder, target file type 'JavaScript'.", - "Using cached result of 'package.json' at '/node_modules/normalize.css/package.json' that indicates it was found.", + "File '/node_modules/normalize.css/package.json' exists according to earlier cached lookups.", "File '/node_modules/normalize.css.js' does not exist.", "File '/node_modules/normalize.css.jsx' does not exist.", "'package.json' has 'main' field 'normalize.css' that references '/node_modules/normalize.css/normalize.css'.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json index facb2f8f172fe..7c988b2ceec64 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json @@ -25,7 +25,7 @@ "File '/node_modules/foo/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", - "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was found.", + "File '/node_modules/foo/package.json' exists according to earlier cached lookups.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", "'package.json' does not have a 'main' field.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json index 41f8daee2dd96..0d92fd01ac81d 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_withAmbientPresent.trace.json @@ -11,7 +11,7 @@ "File '/node_modules/js/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'js' from 'node_modules' folder, target file type 'JavaScript'.", - "Using cached result of 'package.json' at '/node_modules/js/package.json' that indicates it was not found.", + "File '/node_modules/js/package.json' does not exist according to earlier cached lookups.", "File '/node_modules/js.js' does not exist.", "File '/node_modules/js.jsx' does not exist.", "File '/node_modules/js/index.js' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_withPaths.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_withPaths.trace.json index e6df918dabbb8..85fa415976b99 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_withPaths.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_withPaths.trace.json @@ -25,7 +25,7 @@ "File '/node_modules/foo/lib/test.ts' does not exist.", "File '/node_modules/foo/lib/test.tsx' does not exist.", "File '/node_modules/foo/lib/test.d.ts' exist - use it as a name resolution result.", - "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was not found.", + "File '/node_modules/foo/package.json' does not exist according to earlier cached lookups.", "======== Module name 'foo/test' was successfully resolved to '/node_modules/foo/lib/test.d.ts'. ========", "======== Resolving module './relative.js' from '/test.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json b/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json index e85afdc6f3a5e..414d4d5dec720 100644 --- a/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json +++ b/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json @@ -21,7 +21,7 @@ "======== Resolving module 'linked' from '/app/app.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'linked' from 'node_modules' folder, target file type 'TypeScript'.", - "Using cached result of 'package.json' at '/app/node_modules/linked/package.json' that indicates it was not found.", + "File '/app/node_modules/linked/package.json' does not exist according to earlier cached lookups.", "File '/app/node_modules/linked.ts' does not exist.", "File '/app/node_modules/linked.tsx' does not exist.", "File '/app/node_modules/linked.d.ts' does not exist.", @@ -44,7 +44,7 @@ "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'real' from 'node_modules' folder, target file type 'TypeScript'.", "Directory '/app/node_modules/linked2/node_modules' does not exist, skipping all lookups in it.", - "Using cached result of 'package.json' at '/app/node_modules/real/package.json' that indicates it was not found.", + "File '/app/node_modules/real/package.json' does not exist according to earlier cached lookups.", "File '/app/node_modules/real.ts' does not exist.", "File '/app/node_modules/real.tsx' does not exist.", "File '/app/node_modules/real.d.ts' does not exist.", diff --git a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot.trace.json b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot.trace.json index 5adc657ef49f7..fa6937b140151 100644 --- a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot.trace.json +++ b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot.trace.json @@ -21,8 +21,8 @@ "File '/node_modules/foo/bar/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo/bar' from 'node_modules' folder, target file type 'JavaScript'.", - "Using cached result of 'package.json' at '/node_modules/foo/bar/package.json' that indicates it was not found.", - "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was found.", + "File '/node_modules/foo/bar/package.json' does not exist according to earlier cached lookups.", + "File '/node_modules/foo/package.json' exists according to earlier cached lookups.", "File '/node_modules/foo/bar.js' does not exist.", "File '/node_modules/foo/bar.jsx' does not exist.", "'package.json' does not have a 'main' field.", diff --git a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.trace.json b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.trace.json index c191b204b7d31..8bc7e06171163 100644 --- a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.trace.json +++ b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.trace.json @@ -21,8 +21,8 @@ "File '/node_modules/foo/@bar/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo/@bar' from 'node_modules' folder, target file type 'JavaScript'.", - "Using cached result of 'package.json' at '/node_modules/foo/@bar/package.json' that indicates it was not found.", - "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was found.", + "File '/node_modules/foo/@bar/package.json' does not exist according to earlier cached lookups.", + "File '/node_modules/foo/package.json' exists according to earlier cached lookups.", "File '/node_modules/foo/@bar.js' does not exist.", "File '/node_modules/foo/@bar.jsx' does not exist.", "'package.json' does not have a 'main' field.", diff --git a/tests/baselines/reference/packageJsonMain.trace.json b/tests/baselines/reference/packageJsonMain.trace.json index 93a7b60cfd73f..e5ae23f1d011a 100644 --- a/tests/baselines/reference/packageJsonMain.trace.json +++ b/tests/baselines/reference/packageJsonMain.trace.json @@ -21,7 +21,7 @@ "File '/node_modules/foo/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", - "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was found.", + "File '/node_modules/foo/package.json' exists according to earlier cached lookups.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", "'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.", @@ -57,7 +57,7 @@ "File '/node_modules/bar/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'bar' from 'node_modules' folder, target file type 'JavaScript'.", - "Using cached result of 'package.json' at '/node_modules/bar/package.json' that indicates it was found.", + "File '/node_modules/bar/package.json' exists according to earlier cached lookups.", "File '/node_modules/bar.js' does not exist.", "File '/node_modules/bar.jsx' does not exist.", "'package.json' has 'main' field 'rab.js' that references '/node_modules/bar/rab.js'.", @@ -88,7 +88,7 @@ "File '/node_modules/baz/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'baz' from 'node_modules' folder, target file type 'JavaScript'.", - "Using cached result of 'package.json' at '/node_modules/baz/package.json' that indicates it was found.", + "File '/node_modules/baz/package.json' exists according to earlier cached lookups.", "File '/node_modules/baz.js' does not exist.", "File '/node_modules/baz.jsx' does not exist.", "'package.json' has 'main' field 'zab' that references '/node_modules/baz/zab'.", diff --git a/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json b/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json index 7bd49b1ecd56b..97a56a2ce4e9b 100644 --- a/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json +++ b/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json @@ -23,7 +23,7 @@ "File '/node_modules/foo/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", - "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was found.", + "File '/node_modules/foo/package.json' exists according to earlier cached lookups.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", "'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.trace.json index fb8637c521dd9..2597e6ac2eb84 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution_withExtension_MapedToNodeModules.trace.json @@ -36,6 +36,6 @@ "File '/node_modules/foo/bar/foobar.js.jsx' does not exist.", "File name '/node_modules/foo/bar/foobar.js' has a '.js' extension - stripping it.", "File '/node_modules/foo/bar/foobar.js' exist - use it as a name resolution result.", - "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was not found.", + "File '/node_modules/foo/package.json' does not exist according to earlier cached lookups.", "======== Module name 'foo/bar/foobar.js' was successfully resolved to '/node_modules/foo/bar/foobar.js'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/requireOfJsonFileWithoutResolveJsonModuleAndPathMapping.trace.json b/tests/baselines/reference/requireOfJsonFileWithoutResolveJsonModuleAndPathMapping.trace.json index 21b1881daa045..5fcf495860391 100644 --- a/tests/baselines/reference/requireOfJsonFileWithoutResolveJsonModuleAndPathMapping.trace.json +++ b/tests/baselines/reference/requireOfJsonFileWithoutResolveJsonModuleAndPathMapping.trace.json @@ -29,7 +29,7 @@ "Trying substitution 'src/types', candidate module location: 'src/types'.", "Loading module as file / folder, candidate module location '/src/types', target file type 'JavaScript'.", "Loading module 'foo/bar/foobar.json' from 'node_modules' folder, target file type 'JavaScript'.", - "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was not found.", + "File '/node_modules/foo/package.json' does not exist according to earlier cached lookups.", "File '/node_modules/foo/bar/foobar.json.js' does not exist.", "File '/node_modules/foo/bar/foobar.json.jsx' does not exist.", "======== Module name 'foo/bar/foobar.json' was not resolved. ========" diff --git a/tests/baselines/reference/requireOfJsonFile_PathMapping.trace.json b/tests/baselines/reference/requireOfJsonFile_PathMapping.trace.json index 36af12924efd7..a8e76904b715d 100644 --- a/tests/baselines/reference/requireOfJsonFile_PathMapping.trace.json +++ b/tests/baselines/reference/requireOfJsonFile_PathMapping.trace.json @@ -29,7 +29,7 @@ "Trying substitution 'src/types', candidate module location: 'src/types'.", "Loading module as file / folder, candidate module location '/src/types', target file type 'JavaScript'.", "Loading module 'foo/bar/foobar.json' from 'node_modules' folder, target file type 'JavaScript'.", - "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was not found.", + "File '/node_modules/foo/package.json' does not exist according to earlier cached lookups.", "File '/node_modules/foo/bar/foobar.json.js' does not exist.", "File '/node_modules/foo/bar/foobar.json.jsx' does not exist.", "'baseUrl' option is set to '/', using this value to resolve non-relative module name 'foo/bar/foobar.json'.", @@ -38,6 +38,6 @@ "Trying substitution 'node_modules/*', candidate module location: 'node_modules/foo/bar/foobar.json'.", "Loading module as file / folder, candidate module location '/node_modules/foo/bar/foobar.json', target file type 'Json'.", "File '/node_modules/foo/bar/foobar.json' exist - use it as a name resolution result.", - "Using cached result of 'package.json' at '/node_modules/foo/package.json' that indicates it was not found.", + "File '/node_modules/foo/package.json' does not exist according to earlier cached lookups.", "======== Module name 'foo/bar/foobar.json' was successfully resolved to '/node_modules/foo/bar/foobar.json'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/scopedPackages.trace.json b/tests/baselines/reference/scopedPackages.trace.json index b377d5d8978e7..29170ab5bd378 100644 --- a/tests/baselines/reference/scopedPackages.trace.json +++ b/tests/baselines/reference/scopedPackages.trace.json @@ -24,7 +24,7 @@ "Module resolution kind is not specified, using 'NodeJs'.", "Loading module '@be/bop/e/z' from 'node_modules' folder, target file type 'TypeScript'.", "Scoped package detected, looking in 'be__bop/e/z'", - "Using cached result of 'package.json' at '/node_modules/@types/be__bop/package.json' that indicates it was not found.", + "File '/node_modules/@types/be__bop/package.json' does not exist according to earlier cached lookups.", "File '/node_modules/@types/be__bop/e/z.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/be__bop/e/z.d.ts', result '/node_modules/@types/be__bop/e/z.d.ts'.", "======== Module name '@be/bop/e/z' was successfully resolved to '/node_modules/@types/be__bop/e/z.d.ts'. ========" diff --git a/tests/baselines/reference/typesVersions.ambientModules.trace.json b/tests/baselines/reference/typesVersions.ambientModules.trace.json index 1497d0c26428d..67a3b617bce03 100644 --- a/tests/baselines/reference/typesVersions.ambientModules.trace.json +++ b/tests/baselines/reference/typesVersions.ambientModules.trace.json @@ -22,7 +22,7 @@ "======== Resolving module 'ext/other' from 'tests/cases/conformance/moduleResolution/main.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", - "Using cached result of 'package.json' at 'tests/cases/conformance/moduleResolution/node_modules/ext/package.json' that indicates it was found.", + "File 'tests/cases/conformance/moduleResolution/node_modules/ext/package.json' exists according to earlier cached lookups.", "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", @@ -42,7 +42,7 @@ "Directory 'node_modules' does not exist, skipping all lookups in it.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "Loading module 'ext/other' from 'node_modules' folder, target file type 'JavaScript'.", - "Using cached result of 'package.json' at 'tests/cases/conformance/moduleResolution/node_modules/ext/package.json' that indicates it was found.", + "File 'tests/cases/conformance/moduleResolution/node_modules/ext/package.json' exists according to earlier cached lookups.", "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", diff --git a/tests/baselines/reference/typesVersions.multiFile.trace.json b/tests/baselines/reference/typesVersions.multiFile.trace.json index e4bf9273edbf5..5ee8a7b292e21 100644 --- a/tests/baselines/reference/typesVersions.multiFile.trace.json +++ b/tests/baselines/reference/typesVersions.multiFile.trace.json @@ -22,7 +22,7 @@ "======== Resolving module 'ext/other' from 'tests/cases/conformance/moduleResolution/main.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", - "Using cached result of 'package.json' at 'tests/cases/conformance/moduleResolution/node_modules/ext/package.json' that indicates it was found.", + "File 'tests/cases/conformance/moduleResolution/node_modules/ext/package.json' exists according to earlier cached lookups.", "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json index 5fd5d9ff7ef80..a0c6ad8f1cfd0 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json @@ -22,7 +22,7 @@ "======== Resolving module 'ext/other' from 'tests/cases/conformance/declarationEmit/main.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", - "Using cached result of 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' that indicates it was found.", + "File 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' exists according to earlier cached lookups.", "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", @@ -42,7 +42,7 @@ "Directory 'node_modules' does not exist, skipping all lookups in it.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "Loading module 'ext/other' from 'node_modules' folder, target file type 'JavaScript'.", - "Using cached result of 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' that indicates it was found.", + "File 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' exists according to earlier cached lookups.", "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json index dfbcd9f4dde6d..c283d3ef124e6 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json @@ -22,7 +22,7 @@ "======== Resolving module 'ext/other' from 'tests/cases/conformance/declarationEmit/main.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", - "Using cached result of 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' that indicates it was found.", + "File 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' exists according to earlier cached lookups.", "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json index 77e0315669d24..a487a795006e0 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json @@ -21,12 +21,12 @@ "File 'tests/cases/conformance/declarationEmit/node_modules/ext/other.ts' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/other.tsx' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/other.d.ts' exist - use it as a name resolution result.", - "Using cached result of 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' that indicates it was found.", + "File 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' exists according to earlier cached lookups.", "======== Module name '../other' was successfully resolved to 'tests/cases/conformance/declarationEmit/node_modules/ext/other.d.ts' with Package ID 'ext/ther.d.ts@1.0.0'. ========", "======== Resolving module 'ext' from 'tests/cases/conformance/declarationEmit/main.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'ext' from 'node_modules' folder, target file type 'TypeScript'.", - "Using cached result of 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' that indicates it was found.", + "File 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' exists according to earlier cached lookups.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext.ts' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext.tsx' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext.d.ts' does not exist.", @@ -45,7 +45,7 @@ "======== Resolving module 'ext/other' from 'tests/cases/conformance/declarationEmit/main.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", - "Using cached result of 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' that indicates it was found.", + "File 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' exists according to earlier cached lookups.", "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "Module name 'other', matched pattern '*'.", "Trying substitution 'ts3.1/*', candidate module location: 'ts3.1/other'.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json index b8c1843096f55..95ccfa6aa8be1 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json @@ -11,7 +11,7 @@ "======== Resolving module 'ext' from 'tests/cases/conformance/declarationEmit/main.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'ext' from 'node_modules' folder, target file type 'TypeScript'.", - "Using cached result of 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' that indicates it was found.", + "File 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' exists according to earlier cached lookups.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext.ts' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext.tsx' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext.d.ts' does not exist.", @@ -30,7 +30,7 @@ "======== Resolving module 'ext/other' from 'tests/cases/conformance/declarationEmit/main.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'ext/other' from 'node_modules' folder, target file type 'TypeScript'.", - "Using cached result of 'package.json' at 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' that indicates it was found.", + "File 'tests/cases/conformance/declarationEmit/node_modules/ext/package.json' exists according to earlier cached lookups.", "'package.json' has a 'typesVersions' entry '>=3.1.0-0' that matches compiler version '3.1.0-dev', looking for a pattern to match module name 'other'.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/other.ts' does not exist.", "File 'tests/cases/conformance/declarationEmit/node_modules/ext/other.tsx' does not exist.", diff --git a/tests/baselines/reference/typingsLookup4.trace.json b/tests/baselines/reference/typingsLookup4.trace.json index c14a1746e3702..a493f6f8883a1 100644 --- a/tests/baselines/reference/typingsLookup4.trace.json +++ b/tests/baselines/reference/typingsLookup4.trace.json @@ -65,14 +65,14 @@ "======== Module name 'mquery' was successfully resolved to '/node_modules/@types/mquery/mquery/index.tsx'. ========", "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", - "Using cached result of 'package.json' at '/node_modules/@types/jquery/package.json' that indicates it was found.", + "File '/node_modules/@types/jquery/package.json' exists according to earlier cached lookups.", "'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.", "File '/node_modules/@types/jquery/jquery.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/jquery/jquery.d.ts', result '/node_modules/@types/jquery/jquery.d.ts'.", "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/jquery.d.ts', primary: true. ========", "======== Resolving type reference directive 'kquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", - "Using cached result of 'package.json' at '/node_modules/@types/kquery/package.json' that indicates it was found.", + "File '/node_modules/@types/kquery/package.json' exists according to earlier cached lookups.", "'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.", "File '/node_modules/@types/kquery/kquery' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/@types/kquery/kquery', target file type 'TypeScript'.", @@ -83,7 +83,7 @@ "======== Type reference directive 'kquery' was successfully resolved to '/node_modules/@types/kquery/kquery.d.ts', primary: true. ========", "======== Resolving type reference directive 'lquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", - "Using cached result of 'package.json' at '/node_modules/@types/lquery/package.json' that indicates it was found.", + "File '/node_modules/@types/lquery/package.json' exists according to earlier cached lookups.", "'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.", "File '/node_modules/@types/lquery/lquery' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/@types/lquery/lquery', target file type 'TypeScript'.", @@ -92,7 +92,7 @@ "======== Type reference directive 'lquery' was successfully resolved to '/node_modules/@types/lquery/lquery.ts', primary: true. ========", "======== Resolving type reference directive 'mquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", - "Using cached result of 'package.json' at '/node_modules/@types/mquery/package.json' that indicates it was found.", + "File '/node_modules/@types/mquery/package.json' exists according to earlier cached lookups.", "'package.json' has 'typings' field 'mquery' that references '/node_modules/@types/mquery/mquery'.", "File '/node_modules/@types/mquery/mquery' does not exist.", "Loading module as file / folder, candidate module location '/node_modules/@types/mquery/mquery', target file type 'TypeScript'.", diff --git a/tests/baselines/reference/typingsLookupAmd.trace.json b/tests/baselines/reference/typingsLookupAmd.trace.json index 5b3fe5585ff7a..31cd72105f1dd 100644 --- a/tests/baselines/reference/typingsLookupAmd.trace.json +++ b/tests/baselines/reference/typingsLookupAmd.trace.json @@ -41,7 +41,7 @@ "======== Module name 'a' was successfully resolved to '/node_modules/@types/a/index.d.ts'. ========", "======== Resolving type reference directive 'a', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", - "Using cached result of 'package.json' at '/node_modules/@types/a/package.json' that indicates it was not found.", + "File '/node_modules/@types/a/package.json' does not exist according to earlier cached lookups.", "File '/node_modules/@types/a/index.d.ts' exist - use it as a name resolution result.", "Resolving real path for '/node_modules/@types/a/index.d.ts', result '/node_modules/@types/a/index.d.ts'.", "======== Type reference directive 'a' was successfully resolved to '/node_modules/@types/a/index.d.ts', primary: true. ========"