Compare commits

...

9 commits

Author SHA1 Message Date
Sheetal Nandi 1978d367de TODOs for later 2020-07-22 16:23:28 -07:00
Sheetal Nandi 70fd04c0a6 Add test that shows types file does not act as ambient module declaration. 2020-07-22 15:53:25 -07:00
Sheetal Nandi e64e70f6a7 Auto type reference directive shouldnt lookup in node_modules
Fixes #37708
Bug 1 part of the issue
2020-07-22 15:37:09 -07:00
Sheetal Nandi 97b7cbc704 Test to show even when typeRoots are specified, resolution falls back to node_modules in nearest directory 2020-07-21 15:08:30 -07:00
Sheetal Nandi 8a07917b67 Remaining baseline changes 2020-07-21 15:08:30 -07:00
Sheetal Nandi 4c77eb92fe Baseline traceResolution traces from reuseProgramStructure
Fixes existing baseline as well (part2)
2020-07-21 15:08:29 -07:00
Sheetal Nandi 27191d5b3a Fix existing baseline Part1 2020-07-21 15:08:29 -07:00
Sheetal Nandi 892f214d49 Resolve typeReferenceDirective as fileOrDirectory instead of just directory
Fixes #37708
Bug 2 part of the issue
2020-07-21 15:08:29 -07:00
Sheetal Nandi 85bce61a6b Test case 2020-07-21 15:08:28 -07:00
70 changed files with 844 additions and 322 deletions

View file

