diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json
index f582f36df63ac..fd5acd0cf83e1 100644
--- a/src/compiler/diagnosticMessages.json
+++ b/src/compiler/diagnosticMessages.json
@@ -5246,6 +5246,10 @@
"category": "Message",
"code": 6264
},
+ "Resolving type reference directive for program that specifies custom typeRoots, skipping lookup in 'node_modules' folder.": {
+ "category": "Message",
+ "code": 6265
+ },
"Directory '{0}' has no containing package.json scope. Imports will not resolve.": {
"category": "Message",
diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts
index bf81a917d68f1..e330825fa3fb9 100644
--- a/src/compiler/moduleNameResolver.ts
+++ b/src/compiler/moduleNameResolver.ts
@@ -55,6 +55,7 @@ import {
hasProperty,
hasTrailingDirectorySeparator,
hostGetCanonicalFileName,
+ inferredTypesContainingFile,
isArray,
isDeclarationFileName,
isExternalModuleNameRelative,
@@ -450,7 +451,7 @@ export function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffecti
}
if (currentDirectory !== undefined) {
- return getDefaultTypeRoots(currentDirectory, host);
+ return getDefaultTypeRoots(currentDirectory);
}
}
@@ -458,19 +459,11 @@ export function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffecti
* Returns the path to every node_modules/@types directory from some ancestor directory.
* Returns undefined if there are none.
*/
-function getDefaultTypeRoots(currentDirectory: string, host: { directoryExists?: (directoryName: string) => boolean }): string[] | undefined {
- if (!host.directoryExists) {
- return [combinePaths(currentDirectory, nodeModulesAtTypes)];
- // And if it doesn't exist, tough.
- }
-
+function getDefaultTypeRoots(currentDirectory: string): string[] | undefined {
let typeRoots: string[] | undefined;
forEachAncestorDirectory(normalizePath(currentDirectory), directory => {
const atTypes = combinePaths(directory, nodeModulesAtTypes);
- if (host.directoryExists!(atTypes)) {
- (typeRoots || (typeRoots = [])).push(atTypes);
- }
- return undefined;
+ (typeRoots ??= []).push(atTypes);
});
return typeRoots;
}
@@ -627,10 +620,18 @@ export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string
}
return firstDefined(typeRoots, typeRoot => {
const candidate = combinePaths(typeRoot, typeReferenceDirectiveName);
- const candidateDirectory = getDirectoryPath(candidate);
- const directoryExists = directoryProbablyExists(candidateDirectory, host);
+ const directoryExists = directoryProbablyExists(typeRoot, host);
if (!directoryExists && traceEnabled) {
- trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory);
+ trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, typeRoot);
+ }
+ if (options.typeRoots) {
+ // Custom typeRoots resolve as file or directory just like we do modules
+ const resolvedFromFile = loadModuleFromFile(Extensions.Declaration, candidate, !directoryExists, moduleResolutionState);
+ if (resolvedFromFile) {
+ const packageDirectory = parseNodeModuleFromPath(resolvedFromFile.path);
+ const packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, /*onlyRecordFailures*/ false, moduleResolutionState) : undefined;
+ return resolvedTypeScriptOnly(withPackageId(packageInfo, resolvedFromFile));
+ }
}
return resolvedTypeScriptOnly(
loadNodeModuleFromDirectory(Extensions.Declaration, candidate,
@@ -646,20 +647,24 @@ export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string
function secondaryLookup(): PathAndPackageId | undefined {
const initialLocationForSecondaryLookup = containingFile && getDirectoryPath(containingFile);
-
if (initialLocationForSecondaryLookup !== undefined) {
- // check secondary locations
- if (traceEnabled) {
- trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
- }
let result: Resolved | undefined;
- if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) {
- const searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.Declaration, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined, /*redirectedReference*/ undefined);
- result = searchResult && searchResult.value;
+ if (!options.typeRoots || !endsWith(containingFile!, inferredTypesContainingFile)) {
+ // check secondary locations
+ if (traceEnabled) {
+ trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
+ }
+ if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) {
+ const searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.Declaration, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined, /*redirectedReference*/ undefined);
+ result = searchResult && searchResult.value;
+ }
+ else {
+ const { path: candidate } = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName);
+ result = nodeLoadModuleByRelativeName(Extensions.Declaration, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true);
+ }
}
- else {
- const { path: candidate } = normalizePathForCJSResolution(initialLocationForSecondaryLookup, typeReferenceDirectiveName);
- result = nodeLoadModuleByRelativeName(Extensions.Declaration, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true);
+ else if (traceEnabled) {
+ trace(host, Diagnostics.Resolving_type_reference_directive_for_program_that_specifies_custom_typeRoots_skipping_lookup_in_node_modules_folder);
}
return resolvedTypeScriptOnly(result);
}
@@ -1777,6 +1782,9 @@ function nodeModuleNameResolverWorker(features: NodeResolutionFeatures, moduleNa
}
resolved = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
}
+ if (extensions & Extensions.Declaration) {
+ resolved ??= resolveFromTypeRoot(moduleName, state);
+ }
// For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files.
return resolved && { value: resolved.value && { resolved: resolved.value, isExternalLibraryImport: true } };
}
@@ -3058,12 +3066,12 @@ export function classicNameResolver(moduleName: string, containingFile: string,
const searchName = normalizePath(combinePaths(directory, moduleName));
return toSearchResult(loadModuleFromFileNoPackageId(extensions, searchName, /*onlyRecordFailures*/ false, state));
});
- if (resolved) {
- return resolved;
- }
+ if (resolved) return resolved;
if (extensions & (Extensions.TypeScript | Extensions.Declaration)) {
// If we didn't find the file normally, look it up in @types.
- return loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
+ let resolved = loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
+ if (extensions & Extensions.Declaration) resolved ??= resolveFromTypeRoot(moduleName, state);
+ return resolved;
}
}
else {
@@ -3073,6 +3081,25 @@ export function classicNameResolver(moduleName: string, containingFile: string,
}
}
+function resolveFromTypeRoot(moduleName: string, state: ModuleResolutionState) {
+ if (!state.compilerOptions.typeRoots) return;
+ for (const typeRoot of state.compilerOptions.typeRoots) {
+ const candidate = combinePaths(typeRoot, moduleName);
+ const directoryExists = directoryProbablyExists(typeRoot, state.host);
+ if (!directoryExists && state.traceEnabled) {
+ trace(state.host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, typeRoot);
+ }
+ const resolvedFromFile = loadModuleFromFile(Extensions.Declaration, candidate, !directoryExists, state);
+ if (resolvedFromFile) {
+ const packageDirectory = parseNodeModuleFromPath(resolvedFromFile.path);
+ const packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, /*onlyRecordFailures*/ false, state) : undefined;
+ return toSearchResult(withPackageId(packageInfo, resolvedFromFile));
+ }
+ const resolved = loadNodeModuleFromDirectory(Extensions.Declaration, candidate, !directoryExists, state);
+ if (resolved) return toSearchResult(resolved);
+ }
+}
+
// Program errors validate that `noEmit` or `emitDeclarationOnly` is also set,
// so this function doesn't check them to avoid propagating errors.
/** @internal */
diff --git a/src/compiler/resolutionCache.ts b/src/compiler/resolutionCache.ts
index 0f29b75d31b89..995de60bb2586 100644
--- a/src/compiler/resolutionCache.ts
+++ b/src/compiler/resolutionCache.ts
@@ -1167,26 +1167,28 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
function createTypeRootsWatch(typeRootPath: Path, typeRoot: string): FileWatcher {
// Create new watch and recursive info
- return resolutionHost.watchTypeRootsDirectory(typeRoot, fileOrDirectory => {
- const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
- if (cachedDirectoryStructureHost) {
- // Since the file existence changed, update the sourceFiles cache
- cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
- }
-
- // For now just recompile
- // We could potentially store more data here about whether it was/would be really be used or not
- // and with that determine to trigger compilation but for now this is enough
- hasChangedAutomaticTypeDirectiveNames = true;
- resolutionHost.onChangedAutomaticTypeDirectiveNames();
+ return canWatchTypeRootPath(typeRootPath) ?
+ resolutionHost.watchTypeRootsDirectory(typeRoot, fileOrDirectory => {
+ const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
+ if (cachedDirectoryStructureHost) {
+ // Since the file existence changed, update the sourceFiles cache
+ cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
+ }
- // Since directory watchers invoked are flaky, the failed lookup location events might not be triggered
- // So handle to failed lookup locations here as well to ensure we are invalidating resolutions
- const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath);
- if (dirPath) {
- scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
- }
- }, WatchDirectoryFlags.Recursive);
+ // For now just recompile
+ // We could potentially store more data here about whether it was/would be really be used or not
+ // and with that determine to trigger compilation but for now this is enough
+ hasChangedAutomaticTypeDirectiveNames = true;
+ resolutionHost.onChangedAutomaticTypeDirectiveNames();
+
+ // Since directory watchers invoked are flaky, the failed lookup location events might not be triggered
+ // So handle to failed lookup locations here as well to ensure we are invalidating resolutions
+ const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath);
+ if (dirPath) {
+ scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
+ }
+ }, WatchDirectoryFlags.Recursive) :
+ noopFileWatcher;
}
/**
@@ -1204,7 +1206,7 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
// we need to assume the directories exist to ensure that we can get all the type root directories that get included
// But filter directories that are at root level to say directory doesnt exist, so that we arent watching them
- const typeRoots = getEffectiveTypeRoots(options, { directoryExists: directoryExistsForTypeRootWatch, getCurrentDirectory });
+ const typeRoots = getEffectiveTypeRoots(options, { getCurrentDirectory });
if (typeRoots) {
mutateMap(
typeRootsWatches,
@@ -1220,12 +1222,11 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
}
}
- /**
- * Use this function to return if directory exists to get type roots to watch
- * If we return directory exists then only the paths will be added to type roots
- * Hence return true for all directories except root directories which are filtered from watching
- */
- function directoryExistsForTypeRootWatch(nodeTypesDirectory: string) {
+ function canWatchTypeRootPath(nodeTypesDirectory: string) {
+ // If type roots is specified, watch that path
+ if (resolutionHost.getCompilationSettings().typeRoots) return true;
+
+ // Otherwise can watch directory only if we can watch the parent directory of node_modules/@types
const dir = getDirectoryPath(getDirectoryPath(nodeTypesDirectory));
const dirPath = resolutionHost.toPath(dir);
return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
diff --git a/src/compiler/types.ts b/src/compiler/types.ts
index bb21ab8749795..35e899e351a55 100644
--- a/src/compiler/types.ts
+++ b/src/compiler/types.ts
@@ -9473,7 +9473,6 @@ export interface EmitTextWriter extends SymbolWriter {
}
export interface GetEffectiveTypeRootsHost {
- directoryExists?(directoryName: string): boolean;
getCurrentDirectory?(): string;
}
diff --git a/src/server/project.ts b/src/server/project.ts
index b9b4a793411d3..8dee92fdc9d68 100644
--- a/src/server/project.ts
+++ b/src/server/project.ts
@@ -2827,7 +2827,7 @@ export class ConfiguredProject extends Project {
}
getEffectiveTypeRoots() {
- return getEffectiveTypeRoots(this.getCompilationSettings(), this.directoryStructureHost) || [];
+ return getEffectiveTypeRoots(this.getCompilationSettings(), this) || [];
}
/** @internal */
diff --git a/src/testRunner/unittests/tscWatch/programUpdates.ts b/src/testRunner/unittests/tscWatch/programUpdates.ts
index 82f28e61aee54..5aaa8e4af9a48 100644
--- a/src/testRunner/unittests/tscWatch/programUpdates.ts
+++ b/src/testRunner/unittests/tscWatch/programUpdates.ts
@@ -970,28 +970,36 @@ declare const eval: any`
]
});
- verifyTscWatch({
- scenario,
- subScenario: "types should load from config file path if config exists",
- commandLineArgs: ["-w", "-p", configFilePath],
- sys: () => {
- const f1 = {
- path: "/a/b/app.ts",
- content: "let x = 1"
- };
- const config = {
- path: configFilePath,
- content: JSON.stringify({ compilerOptions: { types: ["node"], typeRoots: [] } })
- };
- const node = {
- path: "/a/b/node_modules/@types/node/index.d.ts",
- content: "declare var process: any"
- };
- const cwd = {
- path: "/a/c"
- };
- return createWatchedSystem([f1, config, node, cwd, libFile], { currentDirectory: cwd.path });
- },
+ describe("types from config file", () => {
+ function verifyTypesLoad(includeTypeRoots: boolean) {
+ verifyTscWatch({
+ scenario,
+ subScenario: includeTypeRoots ?
+ "types should not load from config file path if config exists but does not specifies typeRoots" :
+ "types should load from config file path if config exists",
+ commandLineArgs: ["-w", "-p", configFilePath],
+ sys: () => {
+ const f1 = {
+ path: "/a/b/app.ts",
+ content: "let x = 1"
+ };
+ const config = {
+ path: configFilePath,
+ content: JSON.stringify({ compilerOptions: { types: ["node"], typeRoots: includeTypeRoots ? [] : undefined } })
+ };
+ const node = {
+ path: "/a/b/node_modules/@types/node/index.d.ts",
+ content: "declare var process: any"
+ };
+ const cwd = {
+ path: "/a/c"
+ };
+ return createWatchedSystem([f1, config, node, cwd, libFile], { currentDirectory: cwd.path });
+ },
+ });
+ }
+ verifyTypesLoad(/*includeTypeRoots*/ false);
+ verifyTypesLoad(/*includeTypeRoots*/ true);
});
verifyTscWatch({
diff --git a/src/testRunner/unittests/tsserver/resolutionCache.ts b/src/testRunner/unittests/tsserver/resolutionCache.ts
index b59ace49f1015..2f9f509d0346b 100644
--- a/src/testRunner/unittests/tsserver/resolutionCache.ts
+++ b/src/testRunner/unittests/tsserver/resolutionCache.ts
@@ -345,27 +345,32 @@ describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem rename
projectService.checkNumberOfProjects({ configuredProjects: 1 });
});
- it("types should load from config file path if config exists", () => {
- const f1 = {
- path: "/a/b/app.ts",
- content: "let x = 1"
- };
- const config = {
- path: "/a/b/tsconfig.json",
- content: JSON.stringify({ compilerOptions: { types: ["node"], typeRoots: [] } })
- };
- const node = {
- path: "/a/b/node_modules/@types/node/index.d.ts",
- content: "declare var process: any"
- };
- const cwd = {
- path: "/a/c"
- };
- const host = createServerHost([f1, config, node, cwd], { currentDirectory: cwd.path });
- const projectService = createProjectService(host);
- projectService.openClientFile(f1.path);
- projectService.checkNumberOfProjects({ configuredProjects: 1 });
- checkProjectActualFiles(configuredProjectAt(projectService, 0), [f1.path, node.path, config.path]);
+ describe("types from config file", () => {
+ function verifyTypesLoad(subScenario: string, includeTypeRoots: boolean) {
+ it(subScenario, () => {
+ const f1 = {
+ path: "/a/b/app.ts",
+ content: "let x = 1"
+ };
+ const config = {
+ path: "/a/b/tsconfig.json",
+ content: JSON.stringify({ compilerOptions: { types: ["node"], typeRoots: includeTypeRoots ? [] : undefined } })
+ };
+ const node = {
+ path: "/a/b/node_modules/@types/node/index.d.ts",
+ content: "declare var process: any"
+ };
+ const cwd = {
+ path: "/a/c"
+ };
+ const host = createServerHost([f1, config, node, cwd], { currentDirectory: cwd.path });
+ const projectService = createProjectService(host, { logger: createLoggerWithInMemoryLogs(host) });
+ projectService.openClientFile(f1.path);
+ baselineTsserverLogs("resolutionCache", subScenario, projectService);
+ });
+ }
+ verifyTypesLoad("types should load from config file path if config exists", /*includeTypeRoots*/ false);
+ verifyTypesLoad("types should not load from config file path if config exists but does not specifies typeRoots", /*includeTypeRoots*/ true);
});
});
diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts
index deca7c43b4b83..5b043aef89a70 100644
--- a/tests/baselines/reference/api/tsserverlibrary.d.ts
+++ b/tests/baselines/reference/api/tsserverlibrary.d.ts
@@ -8151,7 +8151,6 @@ declare namespace ts {
noEmitHelpers?: boolean;
}
interface GetEffectiveTypeRootsHost {
- directoryExists?(directoryName: string): boolean;
getCurrentDirectory?(): string;
}
interface TextSpan {
diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts
index b7a1a455832e4..251acae603dc7 100644
--- a/tests/baselines/reference/api/typescript.d.ts
+++ b/tests/baselines/reference/api/typescript.d.ts
@@ -4176,7 +4176,6 @@ declare namespace ts {
noEmitHelpers?: boolean;
}
interface GetEffectiveTypeRootsHost {
- directoryExists?(directoryName: string): boolean;
getCurrentDirectory?(): string;
}
interface TextSpan {
diff --git a/tests/baselines/reference/library-reference-1.trace.json b/tests/baselines/reference/library-reference-1.trace.json
index f61b4add7c9c8..b53518630ee01 100644
--- a/tests/baselines/reference/library-reference-1.trace.json
+++ b/tests/baselines/reference/library-reference-1.trace.json
@@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'.",
+ "File 'types/jquery.d.ts' does not exist.",
"File 'types/jquery/package.json' does not exist.",
"File 'types/jquery/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for 'types/jquery/index.d.ts', result '/src/types/jquery/index.d.ts'.",
diff --git a/tests/baselines/reference/library-reference-10.trace.json b/tests/baselines/reference/library-reference-10.trace.json
index 38f31bafb9cc9..53404db89e334 100644
--- a/tests/baselines/reference/library-reference-10.trace.json
+++ b/tests/baselines/reference/library-reference-10.trace.json
@@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'jquery', containing file '/foo/consumer.ts', root directory './types'. ========",
"Resolving with primary search path './types'.",
+ "File './types/jquery.d.ts' does not exist.",
"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'.",
diff --git a/tests/baselines/reference/library-reference-11.trace.json b/tests/baselines/reference/library-reference-11.trace.json
index 020fbdae08a1a..2e450e444e949 100644
--- a/tests/baselines/reference/library-reference-11.trace.json
+++ b/tests/baselines/reference/library-reference-11.trace.json
@@ -1,6 +1,7 @@
[
- "======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory not set. ========",
- "Root directory cannot be determined, skipping primary search paths.",
+ "======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory '/node_modules/@types'. ========",
+ "Resolving with primary search path '/node_modules/@types'.",
+ "Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/a/b'.",
"Directory '/a/b/node_modules' does not exist, skipping all lookups in it.",
"Found 'package.json' at '/a/node_modules/jquery/package.json'.",
diff --git a/tests/baselines/reference/library-reference-12.trace.json b/tests/baselines/reference/library-reference-12.trace.json
index a138305793937..e53bb5237eb42 100644
--- a/tests/baselines/reference/library-reference-12.trace.json
+++ b/tests/baselines/reference/library-reference-12.trace.json
@@ -1,6 +1,7 @@
[
- "======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory not set. ========",
- "Root directory cannot be determined, skipping primary search paths.",
+ "======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory '/node_modules/@types'. ========",
+ "Resolving with primary search path '/node_modules/@types'.",
+ "Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/a/b'.",
"Directory '/a/b/node_modules' does not exist, skipping all lookups in it.",
"Found 'package.json' at '/a/node_modules/jquery/package.json'.",
diff --git a/tests/baselines/reference/library-reference-13.trace.json b/tests/baselines/reference/library-reference-13.trace.json
index 727e13c40bc77..f86420020c182 100644
--- a/tests/baselines/reference/library-reference-13.trace.json
+++ b/tests/baselines/reference/library-reference-13.trace.json
@@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory '/a/types'. ========",
"Resolving with primary search path '/a/types'.",
+ "File '/a/types/jquery.d.ts' does not exist.",
"File '/a/types/jquery/package.json' does not exist.",
"File '/a/types/jquery/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/a/types/jquery/index.d.ts', result '/a/types/jquery/index.d.ts'.",
diff --git a/tests/baselines/reference/library-reference-14.trace.json b/tests/baselines/reference/library-reference-14.trace.json
index 727e13c40bc77..f86420020c182 100644
--- a/tests/baselines/reference/library-reference-14.trace.json
+++ b/tests/baselines/reference/library-reference-14.trace.json
@@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory '/a/types'. ========",
"Resolving with primary search path '/a/types'.",
+ "File '/a/types/jquery.d.ts' does not exist.",
"File '/a/types/jquery/package.json' does not exist.",
"File '/a/types/jquery/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/a/types/jquery/index.d.ts', result '/a/types/jquery/index.d.ts'.",
diff --git a/tests/baselines/reference/library-reference-15.trace.json b/tests/baselines/reference/library-reference-15.trace.json
index 729744d190a74..2056dd63f5083 100644
--- a/tests/baselines/reference/library-reference-15.trace.json
+++ b/tests/baselines/reference/library-reference-15.trace.json
@@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'.",
+ "File 'types/jquery.d.ts' does not exist.",
"File 'types/jquery/package.json' does not exist.",
"File 'types/jquery/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for 'types/jquery/index.d.ts', result '/a/types/jquery/index.d.ts'.",
diff --git a/tests/baselines/reference/library-reference-2.trace.json b/tests/baselines/reference/library-reference-2.trace.json
index bf333fd3212d0..096520745c723 100644
--- a/tests/baselines/reference/library-reference-2.trace.json
+++ b/tests/baselines/reference/library-reference-2.trace.json
@@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'jquery', containing file '/consumer.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
+ "File '/types/jquery.d.ts' does not exist.",
"Found 'package.json' at '/types/jquery/package.json'.",
"'package.json' does not have a 'typesVersions' field.",
"'package.json' does not have a 'typings' field.",
@@ -10,6 +11,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'.",
+ "File '/types/jquery.d.ts' does not exist.",
"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'.",
diff --git a/tests/baselines/reference/library-reference-3.trace.json b/tests/baselines/reference/library-reference-3.trace.json
index 79516a6139027..927753c4c1a3f 100644
--- a/tests/baselines/reference/library-reference-3.trace.json
+++ b/tests/baselines/reference/library-reference-3.trace.json
@@ -1,6 +1,8 @@
[
- "======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory not set. ========",
- "Root directory cannot be determined, skipping primary search paths.",
+ "======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory '/src/node_modules/@types,/node_modules/@types'. ========",
+ "Resolving with primary search path '/src/node_modules/@types, /node_modules/@types'.",
+ "Directory '/src/node_modules/@types' does not exist, skipping all lookups in it.",
+ "Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/src'.",
"File '/src/node_modules/jquery/package.json' does not exist.",
"File '/src/node_modules/jquery.d.ts' does not exist.",
diff --git a/tests/baselines/reference/library-reference-4.trace.json b/tests/baselines/reference/library-reference-4.trace.json
index 60ce5559db24e..1bc131aa6ceb2 100644
--- a/tests/baselines/reference/library-reference-4.trace.json
+++ b/tests/baselines/reference/library-reference-4.trace.json
@@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'foo', containing file '/src/root.ts', root directory '/src'. ========",
"Resolving with primary search path '/src'.",
+ "File '/src/foo.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/src'.",
"Directory '/src/node_modules' does not exist, skipping all lookups in it.",
"File '/node_modules/foo/package.json' does not exist.",
@@ -10,6 +11,7 @@
"======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: false. ========",
"======== Resolving type reference directive 'bar', containing file '/src/root.ts', root directory '/src'. ========",
"Resolving with primary search path '/src'.",
+ "File '/src/bar.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/src'.",
"Directory '/src/node_modules' does not exist, skipping all lookups in it.",
"File '/node_modules/bar/package.json' does not exist.",
@@ -19,6 +21,7 @@
"======== Type reference directive 'bar' was successfully resolved to '/node_modules/bar/index.d.ts', primary: false. ========",
"======== Resolving type reference directive 'alpha', containing file '/node_modules/foo/index.d.ts', root directory '/src'. ========",
"Resolving with primary search path '/src'.",
+ "File '/src/alpha.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/node_modules/foo'.",
"File '/node_modules/foo/node_modules/alpha/package.json' does not exist.",
"File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.",
@@ -27,6 +30,7 @@
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/foo/node_modules/alpha/index.d.ts', primary: false. ========",
"======== Resolving type reference directive 'alpha', containing file '/node_modules/bar/index.d.ts', root directory '/src'. ========",
"Resolving with primary search path '/src'.",
+ "File '/src/alpha.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/node_modules/bar'.",
"File '/node_modules/bar/node_modules/alpha/package.json' does not exist.",
"File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.",
diff --git a/tests/baselines/reference/library-reference-7.trace.json b/tests/baselines/reference/library-reference-7.trace.json
index 79516a6139027..0440471e41cd7 100644
--- a/tests/baselines/reference/library-reference-7.trace.json
+++ b/tests/baselines/reference/library-reference-7.trace.json
@@ -1,6 +1,7 @@
[
- "======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory not set. ========",
- "Root directory cannot be determined, skipping primary search paths.",
+ "======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory '/node_modules/@types'. ========",
+ "Resolving with primary search path '/node_modules/@types'.",
+ "Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/src'.",
"File '/src/node_modules/jquery/package.json' does not exist.",
"File '/src/node_modules/jquery.d.ts' does not exist.",
diff --git a/tests/baselines/reference/library-reference-8.trace.json b/tests/baselines/reference/library-reference-8.trace.json
index 7332af0a1cb58..4695682aaeb75 100644
--- a/tests/baselines/reference/library-reference-8.trace.json
+++ b/tests/baselines/reference/library-reference-8.trace.json
@@ -1,24 +1,28 @@
[
"======== Resolving type reference directive 'alpha', containing file '/test/foo.ts', root directory '/test/types'. ========",
"Resolving with primary search path '/test/types'.",
+ "File '/test/types/alpha.d.ts' does not exist.",
"File '/test/types/alpha/package.json' does not exist.",
"File '/test/types/alpha/index.d.ts' exists - 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 'beta', containing file '/test/foo.ts', root directory '/test/types'. ========",
"Resolving with primary search path '/test/types'.",
+ "File '/test/types/beta.d.ts' does not exist.",
"File '/test/types/beta/package.json' does not exist.",
"File '/test/types/beta/index.d.ts' exists - 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 'beta', containing file '/test/types/alpha/index.d.ts', root directory '/test/types'. ========",
"Resolving with primary search path '/test/types'.",
+ "File '/test/types/beta.d.ts' does not exist.",
"File '/test/types/beta/package.json' does not exist according to earlier cached lookups.",
"File '/test/types/beta/index.d.ts' exists - 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.d.ts' does not exist.",
"File '/test/types/alpha/package.json' does not exist according to earlier cached lookups.",
"File '/test/types/alpha/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/test/types/alpha/index.d.ts', result '/test/types/alpha/index.d.ts'.",
diff --git a/tests/baselines/reference/library-reference-scoped-packages.trace.json b/tests/baselines/reference/library-reference-scoped-packages.trace.json
index c3576ed31bc8b..b4e32ddc94902 100644
--- a/tests/baselines/reference/library-reference-scoped-packages.trace.json
+++ b/tests/baselines/reference/library-reference-scoped-packages.trace.json
@@ -1,7 +1,7 @@
[
"======== Resolving type reference directive '@beep/boop', containing file '/a.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'.",
- "Directory 'types/@beep' does not exist, skipping all lookups in it.",
+ "Directory 'types' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/'.",
"Scoped package detected, looking in 'beep__boop'",
"File '/node_modules/@types/beep__boop/package.json' does not exist.",
diff --git a/tests/baselines/reference/moduleResolution/type-reference-from-primary-location.js b/tests/baselines/reference/moduleResolution/type-reference-from-primary-location.js
index 282c0bb60a392..c2b369638d185 100644
--- a/tests/baselines/reference/moduleResolution/type-reference-from-primary-location.js
+++ b/tests/baselines/reference/moduleResolution/type-reference-from-primary-location.js
@@ -12,6 +12,7 @@ Resolution:: {
"isExternalLibraryImport": false
},
"failedLookupLocations": [
+ "/root/src/types/lib.d.ts",
"/root/src/types/lib/package.json"
]
}
@@ -32,6 +33,9 @@ Resolution:: {
"resolvedFileName": "/root/src/types/lib/typings/lib.d.ts",
"isExternalLibraryImport": false
},
+ "failedLookupLocations": [
+ "/root/src/types/lib.d.ts"
+ ],
"affectingLocations": [
"/root/src/types/lib/package.json"
]
@@ -51,6 +55,7 @@ Resolution:: {
"isExternalLibraryImport": true
},
"failedLookupLocations": [
+ "/root/src/types/lib.d.ts",
"/root/src/types/lib/package.json",
"/root/src/types/lib/index.d.ts",
"/root/src/node_modules/lib/package.json",
@@ -75,6 +80,7 @@ Resolution:: {
"isExternalLibraryImport": true
},
"failedLookupLocations": [
+ "/root/src/types/lib.d.ts",
"/root/src/types/lib/package.json",
"/root/src/types/lib/index.d.ts",
"/root/src/node_modules/lib.d.ts"
@@ -98,6 +104,7 @@ Resolution:: {
"isExternalLibraryImport": true
},
"failedLookupLocations": [
+ "/root/src/types/lib.d.ts",
"/root/src/types/lib/package.json",
"/root/src/types/lib/index.d.ts",
"/root/src/node_modules/lib/package.json",
@@ -125,6 +132,7 @@ Resolution:: {
"isExternalLibraryImport": true
},
"failedLookupLocations": [
+ "/root/src/types/lib.d.ts",
"/root/src/types/lib/package.json",
"/root/src/types/lib/index.d.ts",
"/root/src/node_modules/lib/package.json",
diff --git a/tests/baselines/reference/moduleResolution/type-reference-from-secondary-location.js b/tests/baselines/reference/moduleResolution/type-reference-from-secondary-location.js
index 8990d303378db..4f96a2c8cc9b8 100644
--- a/tests/baselines/reference/moduleResolution/type-reference-from-secondary-location.js
+++ b/tests/baselines/reference/moduleResolution/type-reference-from-secondary-location.js
@@ -12,6 +12,7 @@ Resolution:: {
"isExternalLibraryImport": true
},
"failedLookupLocations": [
+ "/root/src/types/lib.d.ts",
"/root/src/types/lib/package.json",
"/root/src/types/lib/index.d.ts",
"/root/src/node_modules/lib/package.json",
@@ -38,6 +39,7 @@ Resolution:: {
"isExternalLibraryImport": true
},
"failedLookupLocations": [
+ "/root/src/types/lib.d.ts",
"/root/src/types/lib/package.json",
"/root/src/types/lib/index.d.ts",
"/root/src/node_modules/lib/package.json",
@@ -68,6 +70,7 @@ Resolution:: {
"isExternalLibraryImport": true
},
"failedLookupLocations": [
+ "/root/src/types/lib.d.ts",
"/root/src/types/lib/package.json",
"/root/src/types/lib/index.d.ts",
"/root/src/node_modules/lib/package.json",
@@ -97,6 +100,7 @@ Resolution:: {
"isExternalLibraryImport": true
},
"failedLookupLocations": [
+ "/root/src/types/lib.d.ts",
"/root/src/types/lib/package.json",
"/root/src/types/lib/index.d.ts",
"/root/src/node_modules/lib/package.json",
@@ -130,6 +134,7 @@ Resolution:: {
"isExternalLibraryImport": true
},
"failedLookupLocations": [
+ "/root/src/types/lib.d.ts",
"/root/src/types/lib/package.json",
"/root/src/types/lib/index.d.ts",
"/root/src/node_modules/lib/package.json",
diff --git a/tests/baselines/reference/moduleResolution/type-reference-overrides-secondary-location.js b/tests/baselines/reference/moduleResolution/type-reference-overrides-secondary-location.js
index ef5afa43c6c12..e2cf663792a12 100644
--- a/tests/baselines/reference/moduleResolution/type-reference-overrides-secondary-location.js
+++ b/tests/baselines/reference/moduleResolution/type-reference-overrides-secondary-location.js
@@ -15,6 +15,7 @@ Resolution:: {
"isExternalLibraryImport": false
},
"failedLookupLocations": [
+ "/root/src/types/lib.d.ts",
"/root/src/types/lib/package.json"
]
}
diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.js b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.js
new file mode 100644
index 0000000000000..195879163615d
--- /dev/null
+++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.js
@@ -0,0 +1,15 @@
+//// [tests/cases/compiler/moduleResolutionAsTypeReferenceDirective.ts] ////
+
+//// [phaser.d.ts]
+export const a2: number;
+
+//// [package.json]
+{ "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" }
+
+
+//// [a.ts]
+import { a2 } from "phaser";
+
+//// [a.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.symbols b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.symbols
new file mode 100644
index 0000000000000..412bc680e0c31
--- /dev/null
+++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.symbols
@@ -0,0 +1,8 @@
+=== /a.ts ===
+import { a2 } from "phaser";
+>a2 : Symbol(a2, Decl(a.ts, 0, 8))
+
+=== /typings/phaser/types/phaser.d.ts ===
+export const a2: number;
+>a2 : Symbol(a2, Decl(phaser.d.ts, 0, 12))
+
diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.trace.json b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.trace.json
new file mode 100644
index 0000000000000..919021dc26b19
--- /dev/null
+++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.trace.json
@@ -0,0 +1,23 @@
+[
+ "======== Resolving module 'phaser' from '/a.ts'. ========",
+ "Module resolution kind is not specified, using 'Node10'.",
+ "Loading module 'phaser' from 'node_modules' folder, target file types: TypeScript, Declaration.",
+ "Directory '/node_modules' does not exist, skipping all lookups in it.",
+ "File '/typings/phaser.d.ts' does not exist.",
+ "Found 'package.json' at '/typings/phaser/package.json'.",
+ "'package.json' does not have a 'typesVersions' field.",
+ "'package.json' does not have a 'typings' field.",
+ "'package.json' has 'types' field 'types/phaser.d.ts' that references '/typings/phaser/types/phaser.d.ts'.",
+ "File '/typings/phaser/types/phaser.d.ts' exists - use it as a name resolution result.",
+ "Resolving real path for '/typings/phaser/types/phaser.d.ts', result '/typings/phaser/types/phaser.d.ts'.",
+ "======== Module name 'phaser' was successfully resolved to '/typings/phaser/types/phaser.d.ts' with Package ID 'phaser/types/phaser.d.ts@1.2.3'. ========",
+ "======== Resolving type reference directive 'phaser', containing file '/__inferred type names__.ts', root directory '/typings'. ========",
+ "Resolving with primary search path '/typings'.",
+ "File '/typings/phaser.d.ts' does not exist.",
+ "File '/typings/phaser/package.json' exists according to earlier cached lookups.",
+ "'package.json' does not have a 'typings' field.",
+ "'package.json' has 'types' field 'types/phaser.d.ts' that references '/typings/phaser/types/phaser.d.ts'.",
+ "File '/typings/phaser/types/phaser.d.ts' exists - use it as a name resolution result.",
+ "Resolving real path for '/typings/phaser/types/phaser.d.ts', result '/typings/phaser/types/phaser.d.ts'.",
+ "======== Type reference directive 'phaser' was successfully resolved to '/typings/phaser/types/phaser.d.ts' with Package ID 'phaser/types/phaser.d.ts@1.2.3', primary: true. ========"
+]
\ No newline at end of file
diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.types b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.types
new file mode 100644
index 0000000000000..b1b60c24349da
--- /dev/null
+++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirective.types
@@ -0,0 +1,8 @@
+=== /a.ts ===
+import { a2 } from "phaser";
+>a2 : number
+
+=== /typings/phaser/types/phaser.d.ts ===
+export const a2: number;
+>a2 : number
+
diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.js b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.js
new file mode 100644
index 0000000000000..413f263cba1f7
--- /dev/null
+++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.js
@@ -0,0 +1,17 @@
+//// [tests/cases/compiler/moduleResolutionAsTypeReferenceDirectiveAmbient.ts] ////
+
+//// [phaser.d.ts]
+declare module "phaser" {
+ export const a2: number;
+}
+
+//// [package.json]
+{ "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" }
+
+
+//// [a.ts]
+import { a2 } from "phaser";
+
+//// [a.js]
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.symbols b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.symbols
new file mode 100644
index 0000000000000..578a81a43c756
--- /dev/null
+++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.symbols
@@ -0,0 +1,12 @@
+=== /a.ts ===
+import { a2 } from "phaser";
+>a2 : Symbol(a2, Decl(a.ts, 0, 8))
+
+=== /typings/phaser/types/phaser.d.ts ===
+declare module "phaser" {
+>"phaser" : Symbol("phaser", Decl(phaser.d.ts, 0, 0))
+
+ export const a2: number;
+>a2 : Symbol(a2, Decl(phaser.d.ts, 1, 16))
+}
+
diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.trace.json b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.trace.json
new file mode 100644
index 0000000000000..919021dc26b19
--- /dev/null
+++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.trace.json
@@ -0,0 +1,23 @@
+[
+ "======== Resolving module 'phaser' from '/a.ts'. ========",
+ "Module resolution kind is not specified, using 'Node10'.",
+ "Loading module 'phaser' from 'node_modules' folder, target file types: TypeScript, Declaration.",
+ "Directory '/node_modules' does not exist, skipping all lookups in it.",
+ "File '/typings/phaser.d.ts' does not exist.",
+ "Found 'package.json' at '/typings/phaser/package.json'.",
+ "'package.json' does not have a 'typesVersions' field.",
+ "'package.json' does not have a 'typings' field.",
+ "'package.json' has 'types' field 'types/phaser.d.ts' that references '/typings/phaser/types/phaser.d.ts'.",
+ "File '/typings/phaser/types/phaser.d.ts' exists - use it as a name resolution result.",
+ "Resolving real path for '/typings/phaser/types/phaser.d.ts', result '/typings/phaser/types/phaser.d.ts'.",
+ "======== Module name 'phaser' was successfully resolved to '/typings/phaser/types/phaser.d.ts' with Package ID 'phaser/types/phaser.d.ts@1.2.3'. ========",
+ "======== Resolving type reference directive 'phaser', containing file '/__inferred type names__.ts', root directory '/typings'. ========",
+ "Resolving with primary search path '/typings'.",
+ "File '/typings/phaser.d.ts' does not exist.",
+ "File '/typings/phaser/package.json' exists according to earlier cached lookups.",
+ "'package.json' does not have a 'typings' field.",
+ "'package.json' has 'types' field 'types/phaser.d.ts' that references '/typings/phaser/types/phaser.d.ts'.",
+ "File '/typings/phaser/types/phaser.d.ts' exists - use it as a name resolution result.",
+ "Resolving real path for '/typings/phaser/types/phaser.d.ts', result '/typings/phaser/types/phaser.d.ts'.",
+ "======== Type reference directive 'phaser' was successfully resolved to '/typings/phaser/types/phaser.d.ts' with Package ID 'phaser/types/phaser.d.ts@1.2.3', primary: true. ========"
+]
\ No newline at end of file
diff --git a/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.types b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.types
new file mode 100644
index 0000000000000..6bc892a4e4145
--- /dev/null
+++ b/tests/baselines/reference/moduleResolutionAsTypeReferenceDirectiveAmbient.types
@@ -0,0 +1,12 @@
+=== /a.ts ===
+import { a2 } from "phaser";
+>a2 : number
+
+=== /typings/phaser/types/phaser.d.ts ===
+declare module "phaser" {
+>"phaser" : typeof import("phaser")
+
+ export const a2: number;
+>a2 : number
+}
+
diff --git a/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json b/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json
index a48f4ea42f8ee..a7ec056bc1dc5 100644
--- a/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json
+++ b/tests/baselines/reference/moduleResolutionWithSymlinks_preserveSymlinks.trace.json
@@ -1,6 +1,8 @@
[
- "======== Resolving type reference directive 'linked', containing file '/app/app.ts', root directory not set. ========",
- "Root directory cannot be determined, skipping primary search paths.",
+ "======== Resolving type reference directive 'linked', containing file '/app/app.ts', root directory 'node_modules/@types,/node_modules/@types'. ========",
+ "Resolving with primary search path 'node_modules/@types, /node_modules/@types'.",
+ "Directory 'node_modules/@types' does not exist, skipping all lookups in it.",
+ "Directory '/node_modules/@types' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/app'.",
"File '/app/node_modules/linked/package.json' does not exist.",
"File '/app/node_modules/linked.d.ts' does not exist.",
diff --git a/tests/baselines/reference/nodeModulesAtTypesPriority.trace.json b/tests/baselines/reference/nodeModulesAtTypesPriority.trace.json
index 56a98461a3ead..40c90dcc03693 100644
--- a/tests/baselines/reference/nodeModulesAtTypesPriority.trace.json
+++ b/tests/baselines/reference/nodeModulesAtTypesPriority.trace.json
@@ -55,14 +55,16 @@
"File '/packages/a/node_modules/redux/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/packages/a/node_modules/redux/index.d.ts', result '/packages/a/node_modules/redux/index.d.ts'.",
"======== Module name 'redux' was successfully resolved to '/packages/a/node_modules/redux/index.d.ts'. ========",
- "======== Resolving type reference directive 'react', containing file '__inferred type names__.ts', root directory '/node_modules/@types'. ========",
- "Resolving with primary search path '/node_modules/@types'.",
+ "======== Resolving type reference directive 'react', containing file '__inferred type names__.ts', root directory 'node_modules/@types,/node_modules/@types'. ========",
+ "Resolving with primary search path 'node_modules/@types, /node_modules/@types'.",
+ "Directory 'node_modules/@types' does not exist, skipping all lookups in it.",
"File '/node_modules/@types/react/package.json' does not exist according to earlier cached lookups.",
"File '/node_modules/@types/react/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/react/index.d.ts', result '/node_modules/@types/react/index.d.ts'.",
"======== Type reference directive 'react' was successfully resolved to '/node_modules/@types/react/index.d.ts', primary: true. ========",
- "======== Resolving type reference directive 'redux', containing file '__inferred type names__.ts', root directory '/node_modules/@types'. ========",
- "Resolving with primary search path '/node_modules/@types'.",
+ "======== Resolving type reference directive 'redux', containing file '__inferred type names__.ts', root directory 'node_modules/@types,/node_modules/@types'. ========",
+ "Resolving with primary search path 'node_modules/@types, /node_modules/@types'.",
+ "Directory 'node_modules/@types' does not exist, skipping all lookups in it.",
"File '/node_modules/@types/redux/package.json' does not exist according to earlier cached lookups.",
"File '/node_modules/@types/redux/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/redux/index.d.ts', result '/node_modules/@types/redux/index.d.ts'.",
diff --git a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).trace.json b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).trace.json
index 008a09f076eb4..c829c3aaa7b1c 100644
--- a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).trace.json
+++ b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=bundler).trace.json
@@ -96,8 +96,9 @@
"File '/node_modules/@types/bar/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/node_modules/bar/index.mjs', result '/node_modules/bar/index.mjs'.",
"======== Module name 'bar' was successfully resolved to '/node_modules/bar/index.mjs' with Package ID 'bar/index.mjs@1.0.0'. ========",
- "======== Resolving type reference directive 'bar', containing file '__inferred type names__.ts', root directory '/node_modules/@types'. ========",
- "Resolving with primary search path '/node_modules/@types'.",
+ "======== Resolving type reference directive 'bar', containing file '__inferred type names__.ts', root directory 'node_modules/@types,/node_modules/@types'. ========",
+ "Resolving with primary search path 'node_modules/@types, /node_modules/@types'.",
+ "Directory 'node_modules/@types' does not exist, skipping all lookups in it.",
"File '/node_modules/@types/bar/package.json' exists according to earlier cached lookups.",
"'package.json' does not have a 'typings' field.",
"'package.json' has 'types' field 'index.d.ts' that references '/node_modules/@types/bar/index.d.ts'.",
diff --git a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).trace.json b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).trace.json
index 5b9abf1482a53..43f9a28d1307b 100644
--- a/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).trace.json
+++ b/tests/baselines/reference/resolvesWithoutExportsDiagnostic1(moduleresolution=node16).trace.json
@@ -87,8 +87,9 @@
"File '/node_modules/@types/bar/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/node_modules/bar/index.mjs', result '/node_modules/bar/index.mjs'.",
"======== Module name 'bar' was successfully resolved to '/node_modules/bar/index.mjs' with Package ID 'bar/index.mjs@1.0.0'. ========",
- "======== Resolving type reference directive 'bar', containing file '__inferred type names__.ts', root directory '/node_modules/@types'. ========",
- "Resolving with primary search path '/node_modules/@types'.",
+ "======== Resolving type reference directive 'bar', containing file '__inferred type names__.ts', root directory 'node_modules/@types,/node_modules/@types'. ========",
+ "Resolving with primary search path 'node_modules/@types, /node_modules/@types'.",
+ "Directory 'node_modules/@types' does not exist, skipping all lookups in it.",
"File '/node_modules/@types/bar/package.json' exists according to earlier cached lookups.",
"'package.json' does not have a 'typings' field.",
"'package.json' has 'types' field 'index.d.ts' that references '/node_modules/@types/bar/index.d.ts'.",
diff --git a/tests/baselines/reference/reuseProgramStructure/config-path-changes.js b/tests/baselines/reference/reuseProgramStructure/config-path-changes.js
index 42f692e5bba13..1dd028d4ccb90 100644
--- a/tests/baselines/reference/reuseProgramStructure/config-path-changes.js
+++ b/tests/baselines/reference/reuseProgramStructure/config-path-changes.js
@@ -27,6 +27,10 @@ typerefs: {
"failedLookupLocations": [
"/a/b/node_modules/@types/typerefs/package.json",
"/a/b/node_modules/@types/typerefs/index.d.ts",
+ "/a/node_modules/@types/typerefs/package.json",
+ "/a/node_modules/@types/typerefs/index.d.ts",
+ "/node_modules/@types/typerefs/package.json",
+ "/node_modules/@types/typerefs/index.d.ts",
"node_modules/typerefs/package.json",
"node_modules/typerefs.d.ts",
"node_modules/typerefs/index.d.ts",
@@ -73,6 +77,10 @@ typerefs: {
"failedLookupLocations": [
"/a/c/node_modules/@types/typerefs/package.json",
"/a/c/node_modules/@types/typerefs/index.d.ts",
+ "/a/node_modules/@types/typerefs/package.json",
+ "/a/node_modules/@types/typerefs/index.d.ts",
+ "/node_modules/@types/typerefs/package.json",
+ "/node_modules/@types/typerefs/index.d.ts",
"node_modules/typerefs/package.json",
"node_modules/typerefs.d.ts",
"node_modules/typerefs/index.d.ts",
diff --git a/tests/baselines/reference/reuseProgramStructure/resolved-type-directives-cache-follows-type-directives.js b/tests/baselines/reference/reuseProgramStructure/resolved-type-directives-cache-follows-type-directives.js
index 4f4075a6bdb92..4c0cd65d093e4 100644
--- a/tests/baselines/reference/reuseProgramStructure/resolved-type-directives-cache-follows-type-directives.js
+++ b/tests/baselines/reference/reuseProgramStructure/resolved-type-directives-cache-follows-type-directives.js
@@ -19,6 +19,7 @@ typedefs: {
"isExternalLibraryImport": false
},
"failedLookupLocations": [
+ "/types/typedefs.d.ts",
"/types/typedefs/package.json"
]
}
@@ -50,6 +51,7 @@ typedefs: {
"isExternalLibraryImport": false
},
"failedLookupLocations": [
+ "/types/typedefs.d.ts",
"/types/typedefs/package.json"
]
}
@@ -97,11 +99,13 @@ typedefs: {
"isExternalLibraryImport": false
},
"failedLookupLocations": [
+ "/types/typedefs.d.ts",
"/types/typedefs/package.json"
]
}
typedefs2: {
"failedLookupLocations": [
+ "/types/typedefs2.d.ts",
"/types/typedefs2/package.json",
"/types/typedefs2/index.d.ts",
"/node_modules/typedefs2/package.json",
diff --git a/tests/baselines/reference/tsbuild/moduleResolution/impliedNodeFormat-differs-between-projects-for-shared-file.js b/tests/baselines/reference/tsbuild/moduleResolution/impliedNodeFormat-differs-between-projects-for-shared-file.js
index b7a051721de1d..d017ad49e0390 100644
--- a/tests/baselines/reference/tsbuild/moduleResolution/impliedNodeFormat-differs-between-projects-for-shared-file.js
+++ b/tests/baselines/reference/tsbuild/moduleResolution/impliedNodeFormat-differs-between-projects-for-shared-file.js
@@ -62,8 +62,9 @@ Output::
[[90m12:00:24 AM[0m] Building project '/src/projects/a/tsconfig.json'...
-======== Resolving type reference directive 'pg', containing file '/src/projects/a/__inferred type names__.ts', root directory '/src/projects/node_modules/@types'. ========
-Resolving with primary search path '/src/projects/node_modules/@types'.
+======== Resolving type reference directive 'pg', containing file '/src/projects/a/__inferred type names__.ts', root directory '/src/projects/a/node_modules/@types,/src/projects/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ========
+Resolving with primary search path '/src/projects/a/node_modules/@types, /src/projects/node_modules/@types, /src/node_modules/@types, /node_modules/@types'.
+Directory '/src/projects/a/node_modules/@types' does not exist, skipping all lookups in it.
Found 'package.json' at '/src/projects/node_modules/@types/pg/package.json'.
'package.json' does not have a 'typesVersions' field.
'package.json' does not have a 'typings' field.
@@ -98,8 +99,9 @@ File '/src/projects/node_modules/@types/pg/index.d.ts' exists - use it as a name
Resolving real path for '/src/projects/node_modules/@types/pg/index.d.ts', result '/src/projects/node_modules/@types/pg/index.d.ts'.
======== Module name 'pg' was successfully resolved to '/src/projects/node_modules/@types/pg/index.d.ts'. ========
File '/src/projects/node_modules/@types/pg/package.json' exists according to earlier cached lookups.
-======== Resolving type reference directive 'pg', containing file '/src/projects/b/__inferred type names__.ts', root directory '/src/projects/node_modules/@types'. ========
-Resolving with primary search path '/src/projects/node_modules/@types'.
+======== Resolving type reference directive 'pg', containing file '/src/projects/b/__inferred type names__.ts', root directory '/src/projects/b/node_modules/@types,/src/projects/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ========
+Resolving with primary search path '/src/projects/b/node_modules/@types, /src/projects/node_modules/@types, /src/node_modules/@types, /node_modules/@types'.
+Directory '/src/projects/b/node_modules/@types' does not exist, skipping all lookups in it.
File '/src/projects/node_modules/@types/pg/package.json' exists according to earlier cached lookups.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'index.d.ts' that references '/src/projects/node_modules/@types/pg/index.d.ts'.
diff --git a/tests/baselines/reference/tsbuild/moduleResolution/type-reference-resolution-uses-correct-options-for-different-resolution-options-referenced-project.js b/tests/baselines/reference/tsbuild/moduleResolution/type-reference-resolution-uses-correct-options-for-different-resolution-options-referenced-project.js
index e96879a4e3fc7..d720196713688 100644
--- a/tests/baselines/reference/tsbuild/moduleResolution/type-reference-resolution-uses-correct-options-for-different-resolution-options-referenced-project.js
+++ b/tests/baselines/reference/tsbuild/moduleResolution/type-reference-resolution-uses-correct-options-for-different-resolution-options-referenced-project.js
@@ -46,6 +46,7 @@ Output::
======== Resolving type reference directive 'sometype', containing file '/src/packages/__inferred type names__.ts', root directory '/src/packages/typeroot1'. ========
Resolving with primary search path '/src/packages/typeroot1'.
+File '/src/packages/typeroot1/sometype.d.ts' does not exist.
File '/src/packages/typeroot1/sometype/package.json' does not exist.
File '/src/packages/typeroot1/sometype/index.d.ts' exists - use it as a name resolution result.
Resolving real path for '/src/packages/typeroot1/sometype/index.d.ts', result '/src/packages/typeroot1/sometype/index.d.ts'.
@@ -56,6 +57,7 @@ Resolving real path for '/src/packages/typeroot1/sometype/index.d.ts', result '/
======== Resolving type reference directive 'sometype', containing file '/src/packages/__inferred type names__.ts', root directory '/src/packages/typeroot2'. ========
Resolving with primary search path '/src/packages/typeroot2'.
+File '/src/packages/typeroot2/sometype.d.ts' does not exist.
File '/src/packages/typeroot2/sometype/package.json' does not exist.
File '/src/packages/typeroot2/sometype/index.d.ts' exists - use it as a name resolution result.
Resolving real path for '/src/packages/typeroot2/sometype/index.d.ts', result '/src/packages/typeroot2/sometype/index.d.ts'.
diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js
index 137a35ebe3860..eb5858678ceac 100644
--- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js
+++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js
@@ -68,8 +68,8 @@ Exiting conditional exports.
Resolving real path for '/Users/name/projects/web/node_modules/@types/yargs/index.d.ts', result '/Users/name/projects/web/node_modules/@types/yargs/index.d.ts'.
======== Module name 'yargs' was successfully resolved to '/Users/name/projects/web/node_modules/@types/yargs/index.d.ts' with Package ID 'yargs/index.d.ts@17.0.12'. ========
File '/Users/name/projects/web/node_modules/@types/yargs/package.json' exists according to earlier cached lookups.
-======== Resolving type reference directive 'yargs', containing file '/Users/name/projects/web/__inferred type names__.ts', root directory '/Users/name/projects/web/node_modules/@types'. ========
-Resolving with primary search path '/Users/name/projects/web/node_modules/@types'.
+======== Resolving type reference directive 'yargs', containing file '/Users/name/projects/web/__inferred type names__.ts', root directory '/Users/name/projects/web/node_modules/@types,/Users/name/projects/node_modules/@types,/Users/name/node_modules/@types,/Users/node_modules/@types,/node_modules/@types'. ========
+Resolving with primary search path '/Users/name/projects/web/node_modules/@types, /Users/name/projects/node_modules/@types, /Users/name/node_modules/@types, /Users/node_modules/@types, /node_modules/@types'.
File '/Users/name/projects/web/node_modules/@types/yargs/package.json' exists according to earlier cached lookups.
'package.json' does not have a 'typesVersions' field.
'package.json' does not have a 'typings' field.
diff --git a/tests/baselines/reference/tscWatch/moduleResolution/type-reference-resolutions-reuse.js b/tests/baselines/reference/tscWatch/moduleResolution/type-reference-resolutions-reuse.js
index 827b58d73b992..f034a27570489 100644
--- a/tests/baselines/reference/tscWatch/moduleResolution/type-reference-resolutions-reuse.js
+++ b/tests/baselines/reference/tscWatch/moduleResolution/type-reference-resolutions-reuse.js
@@ -71,8 +71,12 @@ File '/user/username/projects/package.json' does not exist according to earlier
File '/user/username/package.json' does not exist according to earlier cached lookups.
File '/user/package.json' does not exist according to earlier cached lookups.
File '/package.json' does not exist according to earlier cached lookups.
-======== Resolving type reference directive 'pkg', containing file '/user/username/projects/myproject/index.ts', root directory '/user/username/projects/myproject/node_modules/@types'. ========
-Resolving with primary search path '/user/username/projects/myproject/node_modules/@types'.
+======== Resolving type reference directive 'pkg', containing file '/user/username/projects/myproject/index.ts', root directory '/user/username/projects/myproject/node_modules/@types,/user/username/projects/node_modules/@types,/user/username/node_modules/@types,/user/node_modules/@types,/node_modules/@types'. ========
+Resolving with primary search path '/user/username/projects/myproject/node_modules/@types, /user/username/projects/node_modules/@types, /user/username/node_modules/@types, /user/node_modules/@types, /node_modules/@types'.
+Directory '/user/username/projects/node_modules/@types' does not exist, skipping all lookups in it.
+Directory '/user/username/node_modules/@types' does not exist, skipping all lookups in it.
+Directory '/user/node_modules/@types' does not exist, skipping all lookups in it.
+Directory '/node_modules/@types' does not exist, skipping all lookups in it.
Looking up in 'node_modules' folder, initial location '/user/username/projects/myproject'.
Found 'package.json' at '/user/username/projects/myproject/node_modules/pkg/package.json'.
Entering conditional exports.
@@ -84,8 +88,12 @@ Resolved under condition 'import'.
Exiting conditional exports.
Resolving real path for '/user/username/projects/myproject/node_modules/pkg/import.d.ts', result '/user/username/projects/myproject/node_modules/pkg/import.d.ts'.
======== Type reference directive 'pkg' was successfully resolved to '/user/username/projects/myproject/node_modules/pkg/import.d.ts' with Package ID 'pkg/import.d.ts@0.0.1', primary: false. ========
-======== Resolving type reference directive 'pkg1', containing file '/user/username/projects/myproject/index.ts', root directory '/user/username/projects/myproject/node_modules/@types'. ========
-Resolving with primary search path '/user/username/projects/myproject/node_modules/@types'.
+======== Resolving type reference directive 'pkg1', containing file '/user/username/projects/myproject/index.ts', root directory '/user/username/projects/myproject/node_modules/@types,/user/username/projects/node_modules/@types,/user/username/node_modules/@types,/user/node_modules/@types,/node_modules/@types'. ========
+Resolving with primary search path '/user/username/projects/myproject/node_modules/@types, /user/username/projects/node_modules/@types, /user/username/node_modules/@types, /user/node_modules/@types, /node_modules/@types'.
+Directory '/user/username/projects/node_modules/@types' does not exist, skipping all lookups in it.
+Directory '/user/username/node_modules/@types' does not exist, skipping all lookups in it.
+Directory '/user/node_modules/@types' does not exist, skipping all lookups in it.
+Directory '/node_modules/@types' does not exist, skipping all lookups in it.
Looking up in 'node_modules' folder, initial location '/user/username/projects/myproject'.
Found 'package.json' at '/user/username/projects/myproject/node_modules/pkg1/package.json'.
Entering conditional exports.
@@ -103,8 +111,8 @@ Directory '/user/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Type reference directive 'pkg1' was not resolved. ========
File '/user/username/projects/myproject/node_modules/pkg/package.json' exists according to earlier cached lookups.
-======== Resolving type reference directive 'pkg2', containing file '/user/username/projects/myproject/__inferred type names__.ts', root directory '/user/username/projects/myproject/node_modules/@types'. ========
-Resolving with primary search path '/user/username/projects/myproject/node_modules/@types'.
+======== Resolving type reference directive 'pkg2', containing file '/user/username/projects/myproject/__inferred type names__.ts', root directory '/user/username/projects/myproject/node_modules/@types,/user/username/projects/node_modules/@types,/user/username/node_modules/@types,/user/node_modules/@types,/node_modules/@types'. ========
+Resolving with primary search path '/user/username/projects/myproject/node_modules/@types, /user/username/projects/node_modules/@types, /user/username/node_modules/@types, /user/node_modules/@types, /node_modules/@types'.
File '/user/username/projects/myproject/node_modules/@types/pkg2/package.json' does not exist.
File '/user/username/projects/myproject/node_modules/@types/pkg2/index.d.ts' exists - use it as a name resolution result.
Resolving real path for '/user/username/projects/myproject/node_modules/@types/pkg2/index.d.ts', result '/user/username/projects/myproject/node_modules/@types/pkg2/index.d.ts'.
@@ -253,8 +261,12 @@ File '/user/username/projects/package.json' does not exist according to earlier
File '/user/username/package.json' does not exist according to earlier cached lookups.
File '/user/package.json' does not exist according to earlier cached lookups.
File '/package.json' does not exist according to earlier cached lookups.
-======== Resolving type reference directive 'pkg', containing file '/user/username/projects/myproject/a.ts', root directory '/user/username/projects/myproject/node_modules/@types'. ========
-Resolving with primary search path '/user/username/projects/myproject/node_modules/@types'.
+======== Resolving type reference directive 'pkg', containing file '/user/username/projects/myproject/a.ts', root directory '/user/username/projects/myproject/node_modules/@types,/user/username/projects/node_modules/@types,/user/username/node_modules/@types,/user/node_modules/@types,/node_modules/@types'. ========
+Resolving with primary search path '/user/username/projects/myproject/node_modules/@types, /user/username/projects/node_modules/@types, /user/username/node_modules/@types, /user/node_modules/@types, /node_modules/@types'.
+Directory '/user/username/projects/node_modules/@types' does not exist, skipping all lookups in it.
+Directory '/user/username/node_modules/@types' does not exist, skipping all lookups in it.
+Directory '/user/node_modules/@types' does not exist, skipping all lookups in it.
+Directory '/node_modules/@types' does not exist, skipping all lookups in it.
Looking up in 'node_modules' folder, initial location '/user/username/projects/myproject'.
File '/user/username/projects/myproject/node_modules/pkg/package.json' exists according to earlier cached lookups.
Entering conditional exports.
diff --git a/tests/baselines/reference/tscWatch/programUpdates/types-should-load-from-config-file-path-if-config-exists.js b/tests/baselines/reference/tscWatch/programUpdates/types-should-load-from-config-file-path-if-config-exists.js
index 05d9c456981c7..f936e1d84722a 100644
--- a/tests/baselines/reference/tscWatch/programUpdates/types-should-load-from-config-file-path-if-config-exists.js
+++ b/tests/baselines/reference/tscWatch/programUpdates/types-should-load-from-config-file-path-if-config-exists.js
@@ -3,7 +3,7 @@ Input::
let x = 1
//// [/a/b/tsconfig.json]
-{"compilerOptions":{"types":["node"],"typeRoots":[]}}
+{"compilerOptions":{"types":["node"]}}
//// [/a/b/node_modules/@types/node/index.d.ts]
declare var process: any
@@ -32,7 +32,7 @@ Output::
Program root files: ["/a/b/app.ts"]
-Program options: {"types":["node"],"typeRoots":[],"watch":true,"project":"/a/b/tsconfig.json","configFilePath":"/a/b/tsconfig.json"}
+Program options: {"types":["node"],"watch":true,"project":"/a/b/tsconfig.json","configFilePath":"/a/b/tsconfig.json"}
Program structureReused: Not
Program files::
/a/lib/lib.d.ts
diff --git a/tests/baselines/reference/tscWatch/programUpdates/types-should-not-load-from-config-file-path-if-config-exists-but-does-not-specifies-typeRoots.js b/tests/baselines/reference/tscWatch/programUpdates/types-should-not-load-from-config-file-path-if-config-exists-but-does-not-specifies-typeRoots.js
new file mode 100644
index 0000000000000..fd38ef9c8cc28
--- /dev/null
+++ b/tests/baselines/reference/tscWatch/programUpdates/types-should-not-load-from-config-file-path-if-config-exists-but-does-not-specifies-typeRoots.js
@@ -0,0 +1,75 @@
+Input::
+//// [/a/b/app.ts]
+let x = 1
+
+//// [/a/b/tsconfig.json]
+{"compilerOptions":{"types":["node"],"typeRoots":[]}}
+
+//// [/a/b/node_modules/@types/node/index.d.ts]
+declare var process: any
+
+//// [/a/lib/lib.d.ts]
+///
+interface Boolean {}
+interface Function {}
+interface CallableFunction {}
+interface NewableFunction {}
+interface IArguments {}
+interface Number { toExponential: any; }
+interface Object {}
+interface RegExp {}
+interface String { charAt: any; }
+interface Array { length: number; [n: number]: T; }
+
+
+/a/lib/tsc.js -w -p /a/b/tsconfig.json
+Output::
+>> Screen clear
+[[90m12:00:25 AM[0m] Starting compilation in watch mode...
+
+[91merror[0m[90m TS2688: [0mCannot find type definition file for 'node'.
+ The file is in the program because:
+ Entry point of type library 'node' specified in compilerOptions
+
+ [96m../b/tsconfig.json[0m:[93m1[0m:[93m30[0m
+ [7m1[0m {"compilerOptions":{"types":["node"],"typeRoots":[]}}
+ [7m [0m [96m ~~~~~~[0m
+ File is entry point of type library specified here.
+
+[[90m12:00:28 AM[0m] Found 1 error. Watching for file changes.
+
+
+
+Program root files: ["/a/b/app.ts"]
+Program options: {"types":["node"],"typeRoots":[],"watch":true,"project":"/a/b/tsconfig.json","configFilePath":"/a/b/tsconfig.json"}
+Program structureReused: Not
+Program files::
+/a/lib/lib.d.ts
+/a/b/app.ts
+
+No cached semantic diagnostics in the builder::
+
+Shape signatures in builder refreshed for::
+/a/lib/lib.d.ts (used version)
+/a/b/app.ts (used version)
+
+PolledWatches::
+
+FsWatches::
+/a/b/tsconfig.json:
+ {}
+/a/b/app.ts:
+ {}
+/a/lib/lib.d.ts:
+ {}
+
+FsWatchesRecursive::
+/a/b:
+ {}
+
+exitCode:: ExitStatus.undefined
+
+//// [/a/b/app.js]
+var x = 1;
+
+
diff --git a/tests/baselines/reference/tscWatch/resolutionCache/reusing-type-ref-resolution.js b/tests/baselines/reference/tscWatch/resolutionCache/reusing-type-ref-resolution.js
index f05f093e47998..a709173d321f3 100644
--- a/tests/baselines/reference/tscWatch/resolutionCache/reusing-type-ref-resolution.js
+++ b/tests/baselines/reference/tscWatch/resolutionCache/reusing-type-ref-resolution.js
@@ -74,16 +74,22 @@ Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name 'pkg1' was not resolved. ========
FileWatcher:: Added:: WatchInfo: /src/project/node_modules/pkg0/index.d.ts 250 undefined Source file
FileWatcher:: Added:: WatchInfo: /src/project/fileWithTypeRefs.ts 250 undefined Source file
-======== Resolving type reference directive 'pkg2', containing file '/src/project/fileWithTypeRefs.ts', root directory not set. ========
-Root directory cannot be determined, skipping primary search paths.
+======== Resolving type reference directive 'pkg2', containing file '/src/project/fileWithTypeRefs.ts', root directory '/src/project/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ========
+Resolving with primary search path '/src/project/node_modules/@types, /src/node_modules/@types, /node_modules/@types'.
+Directory '/src/project/node_modules/@types' does not exist, skipping all lookups in it.
+Directory '/src/node_modules/@types' does not exist, skipping all lookups in it.
+Directory '/node_modules/@types' does not exist, skipping all lookups in it.
Looking up in 'node_modules' folder, initial location '/src/project'.
File '/src/project/node_modules/pkg2/package.json' does not exist.
File '/src/project/node_modules/pkg2.d.ts' does not exist.
File '/src/project/node_modules/pkg2/index.d.ts' exists - use it as a name resolution result.
Resolving real path for '/src/project/node_modules/pkg2/index.d.ts', result '/src/project/node_modules/pkg2/index.d.ts'.
======== Type reference directive 'pkg2' was successfully resolved to '/src/project/node_modules/pkg2/index.d.ts', primary: false. ========
-======== Resolving type reference directive 'pkg3', containing file '/src/project/fileWithTypeRefs.ts', root directory not set. ========
-Root directory cannot be determined, skipping primary search paths.
+======== Resolving type reference directive 'pkg3', containing file '/src/project/fileWithTypeRefs.ts', root directory '/src/project/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ========
+Resolving with primary search path '/src/project/node_modules/@types, /src/node_modules/@types, /node_modules/@types'.
+Directory '/src/project/node_modules/@types' does not exist, skipping all lookups in it.
+Directory '/src/node_modules/@types' does not exist, skipping all lookups in it.
+Directory '/node_modules/@types' does not exist, skipping all lookups in it.
Looking up in 'node_modules' folder, initial location '/src/project'.
File '/src/project/node_modules/pkg3.d.ts' does not exist.
Directory '/src/project/node_modules/@types' does not exist, skipping all lookups in it.
@@ -586,8 +592,11 @@ CreatingProgramWith::
Reusing resolution of module 'pkg0' from '/src/project/fileWithImports.ts' of old program, it was successfully resolved to '/src/project/node_modules/pkg0/index.d.ts'.
Reusing resolution of module 'pkg1' from '/src/project/fileWithImports.ts' of old program, it was successfully resolved to '/src/project/node_modules/pkg1/index.d.ts'.
Reusing resolution of type reference directive 'pkg2' from '/src/project/fileWithTypeRefs.ts' of old program, it was successfully resolved to '/src/project/node_modules/pkg2/index.d.ts'.
-======== Resolving type reference directive 'pkg3', containing file '/src/project/fileWithTypeRefs.ts', root directory not set. ========
-Root directory cannot be determined, skipping primary search paths.
+======== Resolving type reference directive 'pkg3', containing file '/src/project/fileWithTypeRefs.ts', root directory '/src/project/node_modules/@types,/src/node_modules/@types,/node_modules/@types'. ========
+Resolving with primary search path '/src/project/node_modules/@types, /src/node_modules/@types, /node_modules/@types'.
+Directory '/src/project/node_modules/@types' does not exist, skipping all lookups in it.
+Directory '/src/node_modules/@types' does not exist, skipping all lookups in it.
+Directory '/node_modules/@types' does not exist, skipping all lookups in it.
Looking up in 'node_modules' folder, initial location '/src/project'.
File '/src/project/node_modules/pkg3/package.json' does not exist.
File '/src/project/node_modules/pkg3.d.ts' does not exist.
diff --git a/tests/baselines/reference/tsserver/cachingFileSystemInformation/watchDirectories-for-config-file-with-case-insensitive-file-system.js b/tests/baselines/reference/tsserver/cachingFileSystemInformation/watchDirectories-for-config-file-with-case-insensitive-file-system.js
index 802443c20a962..abcefca228573 100644
--- a/tests/baselines/reference/tsserver/cachingFileSystemInformation/watchDirectories-for-config-file-with-case-insensitive-file-system.js
+++ b/tests/baselines/reference/tsserver/cachingFileSystemInformation/watchDirectories-for-config-file-with-case-insensitive-file-system.js
@@ -77,11 +77,9 @@ Info 11 [00:00:44.000] DirectoryWatcher:: Added:: WatchInfo: /Users/someuser/w
Info 12 [00:00:45.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /Users/someuser/work/applications/frontend/types 1 undefined Project: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Failed Lookup Locations
Info 13 [00:00:46.000] DirectoryWatcher:: Added:: WatchInfo: /Users/someuser/work/applications/frontend/node_modules 1 undefined Project: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Failed Lookup Locations
Info 14 [00:00:47.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /Users/someuser/work/applications/frontend/node_modules 1 undefined Project: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Failed Lookup Locations
-Info 15 [00:00:48.000] DirectoryWatcher:: Added:: WatchInfo: /Users/someuser/work/applications/node_modules 1 undefined Project: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Failed Lookup Locations
-Info 16 [00:00:49.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /Users/someuser/work/applications/node_modules 1 undefined Project: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Failed Lookup Locations
-Info 17 [00:00:50.000] Finishing updateGraphWorker: Project: /Users/someuser/work/applications/frontend/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
-Info 18 [00:00:51.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
-Info 19 [00:00:52.000] Files (3)
+Info 15 [00:00:48.000] Finishing updateGraphWorker: Project: /Users/someuser/work/applications/frontend/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
+Info 16 [00:00:49.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
+Info 17 [00:00:50.000] Files (3)
/a/lib/lib.es2016.full.d.ts
/Users/someuser/work/applications/frontend/src/app/redux/configureStore.ts
/Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts
@@ -94,18 +92,18 @@ Info 19 [00:00:52.000] Files (3)
src/app/utils/Analytic.ts
Matched by include pattern 'src/**/*' in 'tsconfig.json'
-Info 20 [00:00:53.000] -----------------------------------------------
-Info 21 [00:00:54.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
-Info 21 [00:00:55.000] Files (3)
-
-Info 21 [00:00:56.000] -----------------------------------------------
-Info 21 [00:00:57.000] Open files:
-Info 21 [00:00:58.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts ProjectRootPath: undefined
-Info 21 [00:00:59.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
-Info 21 [00:01:02.000] DirectoryWatcher:: Triggered with /users/someuser/work/applications/frontend/src/app/utils/Cookie.ts :: WatchInfo: /users/someuser/work/applications/frontend/src 1 undefined Config: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Wild card directory
-Info 22 [00:01:03.000] Scheduled: /Users/someuser/work/applications/frontend/tsconfig.json
-Info 23 [00:01:04.000] Scheduled: *ensureProjectForOpenFiles*
-Info 24 [00:01:05.000] Elapsed:: *ms DirectoryWatcher:: Triggered with /users/someuser/work/applications/frontend/src/app/utils/Cookie.ts :: WatchInfo: /users/someuser/work/applications/frontend/src 1 undefined Config: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Wild card directory
+Info 18 [00:00:51.000] -----------------------------------------------
+Info 19 [00:00:52.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
+Info 19 [00:00:53.000] Files (3)
+
+Info 19 [00:00:54.000] -----------------------------------------------
+Info 19 [00:00:55.000] Open files:
+Info 19 [00:00:56.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts ProjectRootPath: undefined
+Info 19 [00:00:57.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 19 [00:01:00.000] DirectoryWatcher:: Triggered with /users/someuser/work/applications/frontend/src/app/utils/Cookie.ts :: WatchInfo: /users/someuser/work/applications/frontend/src 1 undefined Config: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Wild card directory
+Info 20 [00:01:01.000] Scheduled: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 21 [00:01:02.000] Scheduled: *ensureProjectForOpenFiles*
+Info 22 [00:01:03.000] Elapsed:: *ms DirectoryWatcher:: Triggered with /users/someuser/work/applications/frontend/src/app/utils/Cookie.ts :: WatchInfo: /users/someuser/work/applications/frontend/src 1 undefined Config: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Wild card directory
Before running timeout callbacks
//// [/Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts]
export class Cookie { }
@@ -116,8 +114,6 @@ PolledWatches::
{"pollingInterval":500}
/users/someuser/work/applications/frontend/node_modules:
{"pollingInterval":500}
-/users/someuser/work/applications/node_modules:
- {"pollingInterval":500}
FsWatches::
/users/someuser/work/applications/frontend/tsconfig.json:
@@ -131,12 +127,12 @@ FsWatchesRecursive::
/users/someuser/work/applications/frontend/src:
{}
-Info 25 [00:01:06.000] Running: /Users/someuser/work/applications/frontend/tsconfig.json
-Info 26 [00:01:07.000] FileWatcher:: Added:: WatchInfo: /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts 500 undefined WatchType: Closed Script info
-Info 27 [00:01:08.000] Starting updateGraphWorker: Project: /Users/someuser/work/applications/frontend/tsconfig.json
-Info 28 [00:01:09.000] Finishing updateGraphWorker: Project: /Users/someuser/work/applications/frontend/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms
-Info 29 [00:01:10.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
-Info 30 [00:01:11.000] Files (4)
+Info 23 [00:01:04.000] Running: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 24 [00:01:05.000] FileWatcher:: Added:: WatchInfo: /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts 500 undefined WatchType: Closed Script info
+Info 25 [00:01:06.000] Starting updateGraphWorker: Project: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 26 [00:01:07.000] Finishing updateGraphWorker: Project: /Users/someuser/work/applications/frontend/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms
+Info 27 [00:01:08.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
+Info 28 [00:01:09.000] Files (4)
/a/lib/lib.es2016.full.d.ts
/Users/someuser/work/applications/frontend/src/app/redux/configureStore.ts
/Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts
@@ -152,24 +148,24 @@ Info 30 [00:01:11.000] Files (4)
src/app/utils/Cookie.ts
Matched by include pattern 'src/**/*' in 'tsconfig.json'
-Info 31 [00:01:12.000] -----------------------------------------------
-Info 32 [00:01:13.000] Running: *ensureProjectForOpenFiles*
-Info 33 [00:01:14.000] Before ensureProjectForOpenFiles:
-Info 34 [00:01:15.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
-Info 34 [00:01:16.000] Files (4)
-
-Info 34 [00:01:17.000] -----------------------------------------------
-Info 34 [00:01:18.000] Open files:
-Info 34 [00:01:19.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts ProjectRootPath: undefined
-Info 34 [00:01:20.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
-Info 34 [00:01:21.000] After ensureProjectForOpenFiles:
-Info 35 [00:01:22.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
-Info 35 [00:01:23.000] Files (4)
-
-Info 35 [00:01:24.000] -----------------------------------------------
-Info 35 [00:01:25.000] Open files:
-Info 35 [00:01:26.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts ProjectRootPath: undefined
-Info 35 [00:01:27.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 29 [00:01:10.000] -----------------------------------------------
+Info 30 [00:01:11.000] Running: *ensureProjectForOpenFiles*
+Info 31 [00:01:12.000] Before ensureProjectForOpenFiles:
+Info 32 [00:01:13.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
+Info 32 [00:01:14.000] Files (4)
+
+Info 32 [00:01:15.000] -----------------------------------------------
+Info 32 [00:01:16.000] Open files:
+Info 32 [00:01:17.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts ProjectRootPath: undefined
+Info 32 [00:01:18.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 32 [00:01:19.000] After ensureProjectForOpenFiles:
+Info 33 [00:01:20.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
+Info 33 [00:01:21.000] Files (4)
+
+Info 33 [00:01:22.000] -----------------------------------------------
+Info 33 [00:01:23.000] Open files:
+Info 33 [00:01:24.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts ProjectRootPath: undefined
+Info 33 [00:01:25.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
After running timeout callbacks
PolledWatches::
@@ -177,8 +173,6 @@ PolledWatches::
{"pollingInterval":500}
/users/someuser/work/applications/frontend/node_modules:
{"pollingInterval":500}
-/users/someuser/work/applications/node_modules:
- {"pollingInterval":500}
FsWatches::
/users/someuser/work/applications/frontend/tsconfig.json:
@@ -194,25 +188,25 @@ FsWatchesRecursive::
/users/someuser/work/applications/frontend/src:
{}
-Info 35 [00:01:28.000] fileExists:: [{"key":"/users/someuser/work/applications/frontend/src/app/utils/cookie.ts","count":1},{"key":"/Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts","count":1}]
-Info 36 [00:01:29.000] directoryExists:: [{"key":"/users/someuser/work/applications/frontend/src/app/utils/cookie.ts","count":1}]
-Info 37 [00:01:30.000] getDirectories:: []
-Info 38 [00:01:31.000] readFile:: [{"key":"/Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts","count":1}]
-Info 39 [00:01:32.000] readDirectory:: []
-Info 40 [00:01:33.000] FileWatcher:: Close:: WatchInfo: /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts 500 undefined WatchType: Closed Script info
-Info 41 [00:01:34.000] Search path: /Users/someuser/work/applications/frontend/src/app/utils
-Info 42 [00:01:35.000] For info: /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts :: Config file name: /Users/someuser/work/applications/frontend/tsconfig.json
-Info 43 [00:01:36.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
-Info 43 [00:01:37.000] Files (4)
-
-Info 43 [00:01:38.000] -----------------------------------------------
-Info 43 [00:01:39.000] Open files:
-Info 43 [00:01:40.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts ProjectRootPath: undefined
-Info 43 [00:01:41.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
-Info 43 [00:01:42.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts ProjectRootPath: undefined
-Info 43 [00:01:43.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
-Info 43 [00:01:44.000] fileExists:: []
-Info 44 [00:01:45.000] directoryExists:: []
-Info 45 [00:01:46.000] getDirectories:: []
-Info 46 [00:01:47.000] readFile:: []
-Info 47 [00:01:48.000] readDirectory:: []
\ No newline at end of file
+Info 33 [00:01:26.000] fileExists:: [{"key":"/users/someuser/work/applications/frontend/src/app/utils/cookie.ts","count":1},{"key":"/Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts","count":1}]
+Info 34 [00:01:27.000] directoryExists:: [{"key":"/users/someuser/work/applications/frontend/src/app/utils/cookie.ts","count":1}]
+Info 35 [00:01:28.000] getDirectories:: []
+Info 36 [00:01:29.000] readFile:: [{"key":"/Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts","count":1}]
+Info 37 [00:01:30.000] readDirectory:: []
+Info 38 [00:01:31.000] FileWatcher:: Close:: WatchInfo: /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts 500 undefined WatchType: Closed Script info
+Info 39 [00:01:32.000] Search path: /Users/someuser/work/applications/frontend/src/app/utils
+Info 40 [00:01:33.000] For info: /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts :: Config file name: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 41 [00:01:34.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
+Info 41 [00:01:35.000] Files (4)
+
+Info 41 [00:01:36.000] -----------------------------------------------
+Info 41 [00:01:37.000] Open files:
+Info 41 [00:01:38.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts ProjectRootPath: undefined
+Info 41 [00:01:39.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 41 [00:01:40.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts ProjectRootPath: undefined
+Info 41 [00:01:41.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 41 [00:01:42.000] fileExists:: []
+Info 42 [00:01:43.000] directoryExists:: []
+Info 43 [00:01:44.000] getDirectories:: []
+Info 44 [00:01:45.000] readFile:: []
+Info 45 [00:01:46.000] readDirectory:: []
\ No newline at end of file
diff --git a/tests/baselines/reference/tsserver/cachingFileSystemInformation/watchDirectories-for-config-file-with-case-sensitive-file-system.js b/tests/baselines/reference/tsserver/cachingFileSystemInformation/watchDirectories-for-config-file-with-case-sensitive-file-system.js
index 60c410090a674..3c1a0230068dd 100644
--- a/tests/baselines/reference/tsserver/cachingFileSystemInformation/watchDirectories-for-config-file-with-case-sensitive-file-system.js
+++ b/tests/baselines/reference/tsserver/cachingFileSystemInformation/watchDirectories-for-config-file-with-case-sensitive-file-system.js
@@ -77,11 +77,9 @@ Info 11 [00:00:44.000] DirectoryWatcher:: Added:: WatchInfo: /Users/someuser/w
Info 12 [00:00:45.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /Users/someuser/work/applications/frontend/types 1 undefined Project: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Failed Lookup Locations
Info 13 [00:00:46.000] DirectoryWatcher:: Added:: WatchInfo: /Users/someuser/work/applications/frontend/node_modules 1 undefined Project: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Failed Lookup Locations
Info 14 [00:00:47.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /Users/someuser/work/applications/frontend/node_modules 1 undefined Project: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Failed Lookup Locations
-Info 15 [00:00:48.000] DirectoryWatcher:: Added:: WatchInfo: /Users/someuser/work/applications/node_modules 1 undefined Project: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Failed Lookup Locations
-Info 16 [00:00:49.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /Users/someuser/work/applications/node_modules 1 undefined Project: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Failed Lookup Locations
-Info 17 [00:00:50.000] Finishing updateGraphWorker: Project: /Users/someuser/work/applications/frontend/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
-Info 18 [00:00:51.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
-Info 19 [00:00:52.000] Files (3)
+Info 15 [00:00:48.000] Finishing updateGraphWorker: Project: /Users/someuser/work/applications/frontend/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
+Info 16 [00:00:49.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
+Info 17 [00:00:50.000] Files (3)
/a/lib/lib.es2016.full.d.ts
/Users/someuser/work/applications/frontend/src/app/redux/configureStore.ts
/Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts
@@ -94,18 +92,18 @@ Info 19 [00:00:52.000] Files (3)
src/app/utils/Analytic.ts
Matched by include pattern 'src/**/*' in 'tsconfig.json'
-Info 20 [00:00:53.000] -----------------------------------------------
-Info 21 [00:00:54.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
-Info 21 [00:00:55.000] Files (3)
-
-Info 21 [00:00:56.000] -----------------------------------------------
-Info 21 [00:00:57.000] Open files:
-Info 21 [00:00:58.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts ProjectRootPath: undefined
-Info 21 [00:00:59.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
-Info 21 [00:01:02.000] DirectoryWatcher:: Triggered with /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts :: WatchInfo: /Users/someuser/work/applications/frontend/src 1 undefined Config: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Wild card directory
-Info 22 [00:01:03.000] Scheduled: /Users/someuser/work/applications/frontend/tsconfig.json
-Info 23 [00:01:04.000] Scheduled: *ensureProjectForOpenFiles*
-Info 24 [00:01:05.000] Elapsed:: *ms DirectoryWatcher:: Triggered with /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts :: WatchInfo: /Users/someuser/work/applications/frontend/src 1 undefined Config: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Wild card directory
+Info 18 [00:00:51.000] -----------------------------------------------
+Info 19 [00:00:52.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
+Info 19 [00:00:53.000] Files (3)
+
+Info 19 [00:00:54.000] -----------------------------------------------
+Info 19 [00:00:55.000] Open files:
+Info 19 [00:00:56.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts ProjectRootPath: undefined
+Info 19 [00:00:57.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 19 [00:01:00.000] DirectoryWatcher:: Triggered with /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts :: WatchInfo: /Users/someuser/work/applications/frontend/src 1 undefined Config: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Wild card directory
+Info 20 [00:01:01.000] Scheduled: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 21 [00:01:02.000] Scheduled: *ensureProjectForOpenFiles*
+Info 22 [00:01:03.000] Elapsed:: *ms DirectoryWatcher:: Triggered with /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts :: WatchInfo: /Users/someuser/work/applications/frontend/src 1 undefined Config: /Users/someuser/work/applications/frontend/tsconfig.json WatchType: Wild card directory
Before running timeout callbacks
//// [/Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts]
export class Cookie { }
@@ -116,8 +114,6 @@ PolledWatches::
{"pollingInterval":500}
/Users/someuser/work/applications/frontend/node_modules:
{"pollingInterval":500}
-/Users/someuser/work/applications/node_modules:
- {"pollingInterval":500}
FsWatches::
/Users/someuser/work/applications/frontend/tsconfig.json:
@@ -131,12 +127,12 @@ FsWatchesRecursive::
/Users/someuser/work/applications/frontend/src:
{}
-Info 25 [00:01:06.000] Running: /Users/someuser/work/applications/frontend/tsconfig.json
-Info 26 [00:01:07.000] FileWatcher:: Added:: WatchInfo: /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts 500 undefined WatchType: Closed Script info
-Info 27 [00:01:08.000] Starting updateGraphWorker: Project: /Users/someuser/work/applications/frontend/tsconfig.json
-Info 28 [00:01:09.000] Finishing updateGraphWorker: Project: /Users/someuser/work/applications/frontend/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms
-Info 29 [00:01:10.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
-Info 30 [00:01:11.000] Files (4)
+Info 23 [00:01:04.000] Running: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 24 [00:01:05.000] FileWatcher:: Added:: WatchInfo: /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts 500 undefined WatchType: Closed Script info
+Info 25 [00:01:06.000] Starting updateGraphWorker: Project: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 26 [00:01:07.000] Finishing updateGraphWorker: Project: /Users/someuser/work/applications/frontend/tsconfig.json Version: 2 structureChanged: true structureIsReused:: Not Elapsed:: *ms
+Info 27 [00:01:08.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
+Info 28 [00:01:09.000] Files (4)
/a/lib/lib.es2016.full.d.ts
/Users/someuser/work/applications/frontend/src/app/redux/configureStore.ts
/Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts
@@ -152,24 +148,24 @@ Info 30 [00:01:11.000] Files (4)
src/app/utils/Cookie.ts
Matched by include pattern 'src/**/*' in 'tsconfig.json'
-Info 31 [00:01:12.000] -----------------------------------------------
-Info 32 [00:01:13.000] Running: *ensureProjectForOpenFiles*
-Info 33 [00:01:14.000] Before ensureProjectForOpenFiles:
-Info 34 [00:01:15.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
-Info 34 [00:01:16.000] Files (4)
-
-Info 34 [00:01:17.000] -----------------------------------------------
-Info 34 [00:01:18.000] Open files:
-Info 34 [00:01:19.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts ProjectRootPath: undefined
-Info 34 [00:01:20.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
-Info 34 [00:01:21.000] After ensureProjectForOpenFiles:
-Info 35 [00:01:22.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
-Info 35 [00:01:23.000] Files (4)
-
-Info 35 [00:01:24.000] -----------------------------------------------
-Info 35 [00:01:25.000] Open files:
-Info 35 [00:01:26.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts ProjectRootPath: undefined
-Info 35 [00:01:27.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 29 [00:01:10.000] -----------------------------------------------
+Info 30 [00:01:11.000] Running: *ensureProjectForOpenFiles*
+Info 31 [00:01:12.000] Before ensureProjectForOpenFiles:
+Info 32 [00:01:13.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
+Info 32 [00:01:14.000] Files (4)
+
+Info 32 [00:01:15.000] -----------------------------------------------
+Info 32 [00:01:16.000] Open files:
+Info 32 [00:01:17.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts ProjectRootPath: undefined
+Info 32 [00:01:18.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 32 [00:01:19.000] After ensureProjectForOpenFiles:
+Info 33 [00:01:20.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
+Info 33 [00:01:21.000] Files (4)
+
+Info 33 [00:01:22.000] -----------------------------------------------
+Info 33 [00:01:23.000] Open files:
+Info 33 [00:01:24.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts ProjectRootPath: undefined
+Info 33 [00:01:25.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
After running timeout callbacks
PolledWatches::
@@ -177,8 +173,6 @@ PolledWatches::
{"pollingInterval":500}
/Users/someuser/work/applications/frontend/node_modules:
{"pollingInterval":500}
-/Users/someuser/work/applications/node_modules:
- {"pollingInterval":500}
FsWatches::
/Users/someuser/work/applications/frontend/tsconfig.json:
@@ -194,25 +188,25 @@ FsWatchesRecursive::
/Users/someuser/work/applications/frontend/src:
{}
-Info 35 [00:01:28.000] fileExists:: [{"key":"/Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts","count":2}]
-Info 36 [00:01:29.000] directoryExists:: [{"key":"/Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts","count":1}]
-Info 37 [00:01:30.000] getDirectories:: []
-Info 38 [00:01:31.000] readFile:: [{"key":"/Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts","count":1}]
-Info 39 [00:01:32.000] readDirectory:: []
-Info 40 [00:01:33.000] FileWatcher:: Close:: WatchInfo: /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts 500 undefined WatchType: Closed Script info
-Info 41 [00:01:34.000] Search path: /Users/someuser/work/applications/frontend/src/app/utils
-Info 42 [00:01:35.000] For info: /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts :: Config file name: /Users/someuser/work/applications/frontend/tsconfig.json
-Info 43 [00:01:36.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
-Info 43 [00:01:37.000] Files (4)
-
-Info 43 [00:01:38.000] -----------------------------------------------
-Info 43 [00:01:39.000] Open files:
-Info 43 [00:01:40.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts ProjectRootPath: undefined
-Info 43 [00:01:41.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
-Info 43 [00:01:42.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts ProjectRootPath: undefined
-Info 43 [00:01:43.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
-Info 43 [00:01:44.000] fileExists:: []
-Info 44 [00:01:45.000] directoryExists:: []
-Info 45 [00:01:46.000] getDirectories:: []
-Info 46 [00:01:47.000] readFile:: []
-Info 47 [00:01:48.000] readDirectory:: []
\ No newline at end of file
+Info 33 [00:01:26.000] fileExists:: [{"key":"/Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts","count":2}]
+Info 34 [00:01:27.000] directoryExists:: [{"key":"/Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts","count":1}]
+Info 35 [00:01:28.000] getDirectories:: []
+Info 36 [00:01:29.000] readFile:: [{"key":"/Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts","count":1}]
+Info 37 [00:01:30.000] readDirectory:: []
+Info 38 [00:01:31.000] FileWatcher:: Close:: WatchInfo: /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts 500 undefined WatchType: Closed Script info
+Info 39 [00:01:32.000] Search path: /Users/someuser/work/applications/frontend/src/app/utils
+Info 40 [00:01:33.000] For info: /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts :: Config file name: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 41 [00:01:34.000] Project '/Users/someuser/work/applications/frontend/tsconfig.json' (Configured)
+Info 41 [00:01:35.000] Files (4)
+
+Info 41 [00:01:36.000] -----------------------------------------------
+Info 41 [00:01:37.000] Open files:
+Info 41 [00:01:38.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Analytic.ts ProjectRootPath: undefined
+Info 41 [00:01:39.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 41 [00:01:40.000] FileName: /Users/someuser/work/applications/frontend/src/app/utils/Cookie.ts ProjectRootPath: undefined
+Info 41 [00:01:41.000] Projects: /Users/someuser/work/applications/frontend/tsconfig.json
+Info 41 [00:01:42.000] fileExists:: []
+Info 42 [00:01:43.000] directoryExists:: []
+Info 43 [00:01:44.000] getDirectories:: []
+Info 44 [00:01:45.000] readFile:: []
+Info 45 [00:01:46.000] readDirectory:: []
\ No newline at end of file
diff --git a/tests/baselines/reference/tsserver/resolutionCache/types-should-load-from-config-file-path-if-config-exists.js b/tests/baselines/reference/tsserver/resolutionCache/types-should-load-from-config-file-path-if-config-exists.js
new file mode 100644
index 0000000000000..c5220185bcb33
--- /dev/null
+++ b/tests/baselines/reference/tsserver/resolutionCache/types-should-load-from-config-file-path-if-config-exists.js
@@ -0,0 +1,61 @@
+Info 0 [00:00:21.000] Provided types map file "/typesMap.json" doesn't exist
+Creating project service
+//// [/a/b/app.ts]
+let x = 1
+
+//// [/a/b/tsconfig.json]
+{"compilerOptions":{"types":["node"]}}
+
+//// [/a/b/node_modules/@types/node/index.d.ts]
+declare var process: any
+
+
+PolledWatches::
+
+FsWatches::
+
+FsWatchesRecursive::
+
+Info 1 [00:00:22.000] Search path: /a/b
+Info 2 [00:00:23.000] For info: /a/b/app.ts :: Config file name: /a/b/tsconfig.json
+Info 3 [00:00:24.000] Creating configuration project /a/b/tsconfig.json
+Info 4 [00:00:25.000] FileWatcher:: Added:: WatchInfo: /a/b/tsconfig.json 2000 undefined Project: /a/b/tsconfig.json WatchType: Config file
+Info 5 [00:00:26.000] Config: /a/b/tsconfig.json : {
+ "rootNames": [
+ "/a/b/app.ts"
+ ],
+ "options": {
+ "types": [
+ "node"
+ ],
+ "configFilePath": "/a/b/tsconfig.json"
+ }
+}
+Info 6 [00:00:27.000] DirectoryWatcher:: Added:: WatchInfo: /a/b 1 undefined Config: /a/b/tsconfig.json WatchType: Wild card directory
+Info 7 [00:00:28.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /a/b 1 undefined Config: /a/b/tsconfig.json WatchType: Wild card directory
+Info 8 [00:00:29.000] Starting updateGraphWorker: Project: /a/b/tsconfig.json
+Info 9 [00:00:30.000] DirectoryWatcher:: Added:: WatchInfo: /a/b/node_modules 1 undefined WatchType: node_modules for closed script infos and package.jsons affecting module specifier cache
+Info 10 [00:00:31.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /a/b/node_modules 1 undefined WatchType: node_modules for closed script infos and package.jsons affecting module specifier cache
+Info 11 [00:00:32.000] DirectoryWatcher:: Added:: WatchInfo: /a/b/node_modules 1 undefined Project: /a/b/tsconfig.json WatchType: Failed Lookup Locations
+Info 12 [00:00:33.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /a/b/node_modules 1 undefined Project: /a/b/tsconfig.json WatchType: Failed Lookup Locations
+Info 13 [00:00:34.000] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined Project: /a/b/tsconfig.json WatchType: Missing file
+Info 14 [00:00:35.000] Finishing updateGraphWorker: Project: /a/b/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
+Info 15 [00:00:36.000] Project '/a/b/tsconfig.json' (Configured)
+Info 16 [00:00:37.000] Files (2)
+ /a/b/app.ts
+ /a/b/node_modules/@types/node/index.d.ts
+
+
+ app.ts
+ Matched by default include pattern '**/*'
+ node_modules/@types/node/index.d.ts
+ Entry point of type library 'node' specified in compilerOptions
+
+Info 17 [00:00:38.000] -----------------------------------------------
+Info 18 [00:00:39.000] Project '/a/b/tsconfig.json' (Configured)
+Info 18 [00:00:40.000] Files (2)
+
+Info 18 [00:00:41.000] -----------------------------------------------
+Info 18 [00:00:42.000] Open files:
+Info 18 [00:00:43.000] FileName: /a/b/app.ts ProjectRootPath: undefined
+Info 18 [00:00:44.000] Projects: /a/b/tsconfig.json
\ No newline at end of file
diff --git a/tests/baselines/reference/tsserver/resolutionCache/types-should-not-load-from-config-file-path-if-config-exists-but-does-not-specifies-typeRoots.js b/tests/baselines/reference/tsserver/resolutionCache/types-should-not-load-from-config-file-path-if-config-exists-but-does-not-specifies-typeRoots.js
new file mode 100644
index 0000000000000..5dd964c41b967
--- /dev/null
+++ b/tests/baselines/reference/tsserver/resolutionCache/types-should-not-load-from-config-file-path-if-config-exists-but-does-not-specifies-typeRoots.js
@@ -0,0 +1,55 @@
+Info 0 [00:00:21.000] Provided types map file "/typesMap.json" doesn't exist
+Creating project service
+//// [/a/b/app.ts]
+let x = 1
+
+//// [/a/b/tsconfig.json]
+{"compilerOptions":{"types":["node"],"typeRoots":[]}}
+
+//// [/a/b/node_modules/@types/node/index.d.ts]
+declare var process: any
+
+
+PolledWatches::
+
+FsWatches::
+
+FsWatchesRecursive::
+
+Info 1 [00:00:22.000] Search path: /a/b
+Info 2 [00:00:23.000] For info: /a/b/app.ts :: Config file name: /a/b/tsconfig.json
+Info 3 [00:00:24.000] Creating configuration project /a/b/tsconfig.json
+Info 4 [00:00:25.000] FileWatcher:: Added:: WatchInfo: /a/b/tsconfig.json 2000 undefined Project: /a/b/tsconfig.json WatchType: Config file
+Info 5 [00:00:26.000] Config: /a/b/tsconfig.json : {
+ "rootNames": [
+ "/a/b/app.ts"
+ ],
+ "options": {
+ "types": [
+ "node"
+ ],
+ "typeRoots": [],
+ "configFilePath": "/a/b/tsconfig.json"
+ }
+}
+Info 6 [00:00:27.000] DirectoryWatcher:: Added:: WatchInfo: /a/b 1 undefined Config: /a/b/tsconfig.json WatchType: Wild card directory
+Info 7 [00:00:28.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /a/b 1 undefined Config: /a/b/tsconfig.json WatchType: Wild card directory
+Info 8 [00:00:29.000] Starting updateGraphWorker: Project: /a/b/tsconfig.json
+Info 9 [00:00:30.000] FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 500 undefined Project: /a/b/tsconfig.json WatchType: Missing file
+Info 10 [00:00:31.000] Finishing updateGraphWorker: Project: /a/b/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
+Info 11 [00:00:32.000] Project '/a/b/tsconfig.json' (Configured)
+Info 12 [00:00:33.000] Files (1)
+ /a/b/app.ts
+
+
+ app.ts
+ Matched by default include pattern '**/*'
+
+Info 13 [00:00:34.000] -----------------------------------------------
+Info 14 [00:00:35.000] Project '/a/b/tsconfig.json' (Configured)
+Info 14 [00:00:36.000] Files (1)
+
+Info 14 [00:00:37.000] -----------------------------------------------
+Info 14 [00:00:38.000] Open files:
+Info 14 [00:00:39.000] FileName: /a/b/app.ts ProjectRootPath: undefined
+Info 14 [00:00:40.000] Projects: /a/b/tsconfig.json
\ No newline at end of file
diff --git a/tests/baselines/reference/tsserver/resolutionCache/when-resolves-to-ambient-module.js b/tests/baselines/reference/tsserver/resolutionCache/when-resolves-to-ambient-module.js
index ebbecdbfdc2b7..6852cae434ce6 100644
--- a/tests/baselines/reference/tsserver/resolutionCache/when-resolves-to-ambient-module.js
+++ b/tests/baselines/reference/tsserver/resolutionCache/when-resolves-to-ambient-module.js
@@ -85,11 +85,13 @@ Info 17 [00:00:50.000] DirectoryWatcher:: Added:: WatchInfo: /user/username/pr
Info 18 [00:00:51.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/node_modules 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
Info 19 [00:00:52.000] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
Info 20 [00:00:53.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/node_modules 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
-Info 21 [00:00:54.000] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/typings 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Type roots
-Info 22 [00:00:55.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/typings 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Type roots
-Info 23 [00:00:56.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
-Info 24 [00:00:57.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured)
-Info 25 [00:00:58.000] Files (5)
+Info 21 [00:00:54.000] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/typings 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
+Info 22 [00:00:55.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/typings 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Failed Lookup Locations
+Info 23 [00:00:56.000] DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/typings 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Type roots
+Info 24 [00:00:57.000] Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/myproject/src/typings 1 undefined Project: /user/username/projects/myproject/src/tsconfig.json WatchType: Type roots
+Info 25 [00:00:58.000] Finishing updateGraphWorker: Project: /user/username/projects/myproject/src/tsconfig.json Version: 1 structureChanged: true structureIsReused:: Not Elapsed:: *ms
+Info 26 [00:00:59.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured)
+Info 27 [00:01:00.000] Files (5)
/a/lib/lib.d.ts
/user/username/projects/myproject/src/somefolder/module1.ts
/user/username/projects/myproject/src/somefolder/srcfile.ts
@@ -109,11 +111,11 @@ Info 25 [00:00:58.000] Files (5)
typings/node.d.ts
Matched by default include pattern '**/*'
-Info 26 [00:00:59.000] -----------------------------------------------
-Info 27 [00:01:00.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured)
-Info 27 [00:01:01.000] Files (5)
+Info 28 [00:01:01.000] -----------------------------------------------
+Info 29 [00:01:02.000] Project '/user/username/projects/myproject/src/tsconfig.json' (Configured)
+Info 29 [00:01:03.000] Files (5)
-Info 27 [00:01:02.000] -----------------------------------------------
-Info 27 [00:01:03.000] Open files:
-Info 27 [00:01:04.000] FileName: /user/username/projects/myproject/src/somefolder/srcfile.ts ProjectRootPath: /user/username/projects/myproject
-Info 27 [00:01:05.000] Projects: /user/username/projects/myproject/src/tsconfig.json
\ No newline at end of file
+Info 29 [00:01:04.000] -----------------------------------------------
+Info 29 [00:01:05.000] Open files:
+Info 29 [00:01:06.000] FileName: /user/username/projects/myproject/src/somefolder/srcfile.ts ProjectRootPath: /user/username/projects/myproject
+Info 29 [00:01:07.000] Projects: /user/username/projects/myproject/src/tsconfig.json
\ No newline at end of file
diff --git a/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.errors.txt b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.errors.txt
new file mode 100644
index 0000000000000..5e7672baa4b39
--- /dev/null
+++ b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.errors.txt
@@ -0,0 +1,22 @@
+error TS2688: Cannot find type definition file for 'phaser'.
+ The file is in the program because:
+ Entry point of type library 'phaser' specified in compilerOptions
+/a.ts(1,1): error TS2304: Cannot find name 'a'.
+
+
+!!! error TS2688: Cannot find type definition file for 'phaser'.
+!!! error TS2688: The file is in the program because:
+!!! error TS2688: Entry point of type library 'phaser' specified in compilerOptions
+==== /a.ts (1 errors) ====
+ a;
+ ~
+!!! error TS2304: Cannot find name 'a'.
+==== /typings/dummy.d.ts (0 errors) ====
+ declare const a2: number;
+
+==== /node_modules/phaser/types/phaser.d.ts (0 errors) ====
+ declare const a: number;
+
+==== /node_modules/phaser/package.json (0 errors) ====
+ { "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" }
+
\ No newline at end of file
diff --git a/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.js b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.js
new file mode 100644
index 0000000000000..ca6fb691a224b
--- /dev/null
+++ b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.js
@@ -0,0 +1,16 @@
+//// [tests/cases/compiler/typeReferenceDirectiveWithFailedFromTypeRoot.ts] ////
+
+//// [dummy.d.ts]
+declare const a2: number;
+
+//// [phaser.d.ts]
+declare const a: number;
+
+//// [package.json]
+{ "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" }
+
+//// [a.ts]
+a;
+
+//// [a.js]
+a;
diff --git a/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.symbols b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.symbols
new file mode 100644
index 0000000000000..4b42ab41dfba4
--- /dev/null
+++ b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.symbols
@@ -0,0 +1,3 @@
+=== /a.ts ===
+
+a;
diff --git a/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.trace.json b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.trace.json
new file mode 100644
index 0000000000000..a3cd33c89fd1b
--- /dev/null
+++ b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.trace.json
@@ -0,0 +1,7 @@
+[
+ "======== Resolving type reference directive 'phaser', containing file '/__inferred type names__.ts', root directory '/typings'. ========",
+ "Resolving with primary search path '/typings'.",
+ "File '/typings/phaser.d.ts' does not exist.",
+ "Resolving type reference directive for program that specifies custom typeRoots, skipping lookup in 'node_modules' folder.",
+ "======== Type reference directive 'phaser' was not resolved. ========"
+]
\ No newline at end of file
diff --git a/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.types b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.types
new file mode 100644
index 0000000000000..2ec6ffcf1be41
--- /dev/null
+++ b/tests/baselines/reference/typeReferenceDirectiveWithFailedFromTypeRoot.types
@@ -0,0 +1,4 @@
+=== /a.ts ===
+a;
+>a : any
+
diff --git a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.js b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.js
new file mode 100644
index 0000000000000..58a1fb047d8b2
--- /dev/null
+++ b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.js
@@ -0,0 +1,11 @@
+//// [tests/cases/compiler/typeReferenceDirectiveWithTypeAsFile.ts] ////
+
+//// [phaser.d.ts]
+declare const a: number;
+
+//// [a.ts]
+a;
+
+
+//// [a.js]
+a;
diff --git a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.symbols b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.symbols
new file mode 100644
index 0000000000000..f29a1bafe2741
--- /dev/null
+++ b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.symbols
@@ -0,0 +1,8 @@
+=== /a.ts ===
+a;
+>a : Symbol(a, Decl(phaser.d.ts, 0, 13))
+
+=== /node_modules/phaser/types/phaser.d.ts ===
+declare const a: number;
+>a : Symbol(a, Decl(phaser.d.ts, 0, 13))
+
diff --git a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.trace.json b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.trace.json
new file mode 100644
index 0000000000000..90a6fd6c5246a
--- /dev/null
+++ b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.trace.json
@@ -0,0 +1,8 @@
+[
+ "======== Resolving type reference directive 'phaser', containing file '/__inferred type names__.ts', root directory '/node_modules/phaser/types'. ========",
+ "Resolving with primary search path '/node_modules/phaser/types'.",
+ "File '/node_modules/phaser/types/phaser.d.ts' exists - use it as a name resolution result.",
+ "File '/node_modules/phaser/package.json' does not exist.",
+ "Resolving real path for '/node_modules/phaser/types/phaser.d.ts', result '/node_modules/phaser/types/phaser.d.ts'.",
+ "======== Type reference directive 'phaser' was successfully resolved to '/node_modules/phaser/types/phaser.d.ts', primary: true. ========"
+]
\ No newline at end of file
diff --git a/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.types b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.types
new file mode 100644
index 0000000000000..20416fc921d6d
--- /dev/null
+++ b/tests/baselines/reference/typeReferenceDirectiveWithTypeAsFile.types
@@ -0,0 +1,8 @@
+=== /a.ts ===
+a;
+>a : number
+
+=== /node_modules/phaser/types/phaser.d.ts ===
+declare const a: number;
+>a : number
+
diff --git a/tests/baselines/reference/typeReferenceDirectives1.trace.json b/tests/baselines/reference/typeReferenceDirectives1.trace.json
index 123efd357b850..c26f57d965c16 100644
--- a/tests/baselines/reference/typeReferenceDirectives1.trace.json
+++ b/tests/baselines/reference/typeReferenceDirectives1.trace.json
@@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
+ "File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
diff --git a/tests/baselines/reference/typeReferenceDirectives10.trace.json b/tests/baselines/reference/typeReferenceDirectives10.trace.json
index a4e91143469b0..5976efed50cb5 100644
--- a/tests/baselines/reference/typeReferenceDirectives10.trace.json
+++ b/tests/baselines/reference/typeReferenceDirectives10.trace.json
@@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
+ "File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
diff --git a/tests/baselines/reference/typeReferenceDirectives11.trace.json b/tests/baselines/reference/typeReferenceDirectives11.trace.json
index 8b23b436de5a4..90b73567c580e 100644
--- a/tests/baselines/reference/typeReferenceDirectives11.trace.json
+++ b/tests/baselines/reference/typeReferenceDirectives11.trace.json
@@ -6,6 +6,7 @@
"======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
+ "File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
diff --git a/tests/baselines/reference/typeReferenceDirectives12.trace.json b/tests/baselines/reference/typeReferenceDirectives12.trace.json
index ed1f49c7afde2..62cf4a1ddf7b3 100644
--- a/tests/baselines/reference/typeReferenceDirectives12.trace.json
+++ b/tests/baselines/reference/typeReferenceDirectives12.trace.json
@@ -11,6 +11,7 @@
"======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/mod1.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
+ "File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
diff --git a/tests/baselines/reference/typeReferenceDirectives13.trace.json b/tests/baselines/reference/typeReferenceDirectives13.trace.json
index a4e91143469b0..5976efed50cb5 100644
--- a/tests/baselines/reference/typeReferenceDirectives13.trace.json
+++ b/tests/baselines/reference/typeReferenceDirectives13.trace.json
@@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
+ "File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
diff --git a/tests/baselines/reference/typeReferenceDirectives2.trace.json b/tests/baselines/reference/typeReferenceDirectives2.trace.json
index fb124aa978d31..455887c6d7e47 100644
--- a/tests/baselines/reference/typeReferenceDirectives2.trace.json
+++ b/tests/baselines/reference/typeReferenceDirectives2.trace.json
@@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
+ "File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
diff --git a/tests/baselines/reference/typeReferenceDirectives3.trace.json b/tests/baselines/reference/typeReferenceDirectives3.trace.json
index 123efd357b850..c26f57d965c16 100644
--- a/tests/baselines/reference/typeReferenceDirectives3.trace.json
+++ b/tests/baselines/reference/typeReferenceDirectives3.trace.json
@@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
+ "File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
diff --git a/tests/baselines/reference/typeReferenceDirectives4.trace.json b/tests/baselines/reference/typeReferenceDirectives4.trace.json
index 123efd357b850..c26f57d965c16 100644
--- a/tests/baselines/reference/typeReferenceDirectives4.trace.json
+++ b/tests/baselines/reference/typeReferenceDirectives4.trace.json
@@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
+ "File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
diff --git a/tests/baselines/reference/typeReferenceDirectives5.trace.json b/tests/baselines/reference/typeReferenceDirectives5.trace.json
index a4e91143469b0..5976efed50cb5 100644
--- a/tests/baselines/reference/typeReferenceDirectives5.trace.json
+++ b/tests/baselines/reference/typeReferenceDirectives5.trace.json
@@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
+ "File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
diff --git a/tests/baselines/reference/typeReferenceDirectives6.trace.json b/tests/baselines/reference/typeReferenceDirectives6.trace.json
index 123efd357b850..c26f57d965c16 100644
--- a/tests/baselines/reference/typeReferenceDirectives6.trace.json
+++ b/tests/baselines/reference/typeReferenceDirectives6.trace.json
@@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
+ "File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
diff --git a/tests/baselines/reference/typeReferenceDirectives7.trace.json b/tests/baselines/reference/typeReferenceDirectives7.trace.json
index 123efd357b850..c26f57d965c16 100644
--- a/tests/baselines/reference/typeReferenceDirectives7.trace.json
+++ b/tests/baselines/reference/typeReferenceDirectives7.trace.json
@@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
+ "File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
diff --git a/tests/baselines/reference/typeReferenceDirectives8.trace.json b/tests/baselines/reference/typeReferenceDirectives8.trace.json
index 8b23b436de5a4..90b73567c580e 100644
--- a/tests/baselines/reference/typeReferenceDirectives8.trace.json
+++ b/tests/baselines/reference/typeReferenceDirectives8.trace.json
@@ -6,6 +6,7 @@
"======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
+ "File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
diff --git a/tests/baselines/reference/typeReferenceDirectives9.trace.json b/tests/baselines/reference/typeReferenceDirectives9.trace.json
index ed1f49c7afde2..62cf4a1ddf7b3 100644
--- a/tests/baselines/reference/typeReferenceDirectives9.trace.json
+++ b/tests/baselines/reference/typeReferenceDirectives9.trace.json
@@ -11,6 +11,7 @@
"======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/mod1.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
+ "File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
diff --git a/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.trace.json b/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.trace.json
index 702c35909103d..99985f1f534a5 100644
--- a/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.trace.json
+++ b/tests/baselines/reference/typeRootsFromMultipleNodeModulesDirectories.trace.json
@@ -56,20 +56,23 @@
"File '/node_modules/abc.js' does not exist.",
"File '/node_modules/abc.jsx' does not exist.",
"======== Module name 'abc' was not resolved. ========",
- "======== Resolving type reference directive 'grumpy', containing file '/foo/bar/__inferred type names__.ts', root directory '/foo/node_modules/@types,/node_modules/@types'. ========",
- "Resolving with primary search path '/foo/node_modules/@types, /node_modules/@types'.",
+ "======== Resolving type reference directive 'grumpy', containing file '/foo/bar/__inferred type names__.ts', root directory '/foo/bar/node_modules/@types,/foo/node_modules/@types,/node_modules/@types'. ========",
+ "Resolving with primary search path '/foo/bar/node_modules/@types, /foo/node_modules/@types, /node_modules/@types'.",
+ "Directory '/foo/bar/node_modules/@types' does not exist, skipping all lookups in it.",
"File '/foo/node_modules/@types/grumpy/package.json' does not exist.",
"File '/foo/node_modules/@types/grumpy/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/foo/node_modules/@types/grumpy/index.d.ts', result '/foo/node_modules/@types/grumpy/index.d.ts'.",
"======== Type reference directive 'grumpy' was successfully resolved to '/foo/node_modules/@types/grumpy/index.d.ts', primary: true. ========",
- "======== Resolving type reference directive 'sneezy', containing file '/foo/bar/__inferred type names__.ts', root directory '/foo/node_modules/@types,/node_modules/@types'. ========",
- "Resolving with primary search path '/foo/node_modules/@types, /node_modules/@types'.",
+ "======== Resolving type reference directive 'sneezy', containing file '/foo/bar/__inferred type names__.ts', root directory '/foo/bar/node_modules/@types,/foo/node_modules/@types,/node_modules/@types'. ========",
+ "Resolving with primary search path '/foo/bar/node_modules/@types, /foo/node_modules/@types, /node_modules/@types'.",
+ "Directory '/foo/bar/node_modules/@types' does not exist, skipping all lookups in it.",
"File '/foo/node_modules/@types/sneezy/package.json' does not exist.",
"File '/foo/node_modules/@types/sneezy/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/foo/node_modules/@types/sneezy/index.d.ts', result '/foo/node_modules/@types/sneezy/index.d.ts'.",
"======== Type reference directive 'sneezy' was successfully resolved to '/foo/node_modules/@types/sneezy/index.d.ts', primary: true. ========",
- "======== Resolving type reference directive 'dopey', containing file '/foo/bar/__inferred type names__.ts', root directory '/foo/node_modules/@types,/node_modules/@types'. ========",
- "Resolving with primary search path '/foo/node_modules/@types, /node_modules/@types'.",
+ "======== Resolving type reference directive 'dopey', containing file '/foo/bar/__inferred type names__.ts', root directory '/foo/bar/node_modules/@types,/foo/node_modules/@types,/node_modules/@types'. ========",
+ "Resolving with primary search path '/foo/bar/node_modules/@types, /foo/node_modules/@types, /node_modules/@types'.",
+ "Directory '/foo/bar/node_modules/@types' does not exist, skipping all lookups in it.",
"File '/node_modules/@types/dopey/package.json' does not exist.",
"File '/node_modules/@types/dopey/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/dopey/index.d.ts', result '/node_modules/@types/dopey/index.d.ts'.",
diff --git a/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.trace.json b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.trace.json
index f63c1df7b543c..357ecc0cbc692 100644
--- a/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.trace.json
+++ b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.trace.json
@@ -12,8 +12,9 @@
"File '/node_modules/xyz.js' does not exist.",
"File '/node_modules/xyz.jsx' does not exist.",
"======== Module name 'xyz' was not resolved. ========",
- "======== Resolving type reference directive 'foo', containing file '/src/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
- "Resolving with primary search path '/node_modules/@types'.",
+ "======== Resolving type reference directive 'foo', containing file '/src/__inferred type names__.ts', root directory '/src/node_modules/@types,/node_modules/@types'. ========",
+ "Resolving with primary search path '/src/node_modules/@types, /node_modules/@types'.",
+ "Directory '/src/node_modules/@types' does not exist, skipping all lookups in it.",
"File '/node_modules/@types/foo/package.json' does not exist.",
"File '/node_modules/@types/foo/index.d.ts' exists - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/foo/index.d.ts', result '/node_modules/@types/foo/index.d.ts'.",
diff --git a/tests/cases/compiler/moduleResolutionAsTypeReferenceDirective.ts b/tests/cases/compiler/moduleResolutionAsTypeReferenceDirective.ts
new file mode 100644
index 0000000000000..c3e2e2396d5e2
--- /dev/null
+++ b/tests/cases/compiler/moduleResolutionAsTypeReferenceDirective.ts
@@ -0,0 +1,15 @@
+// @noImplicitReferences: true
+// @typeRoots: /typings
+// @types: phaser
+// @traceResolution: true
+// @currentDirectory: /
+
+// @Filename: /typings/phaser/types/phaser.d.ts
+export const a2: number;
+
+// @Filename: /typings/phaser/package.json
+{ "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" }
+
+
+// @Filename: /a.ts
+import { a2 } from "phaser";
\ No newline at end of file
diff --git a/tests/cases/compiler/moduleResolutionAsTypeReferenceDirectiveAmbient.ts b/tests/cases/compiler/moduleResolutionAsTypeReferenceDirectiveAmbient.ts
new file mode 100644
index 0000000000000..a0b7e0d29d1cb
--- /dev/null
+++ b/tests/cases/compiler/moduleResolutionAsTypeReferenceDirectiveAmbient.ts
@@ -0,0 +1,17 @@
+// @noImplicitReferences: true
+// @typeRoots: /typings
+// @types: phaser
+// @traceResolution: true
+// @currentDirectory: /
+
+// @Filename: /typings/phaser/types/phaser.d.ts
+declare module "phaser" {
+ export const a2: number;
+}
+
+// @Filename: /typings/phaser/package.json
+{ "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" }
+
+
+// @Filename: /a.ts
+import { a2 } from "phaser";
\ No newline at end of file
diff --git a/tests/cases/compiler/typeReferenceDirectiveWithFailedFromTypeRoot.ts b/tests/cases/compiler/typeReferenceDirectiveWithFailedFromTypeRoot.ts
new file mode 100644
index 0000000000000..eec8f38a6dd8f
--- /dev/null
+++ b/tests/cases/compiler/typeReferenceDirectiveWithFailedFromTypeRoot.ts
@@ -0,0 +1,17 @@
+// @noImplicitReferences: true
+// @typeRoots: /typings
+// @types: phaser
+// @traceResolution: true
+// @currentDirectory: /
+
+// @Filename: /typings/dummy.d.ts
+declare const a2: number;
+
+// @Filename: /node_modules/phaser/types/phaser.d.ts
+declare const a: number;
+
+// @Filename: /node_modules/phaser/package.json
+{ "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" }
+
+// @Filename: /a.ts
+a;
\ No newline at end of file
diff --git a/tests/cases/compiler/typeReferenceDirectiveWithTypeAsFile.ts b/tests/cases/compiler/typeReferenceDirectiveWithTypeAsFile.ts
new file mode 100644
index 0000000000000..e730d31001759
--- /dev/null
+++ b/tests/cases/compiler/typeReferenceDirectiveWithTypeAsFile.ts
@@ -0,0 +1,11 @@
+// @noImplicitReferences: true
+// @typeRoots: /node_modules/phaser/types
+// @types: phaser
+// @traceResolution: true
+// @currentDirectory: /
+
+// @Filename: /node_modules/phaser/types/phaser.d.ts
+declare const a: number;
+
+// @Filename: /a.ts
+a;