@ -4473,6 +4473,10 @@
"category": "Message",
"code": 6235
},
"Resolving type reference directive for program with typeRoots, skipping lookup in 'node_modules' folder.": {
"category": "Message",
"code": 6236
},
"Projects to reference": {
"category": "Message",

View file

@ -250,7 +250,7 @@ namespace ts {
}
if (currentDirectory !== undefined) {
return getDefaultTypeRoots(currentDirectory, host);
return getDefaultTypeRoots(currentDirectory);
}
}
@ -258,19 +258,11 @@ namespace ts {
* 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 || (typeRoots = [])).push(atTypes);
});
return typeRoots;
}
@ -343,15 +335,15 @@ namespace ts {
trace(host, Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
}
return firstDefined(typeRoots, typeRoot => {
const candidate = combinePaths(typeRoot, typeReferenceDirectiveName);
const candidateDirectory = getDirectoryPath(candidate);
const directoryExists = directoryProbablyExists(candidateDirectory, host);
if (!directoryExists && traceEnabled) {
trace(host, Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory);
}
return resolvedTypeScriptOnly(
loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate,
!directoryExists, moduleResolutionState));
nodeLoadModuleByRelativeName(
Extensions.DtsOnly,
combinePaths(typeRoot, typeReferenceDirectiveName),
/*onlyRecordFailures*/ false,
moduleResolutionState,
/*considerPackageJson*/ true
)
);
});
}
else {
@ -363,20 +355,25 @@ namespace ts {
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);
}
// Do not resolve auto types from secondary location
let result: Resolved | undefined;
if (!isExternalModuleNameRelative(typeReferenceDirectiveName)) {
const searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, 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.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, /*cache*/ undefined, /*redirectedReference*/ undefined);
result = searchResult && searchResult.value;
}
else {
const { path: candidate } = normalizePathAndParts(combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName));
result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true);
}
}
else {
const { path: candidate } = normalizePathAndParts(combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName));
result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, /*onlyRecordFailures*/ false, moduleResolutionState, /*considerPackageJson*/ true);
else if (traceEnabled) {
trace(host, Diagnostics.Resolving_type_reference_directive_for_program_with_typeRoots_skipping_lookup_in_node_modules_folder);
}
const resolvedFile = resolvedTypeScriptOnly(result);
if (!resolvedFile && traceEnabled) {
@ -944,6 +941,7 @@ namespace ts {
if (traceEnabled) {
trace(host, Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]);
}
// TODO:: resolve type ference directive
const resolved = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
if (!resolved) return undefined;
@ -1473,7 +1471,8 @@ namespace ts {
}
if (extensions === Extensions.TypeScript) {
// If we didn't find the file normally, look it up in @types.
return loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
// TODO type referecnce like resolution
return resolveTypeReferenceDirective(moduleName, containingFile, containingDirectory, state);
}
}
else {

View file

@ -869,26 +869,28 @@ namespace ts {
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);
}
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);
}
// 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();
// 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);
// 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;
}
/**
@ -906,7 +908,7 @@ namespace ts {
// 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,
@ -922,12 +924,11 @@ namespace ts {
}
}
/**
* 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 || canWatchDirectory(dirPath);

View file

@ -7748,7 +7748,6 @@ namespace ts {
}
export interface GetEffectiveTypeRootsHost {
directoryExists?(directoryName: string): boolean;
getCurrentDirectory?(): string;
}

View file

@ -2278,10 +2278,6 @@ namespace ts.server {
return !!this.externalProjectRefCount;
}
getEffectiveTypeRoots() {
return getEffectiveTypeRoots(this.getCompilationSettings(), this.directoryStructureHost) || [];
}
/*@internal*/
updateErrorOnNoInputFiles(fileNameResult: ExpandResult) {
updateErrorForNoInputFiles(fileNameResult, this.getConfigFilePath(), this.configFileSpecs!, this.projectErrors!, this.canConfigFileJsonReportNoInputFiles);

View file

@ -250,6 +250,7 @@ namespace ts {
readFile?(path: string, encoding?: string): string | undefined;
realpath?(path: string): string;
fileExists?(path: string): boolean;
directoryExists?(directoryName: string): boolean;
/*
* LS host can optionally implement these methods to support automatic updating when new type libraries are installed

View file

@ -210,6 +210,18 @@ namespace ts {
checkCache("resolved type directives", program, fileName, expectedContent, f => f.resolvedTypeReferenceDirectiveNames, checkResolvedTypeDirective);
}
type Traces = [subScenario: string, program: ProgramWithSourceTexts][];
function baselineTrace(scenario: string, traces: Traces) {
const actual: MapLike<string[]> = {};
for (const [subScenario, program] of traces) {
actual[subScenario] = program.host.getTrace().map(Utils.sanitizeTraceResolutionLogEntry);
}
Harness.Baseline.runBaseline(
`reuseProgramStructure/${scenario.split(" ").join("-")}.trace.json`,
JSON.stringify(actual, undefined, 4)
);
}
describe("unittests:: Reuse program structure:: General", () => {
const target = ScriptTarget.Latest;
const files: NamedSourceText[] = [
@ -455,34 +467,11 @@ namespace ts {
const options: CompilerOptions = { target: ScriptTarget.ES2015, traceResolution: true, moduleResolution: ModuleResolutionKind.NodeJs };
const rootFiles = [file1Ts, file2Ts];
const filesAfterNpmInstall = [file1Ts, file2Ts, indexDTS];
const traces: Traces = [];
const initialProgram = newProgram(rootFiles, rootFiles.map(f => f.name), options);
{
assert.deepEqual(initialProgram.host.getTrace(),
[
"======== Resolving module 'a' from 'file1.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.",
"File 'node_modules/a/package.json' does not exist.",
"File 'node_modules/a.ts' does not exist.",
"File 'node_modules/a.tsx' does not exist.",
"File 'node_modules/a.d.ts' does not exist.",
"File 'node_modules/a/index.ts' does not exist.",
"File 'node_modules/a/index.tsx' does not exist.",
"File 'node_modules/a/index.d.ts' does not exist.",
"File 'node_modules/@types/a/package.json' does not exist.",
"File 'node_modules/@types/a.d.ts' does not exist.",
"File 'node_modules/@types/a/index.d.ts' does not exist.",
"Loading module 'a' from 'node_modules' folder, target file type 'JavaScript'.",
"File 'node_modules/a/package.json' does not exist.",
"File 'node_modules/a.js' does not exist.",
"File 'node_modules/a.jsx' does not exist.",
"File 'node_modules/a/index.js' does not exist.",
"File 'node_modules/a/index.jsx' does not exist.",
"======== Module name 'a' was not resolved. ========"
],
"initialProgram: execute module resolution normally.");
traces.push(["initialProgram: execute module resolution normally.", initialProgram]);
const initialProgramDiagnostics = initialProgram.getSemanticDiagnostics(initialProgram.getSourceFile("file1.ts"));
assert.lengthOf(initialProgramDiagnostics, 1, `initialProgram: import should fail.`);
}
@ -491,25 +480,12 @@ namespace ts {
f[1].text = f[1].text.updateReferences(`/// <reference no-default-lib="true"/>`);
}, filesAfterNpmInstall);
{
assert.deepEqual(afterNpmInstallProgram.host.getTrace(),
[
"======== Resolving module 'a' from 'file1.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.",
"File 'node_modules/a/package.json' does not exist.",
"File 'node_modules/a.ts' does not exist.",
"File 'node_modules/a.tsx' does not exist.",
"File 'node_modules/a.d.ts' does not exist.",
"File 'node_modules/a/index.ts' does not exist.",
"File 'node_modules/a/index.tsx' does not exist.",
"File 'node_modules/a/index.d.ts' exist - use it as a name resolution result.",
"======== Module name 'a' was successfully resolved to 'node_modules/a/index.d.ts'. ========"
],
"afterNpmInstallProgram: execute module resolution normally.");
traces.push(["afterNpmInstallProgram: execute module resolution normally.", afterNpmInstallProgram]);
const afterNpmInstallProgramDiagnostics = afterNpmInstallProgram.getSemanticDiagnostics(afterNpmInstallProgram.getSourceFile("file1.ts"));
assert.lengthOf(afterNpmInstallProgramDiagnostics, 0, `afterNpmInstallProgram: program is well-formed with import.`);
}
baselineTrace("fetches imports after npm install", traces);
});
it("can reuse ambient module declarations from non-modified files", () => {
@ -519,78 +495,19 @@ namespace ts {
];
const options = { target: ScriptTarget.ES2015, traceResolution: true };
const program = newProgram(files, files.map(f => f.name), options);
assert.deepEqual(program.host.getTrace(),
[
"======== Resolving module 'fs' from '/a/b/app.ts'. ========",
"Module resolution kind is not specified, using 'Classic'.",
"File '/a/b/fs.ts' does not exist.",
"File '/a/b/fs.tsx' does not exist.",
"File '/a/b/fs.d.ts' does not exist.",
"File '/a/fs.ts' does not exist.",
"File '/a/fs.tsx' does not exist.",
"File '/a/fs.d.ts' does not exist.",
"File '/fs.ts' does not exist.",
"File '/fs.tsx' does not exist.",
"File '/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/package.json' does not exist.",
"File '/a/b/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/node_modules/@types/fs/package.json' does not exist.",
"File '/a/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/node_modules/@types/fs/package.json' does not exist.",
"File '/node_modules/@types/fs.d.ts' does not exist.",
"File '/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/b/fs.js' does not exist.",
"File '/a/b/fs.jsx' does not exist.",
"File '/a/fs.js' does not exist.",
"File '/a/fs.jsx' does not exist.",
"File '/fs.js' does not exist.",
"File '/fs.jsx' does not exist.",
"======== Module name 'fs' was not resolved. ========",
], "should look for 'fs'");
const traces: Traces = [];
traces.push(["should look for 'fs'.", program]);
const program2 = updateProgram(program, program.getRootFileNames(), options, f => {
f[0].text = f[0].text.updateProgram("var x = 1;");
});
assert.deepEqual(program2.host.getTrace(), [
"Module 'fs' was resolved as ambient module declared in '/a/b/node.d.ts' since this file was not modified."
], "should reuse 'fs' since node.d.ts was not changed");
traces.push(["should reuse 'fs' since node.d.ts was not changed", program2]);
const program3 = updateProgram(program2, program2.getRootFileNames(), options, f => {
f[0].text = f[0].text.updateProgram("var y = 1;");
f[1].text = f[1].text.updateProgram("declare var process: any");
});
assert.deepEqual(program3.host.getTrace(),
[
"======== Resolving module 'fs' from '/a/b/app.ts'. ========",
"Module resolution kind is not specified, using 'Classic'.",
"File '/a/b/fs.ts' does not exist.",
"File '/a/b/fs.tsx' does not exist.",
"File '/a/b/fs.d.ts' does not exist.",
"File '/a/fs.ts' does not exist.",
"File '/a/fs.tsx' does not exist.",
"File '/a/fs.d.ts' does not exist.",
"File '/fs.ts' does not exist.",
"File '/fs.tsx' does not exist.",
"File '/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/package.json' does not exist.",
"File '/a/b/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/node_modules/@types/fs/package.json' does not exist.",
"File '/a/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/node_modules/@types/fs/package.json' does not exist.",
"File '/node_modules/@types/fs.d.ts' does not exist.",
"File '/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/b/fs.js' does not exist.",
"File '/a/b/fs.jsx' does not exist.",
"File '/a/fs.js' does not exist.",
"File '/a/fs.jsx' does not exist.",
"File '/fs.js' does not exist.",
"File '/fs.jsx' does not exist.",
"======== Module name 'fs' was not resolved. ========",
], "should look for 'fs' again since node.d.ts was changed");
traces.push(["should look for 'fs' again since node.d.ts was changed", program3]);
baselineTrace("can reuse ambient module declarations from non-modified files", traces);
});
it("can reuse module resolutions from non-modified files", () => {
@ -617,38 +534,12 @@ namespace ts {
"(new BB).x; (new BB).y;")
},
];
const traces: Traces = [];
const options: CompilerOptions = { target: ScriptTarget.ES2015, traceResolution: true, moduleResolution: ModuleResolutionKind.Classic };
const program1 = newProgram(files, files.map(f => f.name), options);
let expectedErrors = 0;
{
assert.deepEqual(program1.host.getTrace(),
[
"======== Resolving type reference directive 'typerefs1', containing file 'f1.ts', root directory 'node_modules/@types'. ========",
"Resolving with primary search path 'node_modules/@types'.",
"File 'node_modules/@types/typerefs1/package.json' does not exist.",
"File 'node_modules/@types/typerefs1/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'typerefs1' was successfully resolved to 'node_modules/@types/typerefs1/index.d.ts', primary: true. ========",
"======== Resolving module './b1' from 'f1.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"File 'b1.ts' exist - use it as a name resolution result.",
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========",
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
"Resolving with primary search path 'node_modules/@types'.",
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
"======== Resolving module './b2' from 'f2.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"File 'b2.ts' exist - use it as a name resolution result.",
"======== Module name './b2' was successfully resolved to 'b2.ts'. ========",
"======== Resolving module './f1' from 'f2.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"File 'f1.ts' exist - use it as a name resolution result.",
"======== Module name './f1' was successfully resolved to 'f1.ts'. ========"
],
"program1: execute module resolution normally.");
traces.push(["program1: execute module resolution normally.", program1]);
const program1Diagnostics = program1.getSemanticDiagnostics(program1.getSourceFile("f2.ts"));
assert.lengthOf(program1Diagnostics, expectedErrors, `initial program should be well-formed`);
}
@ -661,25 +552,7 @@ namespace ts {
{
const program2Diagnostics = program2.getSemanticDiagnostics(program2.getSourceFile("f2.ts"));
assert.lengthOf(program2Diagnostics, expectedErrors, `removing no-default-lib shouldn't affect any types used.`);
assert.deepEqual(program2.host.getTrace(), [
"======== Resolving type reference directive 'typerefs1', containing file 'f1.ts', root directory 'node_modules/@types'. ========",
"Resolving with primary search path 'node_modules/@types'.",
"File 'node_modules/@types/typerefs1/package.json' does not exist.",
"File 'node_modules/@types/typerefs1/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'typerefs1' was successfully resolved to 'node_modules/@types/typerefs1/index.d.ts', primary: true. ========",
"======== Resolving module './b1' from 'f1.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"File 'b1.ts' exist - use it as a name resolution result.",
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========",
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
"Resolving with primary search path 'node_modules/@types'.",
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
"Reusing resolution of module './b2' to file 'f2.ts' from old program.",
"Reusing resolution of module './f1' to file 'f2.ts' from old program."
], "program2: reuse module resolutions in f2 since it is unchanged");
traces.push(["program2: reuse module resolutions in f2 since it is unchanged", program2]);
}
const program3 = updateProgram(program2, program2.getRootFileNames(), options, f => {
@ -690,20 +563,7 @@ namespace ts {
{
const program3Diagnostics = program3.getSemanticDiagnostics(program3.getSourceFile("f2.ts"));
assert.lengthOf(program3Diagnostics, expectedErrors, `typerefs2 was unused, so diagnostics should be unaffected.`);
assert.deepEqual(program3.host.getTrace(), [
"======== Resolving module './b1' from 'f1.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"File 'b1.ts' exist - use it as a name resolution result.",
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========",
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
"Resolving with primary search path 'node_modules/@types'.",
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
"Reusing resolution of module './b2' to file 'f2.ts' from old program.",
"Reusing resolution of module './f1' to file 'f2.ts' from old program."
], "program3: reuse module resolutions in f2 since it is unchanged");
traces.push(["program3: reuse module resolutions in f2 since it is unchanged", program3]);
}
@ -715,20 +575,7 @@ namespace ts {
{
const program4Diagnostics = program4.getSemanticDiagnostics(program4.getSourceFile("f2.ts"));
assert.lengthOf(program4Diagnostics, expectedErrors, `a1.ts was unused, so diagnostics should be unaffected.`);
assert.deepEqual(program4.host.getTrace(), [
"======== Resolving module './b1' from 'f1.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"File 'b1.ts' exist - use it as a name resolution result.",
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========",
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
"Resolving with primary search path 'node_modules/@types'.",
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
"Reusing resolution of module './b2' to file 'f2.ts' from old program.",
"Reusing resolution of module './f1' to file 'f2.ts' from old program."
], "program_4: reuse module resolutions in f2 since it is unchanged");
traces.push(["program_4: reuse module resolutions in f2 since it is unchanged", program4]);
}
const program5 = updateProgram(program4, program4.getRootFileNames(), options, f => {
@ -739,13 +586,7 @@ namespace ts {
{
const program5Diagnostics = program5.getSemanticDiagnostics(program5.getSourceFile("f2.ts"));
assert.lengthOf(program5Diagnostics, ++expectedErrors, `import of BB in f1 fails. BB is of type any. Add one error`);
assert.deepEqual(program5.host.getTrace(), [
"======== Resolving module './b1' from 'f1.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"File 'b1.ts' exist - use it as a name resolution result.",
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========"
], "program_5: exports do not affect program structure, so f2's resolutions are silently reused.");
traces.push(["program_5: exports do not affect program structure, so f2's resolutions are silently reused.", program5]);
}
const program6 = updateProgram(program5, program5.getRootFileNames(), options, f => {
@ -756,20 +597,7 @@ namespace ts {
{
const program6Diagnostics = program6.getSemanticDiagnostics(program6.getSourceFile("f2.ts"));
assert.lengthOf(program6Diagnostics, expectedErrors, `import of BB in f1 fails.`);
assert.deepEqual(program6.host.getTrace(), [
"======== Resolving module './b1' from 'f1.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"File 'b1.ts' exist - use it as a name resolution result.",
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========",
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
"Resolving with primary search path 'node_modules/@types'.",
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
"Reusing resolution of module './b2' to file 'f2.ts' from old program.",
"Reusing resolution of module './f1' to file 'f2.ts' from old program."
], "program_6: reuse module resolutions in f2 since it is unchanged");
traces.push(["program_6: reuse module resolutions in f2 since it is unchanged", program6]);
}
const program7 = updateProgram(program6, program6.getRootFileNames(), options, f => {
@ -780,17 +608,9 @@ namespace ts {
{
const program7Diagnostics = program7.getSemanticDiagnostics(program7.getSourceFile("f2.ts"));
assert.lengthOf(program7Diagnostics, expectedErrors, `removing import is noop with respect to program, so no change in diagnostics.`);
assert.deepEqual(program7.host.getTrace(), [
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
"Resolving with primary search path 'node_modules/@types'.",
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
"Reusing resolution of module './b2' to file 'f2.ts' from old program.",
"Reusing resolution of module './f1' to file 'f2.ts' from old program."
], "program_7 should reuse module resolutions in f2 since it is unchanged");
traces.push(["program_7 should reuse module resolutions in f2 since it is unchanged", program7]);
}
baselineTrace("can reuse module resolutions from non-modified files", traces);
});
describe("redirects", () => {

View file

@ -812,29 +812,37 @@ 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 });
},
changes: emptyArray
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 });
},
changes: emptyArray
});
}
verifyTypesLoad(/*includeTypeRoots*/ false);
verifyTypesLoad(/*includeTypeRoots*/ true);
});
verifyTscWatch({

View file

@ -391,7 +391,7 @@ namespace ts.projectSystem {
const { configFileName } = projectService.openClientFile(file1.path);
assert.equal(configFileName, tsconfigFile.path as server.NormalizedPath, `should find config`);
checkNumberOfConfiguredProjects(projectService, 1);
const watchingRecursiveDirectories = [`${canonicalFrontendDir}/src`, `${canonicalFrontendDir}/types`, `${canonicalFrontendDir}/node_modules`].concat(getNodeModuleDirectories(getDirectoryPath(canonicalFrontendDir)));
const watchingRecursiveDirectories = [`${canonicalFrontendDir}/src`, `${canonicalFrontendDir}/types`, `${canonicalFrontendDir}/node_modules`];
const project = projectService.configuredProjects.get(canonicalConfigPath)!;
verifyProjectAndWatchedDirectories();

View file

@ -418,27 +418,37 @@ namespace ts.projectSystem {
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(includeTypeRoots: boolean) {
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);
projectService.openClientFile(f1.path);
projectService.checkNumberOfProjects({ configuredProjects: 1 });
checkProjectActualFiles(configuredProjectAt(projectService, 0), [f1.path, config.path, ...(includeTypeRoots ? [] : [node.path])]);
}
it("types should load from config file path if config exists", () => {
verifyTypesLoad(/*includeTypeRoots*/ false);
});
it("types should not load from config file path if config exists but does not specifies typeRoots", () => {
verifyTypesLoad(/*includeTypeRoots*/ true);
});
});
});

View file

@ -3722,7 +3722,6 @@ declare namespace ts {
noEmitHelpers?: boolean;
}
export interface GetEffectiveTypeRootsHost {
directoryExists?(directoryName: string): boolean;
getCurrentDirectory?(): string;
}
export interface TextSpan {
@ -5334,6 +5333,7 @@ declare namespace ts {
readFile?(path: string, encoding?: string): string | undefined;
realpath?(path: string): string;
fileExists?(path: string): boolean;
directoryExists?(directoryName: string): boolean;
getTypeRootsVersion?(): number;
resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[];
getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined;
@ -9304,7 +9304,6 @@ declare namespace ts.server {
setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void;
getTypeAcquisition(): TypeAcquisition;
close(): void;
getEffectiveTypeRoots(): string[];
}
/**
* Project whose configuration is handled externally, such as in a '.csproj'.

View file

@ -3722,7 +3722,6 @@ declare namespace ts {
noEmitHelpers?: boolean;
}
export interface GetEffectiveTypeRootsHost {
directoryExists?(directoryName: string): boolean;
getCurrentDirectory?(): string;
}
export interface TextSpan {
@ -5334,6 +5333,7 @@ declare namespace ts {
readFile?(path: string, encoding?: string): string | undefined;
realpath?(path: string): string;
fileExists?(path: string): boolean;
directoryExists?(directoryName: string): boolean;
getTypeRootsVersion?(): number;
resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[];
getResolvedModuleWithFailedLookupLocationsFromCache?(modulename: string, containingFile: string): ResolvedModuleWithFailedLookupLocations | undefined;

View file

@ -1,12 +1,16 @@
[
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'.",
"Loading module as file / folder, candidate module location 'types/jquery', target file type 'DtsOnly'.",
"File 'types/jquery.d.ts' does not exist.",
"File 'types/jquery/package.json' does not exist.",
"File 'types/jquery/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for 'types/jquery/index.d.ts', result '/src/types/jquery/index.d.ts'.",
"======== Type reference directive 'jquery' was successfully resolved to '/src/types/jquery/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'jquery', containing file '/src/__inferred type names__.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'.",
"Loading module as file / folder, candidate module location 'types/jquery', target file type 'DtsOnly'.",
"File 'types/jquery.d.ts' does not exist.",
"File 'types/jquery/package.json' does not exist.",
"File 'types/jquery/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for 'types/jquery/index.d.ts', result '/src/types/jquery/index.d.ts'.",

View file

@ -1,6 +1,8 @@
[
"======== Resolving type reference directive 'jquery', containing file '/foo/consumer.ts', root directory './types'. ========",
"Resolving with primary search path './types'.",
"Loading module as file / folder, candidate module location './types/jquery', target file type 'DtsOnly'.",
"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'.",
@ -9,6 +11,8 @@
"======== Type reference directive 'jquery' was successfully resolved to '/foo/types/jquery/jquery.d.ts', primary: true. ========",
"======== Resolving type reference directive 'jquery', containing file '/foo/__inferred type names__.ts', root directory './types'. ========",
"Resolving with primary search path './types'.",
"Loading module as file / folder, candidate module location './types/jquery', target file type 'DtsOnly'.",
"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'.",

View file

@ -1,6 +1,8 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory '/a/types'. ========",
"Resolving with primary search path '/a/types'.",
"Loading module as file / folder, candidate module location '/a/types/jquery', target file type 'DtsOnly'.",
"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' exist - use it as a name resolution result.",
"Resolving real path for '/a/types/jquery/index.d.ts', result '/a/types/jquery/index.d.ts'.",

View file

@ -1,6 +1,8 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory '/a/types'. ========",
"Resolving with primary search path '/a/types'.",
"Loading module as file / folder, candidate module location '/a/types/jquery', target file type 'DtsOnly'.",
"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' exist - use it as a name resolution result.",
"Resolving real path for '/a/types/jquery/index.d.ts', result '/a/types/jquery/index.d.ts'.",

View file

@ -1,6 +1,8 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'.",
"Loading module as file / folder, candidate module location 'types/jquery', target file type 'DtsOnly'.",
"File 'types/jquery.d.ts' does not exist.",
"File 'types/jquery/package.json' does not exist.",
"File 'types/jquery/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for 'types/jquery/index.d.ts', result '/a/types/jquery/index.d.ts'.",

View file

@ -1,6 +1,8 @@
[
"======== Resolving type reference directive 'jquery', containing file '/consumer.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/jquery', target file type 'DtsOnly'.",
"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 +12,8 @@
"======== 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'.",
"Loading module as file / folder, candidate module location '/types/jquery', target file type 'DtsOnly'.",
"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.",

View file

@ -1,6 +1,9 @@
[
"======== Resolving type reference directive 'foo', containing file '/src/root.ts', root directory '/src'. ========",
"Resolving with primary search path '/src'.",
"Loading module as file / folder, candidate module location '/src/foo', target file type 'DtsOnly'.",
"File '/src/foo.d.ts' does not exist.",
"Directory '/src/foo' does not exist, skipping all lookups in it.",
"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 +13,9 @@
"======== 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'.",
"Loading module as file / folder, candidate module location '/src/bar', target file type 'DtsOnly'.",
"File '/src/bar.d.ts' does not exist.",
"Directory '/src/bar' does not exist, skipping all lookups in it.",
"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 +25,9 @@
"======== 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'.",
"Loading module as file / folder, candidate module location '/src/alpha', target file type 'DtsOnly'.",
"File '/src/alpha.d.ts' does not exist.",
"Directory '/src/alpha' does not exist, skipping all lookups in it.",
"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 +36,9 @@
"======== 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'.",
"Loading module as file / folder, candidate module location '/src/alpha', target file type 'DtsOnly'.",
"File '/src/alpha.d.ts' does not exist.",
"Directory '/src/alpha' does not exist, skipping all lookups in it.",
"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.",

View file

@ -1,6 +1,7 @@
[
"======== Resolving type reference directive 'foo', containing file '/src/root.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'.",
"Loading module as file / folder, candidate module location 'types/foo', target file type 'DtsOnly'.",
"Directory 'types' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/src'.",
"Directory '/src/node_modules' does not exist, skipping all lookups in it.",
@ -11,6 +12,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 'types'. ========",
"Resolving with primary search path 'types'.",
"Loading module as file / folder, candidate module location 'types/bar', target file type 'DtsOnly'.",
"Directory 'types' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/src'.",
"Directory '/src/node_modules' does not exist, skipping all lookups in it.",
@ -21,6 +23,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 'types'. ========",
"Resolving with primary search path 'types'.",
"Loading module as file / folder, candidate module location 'types/alpha', target file type 'DtsOnly'.",
"Directory 'types' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/node_modules/foo'.",
"File '/node_modules/foo/node_modules/alpha/package.json' does not exist.",
@ -30,6 +33,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 'types'. ========",
"Resolving with primary search path 'types'.",
"Loading module as file / folder, candidate module location 'types/alpha', target file type 'DtsOnly'.",
"Directory 'types' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/node_modules/bar'.",
"File '/node_modules/bar/node_modules/alpha/package.json' does not exist.",

View file

@ -1,12 +1,16 @@
[
"======== Resolving type reference directive 'alpha', containing file '/src/foo.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'.",
"Loading module as file / folder, candidate module location '/node_modules/@types/alpha', target file type 'DtsOnly'.",
"File '/node_modules/@types/alpha.d.ts' does not exist.",
"File '/node_modules/@types/alpha/package.json' does not exist.",
"File '/node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/alpha/index.d.ts', result '/node_modules/@types/alpha/index.d.ts'.",
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/@types/alpha/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'alpha', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'.",
"Loading module as file / folder, candidate module location '/node_modules/@types/alpha', target file type 'DtsOnly'.",
"File '/node_modules/@types/alpha.d.ts' does not exist.",
"File '/node_modules/@types/alpha/package.json' does not exist.",
"File '/node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/alpha/index.d.ts', result '/node_modules/@types/alpha/index.d.ts'.",

View file

@ -1,36 +1,48 @@
[
"======== Resolving type reference directive 'alpha', containing file '/test/foo.ts', root directory '/test/types'. ========",
"Resolving with primary search path '/test/types'.",
"Loading module as file / folder, candidate module location '/test/types/alpha', target file type 'DtsOnly'.",
"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' exist - use it as a name resolution result.",
"Resolving real path for '/test/types/alpha/index.d.ts', result '/test/types/alpha/index.d.ts'.",
"======== Type reference directive 'alpha' was successfully resolved to '/test/types/alpha/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'beta', containing file '/test/foo.ts', root directory '/test/types'. ========",
"Resolving with primary search path '/test/types'.",
"Loading module as file / folder, candidate module location '/test/types/beta', target file type 'DtsOnly'.",
"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' exist - use it as a name resolution result.",
"Resolving real path for '/test/types/beta/index.d.ts', result '/test/types/beta/index.d.ts'.",
"======== Type reference directive 'beta' was successfully resolved to '/test/types/beta/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'beta', containing file '/test/types/alpha/index.d.ts', root directory '/test/types'. ========",
"Resolving with primary search path '/test/types'.",
"Loading module as file / folder, candidate module location '/test/types/beta', target file type 'DtsOnly'.",
"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' exist - use it as a name resolution result.",
"Resolving real path for '/test/types/beta/index.d.ts', result '/test/types/beta/index.d.ts'.",
"======== Type reference directive 'beta' was successfully resolved to '/test/types/beta/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'alpha', containing file '/test/types/beta/index.d.ts', root directory '/test/types'. ========",
"Resolving with primary search path '/test/types'.",
"Loading module as file / folder, candidate module location '/test/types/alpha', target file type 'DtsOnly'.",
"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' exist - use it as a name resolution result.",
"Resolving real path for '/test/types/alpha/index.d.ts', result '/test/types/alpha/index.d.ts'.",
"======== Type reference directive 'alpha' was successfully resolved to '/test/types/alpha/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'alpha', containing file '/test/__inferred type names__.ts', root directory '/test/types'. ========",
"Resolving with primary search path '/test/types'.",
"Loading module as file / folder, candidate module location '/test/types/alpha', target file type 'DtsOnly'.",
"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' exist - use it as a name resolution result.",
"Resolving real path for '/test/types/alpha/index.d.ts', result '/test/types/alpha/index.d.ts'.",
"======== Type reference directive 'alpha' was successfully resolved to '/test/types/alpha/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'beta', containing file '/test/__inferred type names__.ts', root directory '/test/types'. ========",
"Resolving with primary search path '/test/types'.",
"Loading module as file / folder, candidate module location '/test/types/beta', target file type 'DtsOnly'.",
"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' exist - use it as a name resolution result.",
"Resolving real path for '/test/types/beta/index.d.ts', result '/test/types/beta/index.d.ts'.",

View file

@ -1,6 +1,7 @@
[
"======== Resolving type reference directive '@beep/boop', containing file '/a.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'.",
"Loading module as file / folder, candidate module location 'types/@beep/boop', target file type 'DtsOnly'.",
"Directory 'types/@beep' does not exist, skipping all lookups in it.",
"Looking up in 'node_modules' folder, initial location '/'.",
"Scoped package detected, looking in 'beep__boop'",

View file

@ -0,0 +1,15 @@
/a.ts(1,20): error TS2307: Cannot find module 'phaser' or its corresponding type declarations.
==== /a.ts (1 errors) ====
import { a2 } from "phaser";
~~~~~~~~
!!! error TS2307: Cannot find module 'phaser' or its corresponding type declarations.
==== /typings/phaser/types/phaser.d.ts (0 errors) ====
export const a2: number;
==== /typings/phaser/package.json (0 errors) ====
{ "name": "phaser", "version": "1.2.3", "types": "types/phaser.d.ts" }

View file

@ -0,0 +1,16 @@
//// [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";
exports.__esModule = true;

View file

@ -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))

View file

@ -0,0 +1,20 @@
[
"======== Resolving module 'phaser' from '/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'phaser' from 'node_modules' folder, target file type 'TypeScript'.",
"Directory '/node_modules' does not exist, skipping all lookups in it.",
"Loading module 'phaser' from 'node_modules' folder, target file type 'JavaScript'.",
"Directory '/node_modules' does not exist, skipping all lookups in it.",
"======== Module name 'phaser' was not resolved. ========",
"======== Resolving type reference directive 'phaser', containing file '/__inferred type names__.ts', root directory '/typings'. ========",
"Resolving with primary search path '/typings'.",
"Loading module as file / folder, candidate module location '/typings/phaser', target file type 'DtsOnly'.",
"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' exist - 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. ========"
]

View file

@ -0,0 +1,8 @@
=== /a.ts ===
import { a2 } from "phaser";
>a2 : any
=== /typings/phaser/types/phaser.d.ts ===
export const a2: number;
>a2 : number

View file

@ -0,0 +1,18 @@
//// [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";
exports.__esModule = true;

View file

@ -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))
}

View file

@ -0,0 +1,20 @@
[
"======== Resolving module 'phaser' from '/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'phaser' from 'node_modules' folder, target file type 'TypeScript'.",
"Directory '/node_modules' does not exist, skipping all lookups in it.",
"Loading module 'phaser' from 'node_modules' folder, target file type 'JavaScript'.",
"Directory '/node_modules' does not exist, skipping all lookups in it.",
"======== Module name 'phaser' was not resolved. ========",
"======== Resolving type reference directive 'phaser', containing file '/__inferred type names__.ts', root directory '/typings'. ========",
"Resolving with primary search path '/typings'.",
"Loading module as file / folder, candidate module location '/typings/phaser', target file type 'DtsOnly'.",
"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' exist - 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. ========"
]

View file

@ -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
}

View file

@ -0,0 +1,63 @@
{
"should look for 'fs'.": [
"======== Resolving module 'fs' from '/a/b/app.ts'. ========",
"Module resolution kind is not specified, using 'Classic'.",
"File '/a/b/fs.ts' does not exist.",
"File '/a/b/fs.tsx' does not exist.",
"File '/a/b/fs.d.ts' does not exist.",
"File '/a/fs.ts' does not exist.",
"File '/a/fs.tsx' does not exist.",
"File '/a/fs.d.ts' does not exist.",
"File '/fs.ts' does not exist.",
"File '/fs.tsx' does not exist.",
"File '/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/package.json' does not exist.",
"File '/a/b/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/node_modules/@types/fs/package.json' does not exist.",
"File '/a/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/node_modules/@types/fs/package.json' does not exist.",
"File '/node_modules/@types/fs.d.ts' does not exist.",
"File '/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/b/fs.js' does not exist.",
"File '/a/b/fs.jsx' does not exist.",
"File '/a/fs.js' does not exist.",
"File '/a/fs.jsx' does not exist.",
"File '/fs.js' does not exist.",
"File '/fs.jsx' does not exist.",
"======== Module name 'fs' was not resolved. ========"
],
"should reuse 'fs' since node.d.ts was not changed": [
"Module 'fs' was resolved as ambient module declared in '/a/b/node.d.ts' since this file was not modified."
],
"should look for 'fs' again since node.d.ts was changed": [
"======== Resolving module 'fs' from '/a/b/app.ts'. ========",
"Module resolution kind is not specified, using 'Classic'.",
"File '/a/b/fs.ts' does not exist.",
"File '/a/b/fs.tsx' does not exist.",
"File '/a/b/fs.d.ts' does not exist.",
"File '/a/fs.ts' does not exist.",
"File '/a/fs.tsx' does not exist.",
"File '/a/fs.d.ts' does not exist.",
"File '/fs.ts' does not exist.",
"File '/fs.tsx' does not exist.",
"File '/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/package.json' does not exist.",
"File '/a/b/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/b/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/node_modules/@types/fs/package.json' does not exist.",
"File '/a/node_modules/@types/fs.d.ts' does not exist.",
"File '/a/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/node_modules/@types/fs/package.json' does not exist.",
"File '/node_modules/@types/fs.d.ts' does not exist.",
"File '/node_modules/@types/fs/index.d.ts' does not exist.",
"File '/a/b/fs.js' does not exist.",
"File '/a/b/fs.jsx' does not exist.",
"File '/a/fs.js' does not exist.",
"File '/a/fs.jsx' does not exist.",
"File '/fs.js' does not exist.",
"File '/fs.jsx' does not exist.",
"======== Module name 'fs' was not resolved. ========"
]
}

View file

@ -0,0 +1,114 @@
{
"program1: execute module resolution normally.": [
"======== Resolving type reference directive 'typerefs1', containing file 'f1.ts', root directory 'node_modules/@types'. ========",
"Resolving with primary search path 'node_modules/@types'.",
"Loading module as file / folder, candidate module location 'node_modules/@types/typerefs1', target file type 'DtsOnly'.",
"File 'node_modules/@types/typerefs1.d.ts' does not exist.",
"File 'node_modules/@types/typerefs1/package.json' does not exist.",
"File 'node_modules/@types/typerefs1/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'typerefs1' was successfully resolved to 'node_modules/@types/typerefs1/index.d.ts', primary: true. ========",
"======== Resolving module './b1' from 'f1.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"File 'b1.ts' exist - use it as a name resolution result.",
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========",
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
"Resolving with primary search path 'node_modules/@types'.",
"Loading module as file / folder, candidate module location 'node_modules/@types/typerefs2', target file type 'DtsOnly'.",
"File 'node_modules/@types/typerefs2.d.ts' does not exist.",
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
"======== Resolving module './b2' from 'f2.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"File 'b2.ts' exist - use it as a name resolution result.",
"======== Module name './b2' was successfully resolved to 'b2.ts'. ========",
"======== Resolving module './f1' from 'f2.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"File 'f1.ts' exist - use it as a name resolution result.",
"======== Module name './f1' was successfully resolved to 'f1.ts'. ========"
],
"program2: reuse module resolutions in f2 since it is unchanged": [
"======== Resolving type reference directive 'typerefs1', containing file 'f1.ts', root directory 'node_modules/@types'. ========",
"Resolving with primary search path 'node_modules/@types'.",
"Loading module as file / folder, candidate module location 'node_modules/@types/typerefs1', target file type 'DtsOnly'.",
"File 'node_modules/@types/typerefs1.d.ts' does not exist.",
"File 'node_modules/@types/typerefs1/package.json' does not exist.",
"File 'node_modules/@types/typerefs1/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'typerefs1' was successfully resolved to 'node_modules/@types/typerefs1/index.d.ts', primary: true. ========",
"======== Resolving module './b1' from 'f1.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"File 'b1.ts' exist - use it as a name resolution result.",
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========",
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
"Resolving with primary search path 'node_modules/@types'.",
"Loading module as file / folder, candidate module location 'node_modules/@types/typerefs2', target file type 'DtsOnly'.",
"File 'node_modules/@types/typerefs2.d.ts' does not exist.",
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
"Reusing resolution of module './b2' to file 'f2.ts' from old program.",
"Reusing resolution of module './f1' to file 'f2.ts' from old program."
],
"program3: reuse module resolutions in f2 since it is unchanged": [
"======== Resolving module './b1' from 'f1.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"File 'b1.ts' exist - use it as a name resolution result.",
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========",
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
"Resolving with primary search path 'node_modules/@types'.",
"Loading module as file / folder, candidate module location 'node_modules/@types/typerefs2', target file type 'DtsOnly'.",
"File 'node_modules/@types/typerefs2.d.ts' does not exist.",
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
"Reusing resolution of module './b2' to file 'f2.ts' from old program.",
"Reusing resolution of module './f1' to file 'f2.ts' from old program."
],
"program_4: reuse module resolutions in f2 since it is unchanged": [
"======== Resolving module './b1' from 'f1.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"File 'b1.ts' exist - use it as a name resolution result.",
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========",
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
"Resolving with primary search path 'node_modules/@types'.",
"Loading module as file / folder, candidate module location 'node_modules/@types/typerefs2', target file type 'DtsOnly'.",
"File 'node_modules/@types/typerefs2.d.ts' does not exist.",
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
"Reusing resolution of module './b2' to file 'f2.ts' from old program.",
"Reusing resolution of module './f1' to file 'f2.ts' from old program."
],
"program_5: exports do not affect program structure, so f2's resolutions are silently reused.": [
"======== Resolving module './b1' from 'f1.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"File 'b1.ts' exist - use it as a name resolution result.",
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========"
],
"program_6: reuse module resolutions in f2 since it is unchanged": [
"======== Resolving module './b1' from 'f1.ts'. ========",
"Explicitly specified module resolution kind: 'Classic'.",
"File 'b1.ts' exist - use it as a name resolution result.",
"======== Module name './b1' was successfully resolved to 'b1.ts'. ========",
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
"Resolving with primary search path 'node_modules/@types'.",
"Loading module as file / folder, candidate module location 'node_modules/@types/typerefs2', target file type 'DtsOnly'.",
"File 'node_modules/@types/typerefs2.d.ts' does not exist.",
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
"Reusing resolution of module './b2' to file 'f2.ts' from old program.",
"Reusing resolution of module './f1' to file 'f2.ts' from old program."
],
"program_7 should reuse module resolutions in f2 since it is unchanged": [
"======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========",
"Resolving with primary search path 'node_modules/@types'.",
"Loading module as file / folder, candidate module location 'node_modules/@types/typerefs2', target file type 'DtsOnly'.",
"File 'node_modules/@types/typerefs2.d.ts' does not exist.",
"File 'node_modules/@types/typerefs2/package.json' does not exist.",
"File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========",
"Reusing resolution of module './b2' to file 'f2.ts' from old program.",
"Reusing resolution of module './f1' to file 'f2.ts' from old program."
]
}

View file

@ -0,0 +1,37 @@
{
"initialProgram: execute module resolution normally.": [
"======== Resolving module 'a' from 'file1.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.",
"File 'node_modules/a/package.json' does not exist.",
"File 'node_modules/a.ts' does not exist.",
"File 'node_modules/a.tsx' does not exist.",
"File 'node_modules/a.d.ts' does not exist.",
"File 'node_modules/a/index.ts' does not exist.",
"File 'node_modules/a/index.tsx' does not exist.",
"File 'node_modules/a/index.d.ts' does not exist.",
"File 'node_modules/@types/a/package.json' does not exist.",
"File 'node_modules/@types/a.d.ts' does not exist.",
"File 'node_modules/@types/a/index.d.ts' does not exist.",
"Loading module 'a' from 'node_modules' folder, target file type 'JavaScript'.",
"File 'node_modules/a/package.json' does not exist.",
"File 'node_modules/a.js' does not exist.",
"File 'node_modules/a.jsx' does not exist.",
"File 'node_modules/a/index.js' does not exist.",
"File 'node_modules/a/index.jsx' does not exist.",
"======== Module name 'a' was not resolved. ========"
],
"afterNpmInstallProgram: execute module resolution normally.": [
"======== Resolving module 'a' from 'file1.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.",
"File 'node_modules/a/package.json' does not exist.",
"File 'node_modules/a.ts' does not exist.",
"File 'node_modules/a.tsx' does not exist.",
"File 'node_modules/a.d.ts' does not exist.",
"File 'node_modules/a/index.ts' does not exist.",
"File 'node_modules/a/index.tsx' does not exist.",
"File 'node_modules/a/index.d.ts' exist - use it as a name resolution result.",
"======== Module name 'a' was successfully resolved to 'node_modules/a/index.d.ts'. ========"
]
}

View file

@ -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
@ -33,7 +33,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 files::
/a/lib/lib.d.ts
/a/b/app.ts

View file

@ -0,0 +1,65 @@
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]
/// <reference no-default-lib="true"/>
interface Boolean {}
interface Function {}
interface CallableFunction {}
interface NewableFunction {}
interface IArguments {}
interface Number { toExponential: any; }
interface Object {}
interface RegExp {}
interface String { charAt: any; }
interface Array<T> { length: number; [n: number]: T; }
/a/lib/tsc.js -w -p /a/b/tsconfig.json
Output::
>> Screen clear
[12:00:25 AM] Starting compilation in watch mode...
error TS2688: Cannot find type definition file for 'node'.
[12:00:28 AM] 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 files::
/a/lib/lib.d.ts
/a/b/app.ts
No cached semantic diagnostics in the builder::
WatchedFiles::
/a/b/tsconfig.json:
{"fileName":"/a/b/tsconfig.json","pollingInterval":250}
/a/b/app.ts:
{"fileName":"/a/b/app.ts","pollingInterval":250}
/a/lib/lib.d.ts:
{"fileName":"/a/lib/lib.d.ts","pollingInterval":250}
FsWatches::
FsWatchesRecursive::
/a/b:
{"directoryName":"/a/b","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
exitCode:: ExitStatus.undefined
//// [/a/b/app.js]
var x = 1;

View file

@ -114,6 +114,8 @@ WatchedFiles::
FsWatches::
FsWatchesRecursive::
/a/b/node_modules:
{"directoryName":"/a/b/node_modules","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}
/a/b/node_modules/@types:
{"directoryName":"/a/b/node_modules/@types","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}}

View file

@ -0,0 +1,19 @@
error TS2688: Cannot find type definition file for 'phaser'.
/a.ts(1,1): error TS2304: Cannot find name 'a'.
!!! error TS2688: Cannot find type definition file for 'phaser'.
==== /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" }

View file

@ -0,0 +1,17 @@
//// [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;

View file

@ -0,0 +1,4 @@
=== /a.ts ===
a;
No type information for this code.
No type information for this code.

View file

@ -0,0 +1,9 @@
[
"======== Resolving type reference directive 'phaser', containing file '/__inferred type names__.ts', root directory '/typings'. ========",
"Resolving with primary search path '/typings'.",
"Loading module as file / folder, candidate module location '/typings/phaser', target file type 'DtsOnly'.",
"File '/typings/phaser.d.ts' does not exist.",
"Directory '/typings/phaser' does not exist, skipping all lookups in it.",
"Resolving type reference directive for program with typeRoots, skipping lookup in 'node_modules' folder.",
"======== Type reference directive 'phaser' was not resolved. ========"
]

View file

@ -0,0 +1,4 @@
=== /a.ts ===
a;
>a : any

View file

@ -0,0 +1,11 @@
//// [tests/cases/compiler/typeReferenceDirectiveWithTypeAsFile.ts] ////
//// [phaser.d.ts]
declare const a: number;
//// [a.ts]
a;
//// [a.js]
a;

View file

@ -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))

View file

@ -0,0 +1,9 @@
[
"======== 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'.",
"Loading module as file / folder, candidate module location '/node_modules/phaser/types/phaser', target file type 'DtsOnly'.",
"File '/node_modules/phaser/types/phaser.d.ts' exist - 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. ========"
]

View file

@ -0,0 +1,8 @@
=== /a.ts ===
a;
>a : number
=== /node_modules/phaser/types/phaser.d.ts ===
declare const a: number;
>a : number

View file

@ -1,12 +1,16 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",

View file

@ -1,6 +1,8 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
@ -14,6 +16,8 @@
"======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",

View file

@ -6,6 +6,8 @@
"======== 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'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",

View file

@ -11,6 +11,8 @@
"======== 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'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
@ -20,6 +22,8 @@
"======== Module name './main' was successfully resolved to '/main.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",

View file

@ -1,6 +1,8 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
@ -14,6 +16,8 @@
"======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",

View file

@ -1,6 +1,8 @@
[
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",

View file

@ -1,12 +1,16 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",

View file

@ -1,12 +1,16 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",

View file

@ -1,6 +1,8 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
@ -14,6 +16,8 @@
"======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",

View file

@ -1,12 +1,16 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",

View file

@ -1,12 +1,16 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",

View file

@ -6,6 +6,8 @@
"======== 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'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",

View file

@ -11,6 +11,8 @@
"======== 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'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",
@ -20,6 +22,8 @@
"======== Module name './main' was successfully resolved to '/main.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'.",
"Loading module as file / folder, candidate module location '/types/lib', target file type 'DtsOnly'.",
"File '/types/lib.d.ts' does not exist.",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'.",

View file

@ -58,18 +58,27 @@
"======== 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'.",
"Loading module as file / folder, candidate module location '/foo/node_modules/@types/grumpy', target file type 'DtsOnly'.",
"File '/foo/node_modules/@types/grumpy.d.ts' does not exist.",
"File '/foo/node_modules/@types/grumpy/package.json' does not exist.",
"File '/foo/node_modules/@types/grumpy/index.d.ts' exist - 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'.",
"Loading module as file / folder, candidate module location '/foo/node_modules/@types/sneezy', target file type 'DtsOnly'.",
"File '/foo/node_modules/@types/sneezy.d.ts' does not exist.",
"File '/foo/node_modules/@types/sneezy/package.json' does not exist.",
"File '/foo/node_modules/@types/sneezy/index.d.ts' exist - 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'.",
"Loading module as file / folder, candidate module location '/foo/node_modules/@types/dopey', target file type 'DtsOnly'.",
"File '/foo/node_modules/@types/dopey.d.ts' does not exist.",
"Directory '/foo/node_modules/@types/dopey' does not exist, skipping all lookups in it.",
"Loading module as file / folder, candidate module location '/node_modules/@types/dopey', target file type 'DtsOnly'.",
"File '/node_modules/@types/dopey.d.ts' does not exist.",
"File '/node_modules/@types/dopey/package.json' does not exist.",
"File '/node_modules/@types/dopey/index.d.ts' exist - 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'.",

View file

@ -14,6 +14,8 @@
"======== 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'.",
"Loading module as file / folder, candidate module location '/node_modules/@types/foo', target file type 'DtsOnly'.",
"File '/node_modules/@types/foo.d.ts' does not exist.",
"File '/node_modules/@types/foo/package.json' does not exist.",
"File '/node_modules/@types/foo/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/foo/index.d.ts', result '/node_modules/@types/foo/index.d.ts'.",

View file

@ -1,12 +1,16 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'.",
"Loading module as file / folder, candidate module location '/node_modules/@types/jquery', target file type 'DtsOnly'.",
"File '/node_modules/@types/jquery.d.ts' does not exist.",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/jquery/index.d.ts', result '/node_modules/@types/jquery/index.d.ts'.",
"======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'.",
"Loading module as file / folder, candidate module location '/node_modules/@types/jquery', target file type 'DtsOnly'.",
"File '/node_modules/@types/jquery.d.ts' does not exist.",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/jquery/index.d.ts', result '/node_modules/@types/jquery/index.d.ts'.",

View file

@ -1,12 +1,16 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'.",
"Loading module as file / folder, candidate module location '/node_modules/@types/jquery', target file type 'DtsOnly'.",
"File '/node_modules/@types/jquery.d.ts' does not exist.",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/jquery/index.d.ts', result '/node_modules/@types/jquery/index.d.ts'.",
"======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'.",
"Loading module as file / folder, candidate module location '/node_modules/@types/jquery', target file type 'DtsOnly'.",
"File '/node_modules/@types/jquery.d.ts' does not exist.",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/jquery/index.d.ts', result '/node_modules/@types/jquery/index.d.ts'.",

View file

@ -65,6 +65,8 @@
"======== Module name 'mquery' was successfully resolved to '/node_modules/@types/mquery/mquery/index.tsx'. ========",
"======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'.",
"Loading module as file / folder, candidate module location '/node_modules/@types/jquery', target file type 'DtsOnly'.",
"File '/node_modules/@types/jquery.d.ts' does not exist.",
"Found 'package.json' at '/node_modules/@types/jquery/package.json'.",
"'package.json' does not have a 'typesVersions' field.",
"'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.",
@ -73,6 +75,8 @@
"======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/jquery.d.ts', primary: true. ========",
"======== Resolving type reference directive 'kquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'.",
"Loading module as file / folder, candidate module location '/node_modules/@types/kquery', target file type 'DtsOnly'.",
"File '/node_modules/@types/kquery.d.ts' does not exist.",
"Found 'package.json' at '/node_modules/@types/kquery/package.json'.",
"'package.json' does not have a 'typesVersions' field.",
"'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.",
@ -85,6 +89,8 @@
"======== Type reference directive 'kquery' was successfully resolved to '/node_modules/@types/kquery/kquery.d.ts', primary: true. ========",
"======== Resolving type reference directive 'lquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'.",
"Loading module as file / folder, candidate module location '/node_modules/@types/lquery', target file type 'DtsOnly'.",
"File '/node_modules/@types/lquery.d.ts' does not exist.",
"Found 'package.json' at '/node_modules/@types/lquery/package.json'.",
"'package.json' does not have a 'typesVersions' field.",
"'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.",
@ -95,6 +101,8 @@
"======== Type reference directive 'lquery' was successfully resolved to '/node_modules/@types/lquery/lquery.ts', primary: true. ========",
"======== Resolving type reference directive 'mquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'.",
"Loading module as file / folder, candidate module location '/node_modules/@types/mquery', target file type 'DtsOnly'.",
"File '/node_modules/@types/mquery.d.ts' does not exist.",
"Found 'package.json' at '/node_modules/@types/mquery/package.json'.",
"'package.json' does not have a 'typesVersions' field.",
"'package.json' has 'typings' field 'mquery' that references '/node_modules/@types/mquery/mquery'.",

View file

@ -41,6 +41,8 @@
"======== Module name 'a' was successfully resolved to '/node_modules/@types/a/index.d.ts'. ========",
"======== Resolving type reference directive 'a', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'.",
"Loading module as file / folder, candidate module location '/node_modules/@types/a', target file type 'DtsOnly'.",
"File '/node_modules/@types/a.d.ts' does not exist.",
"File '/node_modules/@types/a/package.json' does not exist.",
"File '/node_modules/@types/a/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/a/index.d.ts', result '/node_modules/@types/a/index.d.ts'.",

View file

@ -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";

View file

@ -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";

View file

@ -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;

View file

@ -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;