Merge pull request #12020 from Microsoft/symlink3

Only resolve symlinks in `node_modules`
This commit is contained in:
Andy
2016-11-11 13:52:00 -08:00
committed by GitHub
67 changed files with 707 additions and 129 deletions

View File

@@ -193,63 +193,66 @@ namespace ts {
const failedLookupLocations: string[] = [];
// Check primary library paths
if (typeRoots && typeRoots.length) {
let resolved = primaryLookup();
let primary = true;
if (!resolved) {
resolved = secondaryLookup();
primary = false;
}
let resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined;
if (resolved) {
resolved = realpath(resolved, host, traceEnabled);
if (traceEnabled) {
trace(host, Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
trace(host, Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary);
}
for (const typeRoot of typeRoots) {
const candidate = combinePaths(typeRoot, typeReferenceDirectiveName);
const candidateDirectory = getDirectoryPath(candidate);
resolvedTypeReferenceDirective = { primary, resolvedFileName: resolved };
}
const resolved = resolvedTypeScriptOnly(
loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations,
!directoryProbablyExists(candidateDirectory, host), moduleResolutionState));
return { resolvedTypeReferenceDirective, failedLookupLocations };
if (resolved) {
if (traceEnabled) {
trace(host, Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, true);
}
return {
resolvedTypeReferenceDirective: { primary: true, resolvedFileName: resolved },
failedLookupLocations
};
function primaryLookup(): string | undefined {
// Check primary library paths
if (typeRoots && typeRoots.length) {
if (traceEnabled) {
trace(host, Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
}
return forEach(typeRoots, typeRoot => {
const candidate = combinePaths(typeRoot, typeReferenceDirectiveName);
const candidateDirectory = getDirectoryPath(candidate);
return resolvedTypeScriptOnly(
loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, failedLookupLocations,
!directoryProbablyExists(candidateDirectory, host), moduleResolutionState));
});
}
else {
if (traceEnabled) {
trace(host, Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths);
}
}
}
else {
if (traceEnabled) {
trace(host, Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths);
}
}
let resolvedFile: string;
const initialLocationForSecondaryLookup = containingFile && getDirectoryPath(containingFile);
function secondaryLookup(): string | undefined {
let resolvedFile: string;
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);
}
resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState));
if (traceEnabled) {
if (resolvedFile) {
trace(host, Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFile, false);
if (initialLocationForSecondaryLookup !== undefined) {
// check secondary locations
if (traceEnabled) {
trace(host, Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
}
else {
resolvedFile = resolvedTypeScriptOnly(loadModuleFromNodeModules(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, failedLookupLocations, moduleResolutionState));
if (!resolvedFile && traceEnabled) {
trace(host, Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
}
return resolvedFile;
}
else {
if (traceEnabled) {
trace(host, Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder);
}
}
}
else {
if (traceEnabled) {
trace(host, Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder);
}
}
return {
resolvedTypeReferenceDirective: resolvedFile ? { primary: false, resolvedFileName: resolvedFile } : undefined,
failedLookupLocations
};
}
/**
@@ -546,7 +549,7 @@ namespace ts {
const result = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
if (result) {
const { resolved, isExternalLibraryImport } = result;
return createResolvedModuleWithFailedLookupLocations(resolved && resolvedWithRealpath(resolved, host, traceEnabled), isExternalLibraryImport, failedLookupLocations);
return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations);
}
return { resolvedModule: undefined, failedLookupLocations };
@@ -561,7 +564,8 @@ namespace ts {
trace(host, Diagnostics.Loading_module_0_from_node_modules_folder, moduleName);
}
const resolved = loadModuleFromNodeModules(extensions, moduleName, containingDirectory, failedLookupLocations, state);
return resolved && { resolved, isExternalLibraryImport: true };
// For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files.
return resolved && { resolved: { path: realpath(resolved.path, host, traceEnabled), extension: resolved.extension }, isExternalLibraryImport: true };
}
else {
const candidate = normalizePath(combinePaths(containingDirectory, moduleName));
@@ -571,16 +575,16 @@ namespace ts {
}
}
function resolvedWithRealpath(resolved: Resolved, host: ModuleResolutionHost, traceEnabled: boolean): Resolved {
function realpath(path: string, host: ModuleResolutionHost, traceEnabled: boolean): string {
if (!host.realpath) {
return resolved;
return path;
}
const real = normalizePath(host.realpath(resolved.path));
const real = normalizePath(host.realpath(path));
if (traceEnabled) {
trace(host, Diagnostics.Resolving_real_path_for_0_result_1, resolved.path, real);
trace(host, Diagnostics.Resolving_real_path_for_0_result_1, path, real);
}
return { path: real, extension: resolved.extension };
return real;
}
function nodeLoadModuleByRelativeName(extensions: Extensions, candidate: string, failedLookupLocations: Push<string>, onlyRecordFailures: boolean, state: ModuleResolutionState): Resolved | undefined {

View File

@@ -1404,14 +1404,17 @@ namespace ts {
// If we already resolved to this file, it must have been a secondary reference. Check file contents
// for sameness and possibly issue an error
if (previousResolution) {
const otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName);
if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) {
fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd,
Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict,
typeReferenceDirective,
resolvedTypeReferenceDirective.resolvedFileName,
previousResolution.resolvedFileName
));
// Don't bother reading the file again if it's the same file.
if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) {
const otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName);
if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) {
fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd,
Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict,
typeReferenceDirective,
resolvedTypeReferenceDirective.resolvedFileName,
previousResolution.resolvedFileName
));
}
}
// don't overwrite previous resolution result
saveResolution = false;

View File

@@ -958,28 +958,38 @@ namespace Harness {
// Local get canonical file name function, that depends on passed in parameter for useCaseSensitiveFileNames
const getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
const realPathMap: ts.FileMap<string> = ts.createFileMap<string>();
const fileMap: ts.FileMap<() => ts.SourceFile> = ts.createFileMap<() => ts.SourceFile>();
/** Maps a symlink name to a realpath. Used only for exposing `realpath`. */
const realPathMap = ts.createFileMap<string>();
/**
* Maps a file name to a source file.
* This will have a different SourceFile for every symlink pointing to that file;
* if the program resolves realpaths then symlink entries will be ignored.
*/
const fileMap = ts.createFileMap<ts.SourceFile>();
for (const file of inputFiles) {
if (file.content !== undefined) {
const fileName = ts.normalizePath(file.unitName);
const path = ts.toPath(file.unitName, currentDirectory, getCanonicalFileName);
if (file.fileOptions && file.fileOptions["symlink"]) {
const link = file.fileOptions["symlink"];
const linkPath = ts.toPath(link, currentDirectory, getCanonicalFileName);
realPathMap.set(linkPath, fileName);
fileMap.set(path, (): ts.SourceFile => { throw new Error("Symlinks should always be resolved to a realpath first"); });
const links = file.fileOptions["symlink"].split(",");
for (const link of links) {
const linkPath = ts.toPath(link, currentDirectory, getCanonicalFileName);
realPathMap.set(linkPath, fileName);
// Create a different SourceFile for every symlink.
const sourceFile = createSourceFileAndAssertInvariants(linkPath, file.content, scriptTarget);
fileMap.set(linkPath, sourceFile);
}
}
const sourceFile = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget);
fileMap.set(path, () => sourceFile);
fileMap.set(path, sourceFile);
}
}
function getSourceFile(fileName: string) {
fileName = ts.normalizePath(fileName);
const path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
if (fileMap.contains(path)) {
return fileMap.get(path)();
const fromFileMap = fileMap.get(toPath(fileName));
if (fromFileMap) {
return fromFileMap;
}
else if (fileName === fourslashFileName) {
const tsFn = "tests/cases/fourslash/" + fourslashFileName;
@@ -998,6 +1008,9 @@ namespace Harness {
newLineKind === ts.NewLineKind.LineFeed ? lineFeed :
Harness.IO.newLine();
function toPath(fileName: string): ts.Path {
return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
}
return {
getCurrentDirectory: () => currentDirectory,
@@ -1007,24 +1020,26 @@ namespace Harness {
getCanonicalFileName,
useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
getNewLine: () => newLine,
fileExists: fileName => {
const path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
return fileMap.contains(path) || (realPathMap && realPathMap.contains(path));
},
fileExists: fileName => fileMap.contains(toPath(fileName)),
readFile: (fileName: string): string => {
return fileMap.get(ts.toPath(fileName, currentDirectory, getCanonicalFileName))().getText();
const file = fileMap.get(toPath(fileName));
if (ts.endsWith(fileName, "json")) {
// strip comments
return file.getText();
}
return file.text;
},
realpath: (fileName: string): ts.Path => {
const path = toPath(fileName);
return (realPathMap.get(path) as ts.Path) || path;
},
realpath: realPathMap && ((f: string) => {
const path = ts.toPath(f, currentDirectory, getCanonicalFileName);
return realPathMap.get(path) || path;
}),
directoryExists: dir => {
let path = ts.toPath(dir, currentDirectory, getCanonicalFileName);
// Strip trailing /, which may exist if the path is a drive root
if (path[path.length - 1] === "/") {
path = <ts.Path>path.substr(0, path.length - 1);
}
return mapHasFileInDirectory(path, fileMap) || mapHasFileInDirectory(path, realPathMap);
return mapHasFileInDirectory(path, fileMap);
},
getDirectories: d => {
const path = ts.toPath(d, currentDirectory, getCanonicalFileName);

View File

@@ -3,26 +3,22 @@
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module as file / folder, candidate module location '/a'.",
"File '/a.ts' exist - use it as a name resolution result.",
"Resolving real path for '/a.ts', result '/a.ts'",
"======== Module name '.' was successfully resolved to '/a.ts'. ========",
"======== Resolving module './' from '/a/test.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module as file / folder, candidate module location '/a/'.",
"File '/a/package.json' does not exist.",
"File '/a/index.ts' exist - use it as a name resolution result.",
"Resolving real path for '/a/index.ts', result '/a/index.ts'",
"======== Module name './' was successfully resolved to '/a/index.ts'. ========",
"======== Resolving module '..' from '/a/b/test.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module as file / folder, candidate module location '/a'.",
"File '/a.ts' exist - use it as a name resolution result.",
"Resolving real path for '/a.ts', result '/a.ts'",
"======== Module name '..' was successfully resolved to '/a.ts'. ========",
"======== Resolving module '../' from '/a/b/test.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module as file / folder, candidate module location '/a/'.",
"File '/a/package.json' does not exist.",
"File '/a/index.ts' exist - use it as a name resolution result.",
"Resolving real path for '/a/index.ts', result '/a/index.ts'",
"======== Module name '../' was successfully resolved to '/a/index.ts'. ========"
]

View File

@@ -3,10 +3,12 @@
"Resolving with primary search path 'types'",
"File 'types/jquery/package.json' does not exist.",
"File 'types/jquery/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to 'types/jquery/index.d.ts', primary: true. ========",
"Resolving real path for 'types/jquery/index.d.ts', result '/src/types/jquery/index.d.ts'",
"======== Type reference directive 'jquery' was successfully resolved to '/src/types/jquery/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'jquery', containing file '/src/__inferred type names__.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'",
"File 'types/jquery/package.json' does not exist.",
"File 'types/jquery/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to 'types/jquery/index.d.ts', primary: true. ========"
"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. ========"
]

View File

@@ -4,11 +4,13 @@
"Found 'package.json' at './types/jquery/package.json'.",
"'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.",
"File 'types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to 'types/jquery/jquery.d.ts', primary: true. ========",
"Resolving real path for 'types/jquery/jquery.d.ts', result '/foo/types/jquery/jquery.d.ts'",
"======== Type reference directive 'jquery' was successfully resolved to '/foo/types/jquery/jquery.d.ts', primary: true. ========",
"======== Resolving type reference directive 'jquery', containing file '/foo/__inferred type names__.ts', root directory './types'. ========",
"Resolving with primary search path './types'",
"Found 'package.json' at './types/jquery/package.json'.",
"'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.",
"File 'types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to 'types/jquery/jquery.d.ts', primary: true. ========"
"Resolving real path for 'types/jquery/jquery.d.ts', result '/foo/types/jquery/jquery.d.ts'",
"======== Type reference directive 'jquery' was successfully resolved to '/foo/types/jquery/jquery.d.ts', primary: true. ========"
]

View File

@@ -12,5 +12,6 @@
"Found 'package.json' at '/a/node_modules/jquery/package.json'.",
"'package.json' has 'typings' field 'jquery.d.ts' that references '/a/node_modules/jquery/jquery.d.ts'.",
"File '/a/node_modules/jquery/jquery.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/a/node_modules/jquery/jquery.d.ts', result '/a/node_modules/jquery/jquery.d.ts'",
"======== Type reference directive 'jquery' was successfully resolved to '/a/node_modules/jquery/jquery.d.ts', primary: false. ========"
]

View File

@@ -12,5 +12,6 @@
"Found 'package.json' at '/a/node_modules/jquery/package.json'.",
"'package.json' has 'types' field 'dist/jquery.d.ts' that references '/a/node_modules/jquery/dist/jquery.d.ts'.",
"File '/a/node_modules/jquery/dist/jquery.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/a/node_modules/jquery/dist/jquery.d.ts', result '/a/node_modules/jquery/dist/jquery.d.ts'",
"======== Type reference directive 'jquery' was successfully resolved to '/a/node_modules/jquery/dist/jquery.d.ts', primary: false. ========"
]

View File

@@ -3,5 +3,6 @@
"Resolving with primary search path '/a/types'",
"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'",
"======== Type reference directive 'jquery' was successfully resolved to '/a/types/jquery/index.d.ts', primary: true. ========"
]

View File

@@ -3,5 +3,6 @@
"Resolving with primary search path '/a/types'",
"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'",
"======== Type reference directive 'jquery' was successfully resolved to '/a/types/jquery/index.d.ts', primary: true. ========"
]

View File

@@ -3,5 +3,6 @@
"Resolving with primary search path 'types'",
"File 'types/jquery/package.json' does not exist.",
"File 'types/jquery/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to 'types/jquery/index.d.ts', primary: true. ========"
"Resolving real path for 'types/jquery/index.d.ts', result '/a/types/jquery/index.d.ts'",
"======== Type reference directive 'jquery' was successfully resolved to '/a/types/jquery/index.d.ts', primary: true. ========"
]

View File

@@ -4,11 +4,13 @@
"Found 'package.json' at '/types/jquery/package.json'.",
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
"File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/jquery/jquery.d.ts', result '/types/jquery/jquery.d.ts'",
"======== Type reference directive 'jquery' was successfully resolved to '/types/jquery/jquery.d.ts', primary: true. ========",
"======== Resolving type reference directive 'jquery', containing file 'test/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"Found 'package.json' at '/types/jquery/package.json'.",
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
"File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/jquery/jquery.d.ts', result '/types/jquery/jquery.d.ts'",
"======== Type reference directive 'jquery' was successfully resolved to '/types/jquery/jquery.d.ts', primary: true. ========"
]

View File

@@ -5,5 +5,6 @@
"File '/src/node_modules/jquery.d.ts' does not exist.",
"File '/src/node_modules/jquery/package.json' does not exist.",
"File '/src/node_modules/jquery/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/node_modules/jquery/index.d.ts', result '/src/node_modules/jquery/index.d.ts'",
"======== Type reference directive 'jquery' was successfully resolved to '/src/node_modules/jquery/index.d.ts', primary: false. ========"
]

View File

@@ -13,6 +13,7 @@
"File '/node_modules/foo.d.ts' does not exist.",
"File '/node_modules/foo/package.json' does not exist.",
"File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/foo/index.d.ts', result '/node_modules/foo/index.d.ts'",
"======== 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'",
@@ -28,6 +29,7 @@
"File '/node_modules/bar.d.ts' does not exist.",
"File '/node_modules/bar/package.json' does not exist.",
"File '/node_modules/bar/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/bar/index.d.ts', result '/node_modules/bar/index.d.ts'",
"======== 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'",
@@ -37,6 +39,7 @@
"File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.",
"File '/node_modules/foo/node_modules/alpha/package.json' does not exist.",
"File '/node_modules/foo/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/foo/node_modules/alpha/index.d.ts', result '/node_modules/foo/node_modules/alpha/index.d.ts'",
"======== 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'",
@@ -46,5 +49,6 @@
"File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.",
"File '/node_modules/bar/node_modules/alpha/package.json' does not exist.",
"File '/node_modules/bar/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/bar/node_modules/alpha/index.d.ts', result '/node_modules/bar/node_modules/alpha/index.d.ts'",
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/bar/node_modules/alpha/index.d.ts', primary: false. ========"
]

View File

@@ -13,6 +13,7 @@
"File '/node_modules/foo.d.ts' does not exist.",
"File '/node_modules/foo/package.json' does not exist.",
"File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/foo/index.d.ts', result '/node_modules/foo/index.d.ts'",
"======== 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'",
@@ -28,6 +29,7 @@
"File '/node_modules/bar.d.ts' does not exist.",
"File '/node_modules/bar/package.json' does not exist.",
"File '/node_modules/bar/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/bar/index.d.ts', result '/node_modules/bar/index.d.ts'",
"======== 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'",
@@ -37,6 +39,7 @@
"File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.",
"File '/node_modules/foo/node_modules/alpha/package.json' does not exist.",
"File '/node_modules/foo/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/foo/node_modules/alpha/index.d.ts', result '/node_modules/foo/node_modules/alpha/index.d.ts'",
"======== 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'",
@@ -46,5 +49,6 @@
"File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.",
"File '/node_modules/bar/node_modules/alpha/package.json' does not exist.",
"File '/node_modules/bar/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/bar/node_modules/alpha/index.d.ts', result '/node_modules/bar/node_modules/alpha/index.d.ts'",
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/bar/node_modules/alpha/index.d.ts', primary: false. ========"
]

View File

@@ -3,10 +3,12 @@
"Resolving with primary search path '/node_modules/@types'",
"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'",
"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. ========"
]

View File

@@ -5,5 +5,6 @@
"File '/src/node_modules/jquery.d.ts' does not exist.",
"File '/src/node_modules/jquery/package.json' does not exist.",
"File '/src/node_modules/jquery/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/node_modules/jquery/index.d.ts', result '/src/node_modules/jquery/index.d.ts'",
"======== Type reference directive 'jquery' was successfully resolved to '/src/node_modules/jquery/index.d.ts', primary: false. ========"
]

View File

@@ -3,30 +3,36 @@
"Resolving with primary search path '/test/types'",
"File '/test/types/alpha/package.json' does not exist.",
"File '/test/types/alpha/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/test/types/alpha/index.d.ts', result '/test/types/alpha/index.d.ts'",
"======== Type reference directive 'alpha' was successfully resolved to '/test/types/alpha/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'beta', containing file '/test/foo.ts', root directory '/test/types'. ========",
"Resolving with primary search path '/test/types'",
"File '/test/types/beta/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'",
"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'",
"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'",
"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'",
"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. ========"
]

View File

@@ -3,7 +3,6 @@
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/src/a'.",
"File '/src/a.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/a.ts', result '/src/a.ts'",
"======== Module name './a' was successfully resolved to '/src/a.ts'. ========",
"======== Resolving module './a.js' from '/src/d.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@@ -13,7 +12,6 @@
"File '/src/a.js.d.ts' does not exist.",
"File name '/src/a.js' has a '.js' extension - stripping it",
"File '/src/a.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/a.ts', result '/src/a.ts'",
"======== Module name './a.js' was successfully resolved to '/src/a.ts'. ========",
"======== Resolving module './jquery.js' from '/src/jquery_user_1.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@@ -25,6 +23,5 @@
"File '/src/jquery.ts' does not exist.",
"File '/src/jquery.tsx' does not exist.",
"File '/src/jquery.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/jquery.d.ts', result '/src/jquery.d.ts'",
"======== Module name './jquery.js' was successfully resolved to '/src/jquery.d.ts'. ========"
]

View File

@@ -4,7 +4,6 @@
"Loading module as file / folder, candidate module location '/tsx'.",
"File '/tsx.ts' does not exist.",
"File '/tsx.tsx' exist - use it as a name resolution result.",
"Resolving real path for '/tsx.tsx', result '/tsx.tsx'",
"======== Module name './tsx' was successfully resolved to '/tsx.tsx'. ========",
"======== Resolving module './jsx' from '/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@@ -19,7 +18,6 @@
"Loading module as file / folder, candidate module location '/jsx'.",
"File '/jsx.js' does not exist.",
"File '/jsx.jsx' exist - use it as a name resolution result.",
"Resolving real path for '/jsx.jsx', result '/jsx.jsx'",
"======== Module name './jsx' was successfully resolved to '/jsx.jsx'. ========",
"======== Resolving module './js' from '/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@@ -33,6 +31,5 @@
"File '/js/index.d.ts' does not exist.",
"Loading module as file / folder, candidate module location '/js'.",
"File '/js.js' exist - use it as a name resolution result.",
"Resolving real path for '/js.js', result '/js.js'",
"======== Module name './js' was successfully resolved to '/js.js'. ========"
]

View File

@@ -12,6 +12,5 @@
"Loading module as file / folder, candidate module location '/jsx'.",
"File '/jsx.js' does not exist.",
"File '/jsx.jsx' exist - use it as a name resolution result.",
"Resolving real path for '/jsx.jsx', result '/jsx.jsx'",
"======== Module name './jsx' was successfully resolved to '/jsx.jsx'. ========"
]

View File

@@ -12,6 +12,5 @@
"Loading module as file / folder, candidate module location '/jsx'.",
"File '/jsx.js' does not exist.",
"File '/jsx.jsx' exist - use it as a name resolution result.",
"Resolving real path for '/jsx.jsx', result '/jsx.jsx'",
"======== Module name './jsx' was successfully resolved to '/jsx.jsx'. ========"
]

View File

@@ -7,6 +7,5 @@
"File '/b.d.ts' does not exist.",
"File '/b/package.json' does not exist.",
"File '/b/index.ts' exist - use it as a name resolution result.",
"Resolving real path for '/b/index.ts', result '/b/index.ts'",
"======== Module name './b' was successfully resolved to '/b/index.ts'. ========"
]

View File

@@ -1,6 +1,8 @@
//// [tests/cases/compiler/moduleResolutionWithSymlinks.ts] ////
//// [index.ts]
// When symlinked files are in node_modules, they are resolved with realpath;
// so a linked file does not create a duplicate SourceFile of the real one.
export class MyClass { private x: number; }
@@ -15,9 +17,31 @@ import { MyClass2 } from "./library-b";
let x: MyClass;
let y: MyClass2;
x = y;
y = x;
y = x;
/*
# To reproduce in a real project:
mkdir src; cd src
mkdir library-a
echo 'export class MyClass { private x: number; }' > library-a/index.ts
mkdir library-b; cd library-b
echo 'import {MyClass} from "library-a"; export { MyClass as MyClass2 }' > index.ts
mkdir node_modules; cd node_modules
ln -s ../../library-a library-a # Linux
# Windows: open command prompt as administrator and run: mklink /D library-a ..\..\library-a
cd ../.. # back to src
echo 'import { MyClass } from "./library-a"; import { MyClass2 } from "./library-b"; let x: MyClass; let y: MyClass2; x = y; y = x;' > app.ts
tsc app.ts # Should write to library-a/index.js, library-b/index.js, and app.js
*/
//// [index.js]
//// [/src/library-a/index.js]
// When symlinked files are in node_modules, they are resolved with realpath;
// so a linked file does not create a duplicate SourceFile of the real one.
"use strict";
var MyClass = (function () {
function MyClass() {
@@ -25,13 +49,31 @@ var MyClass = (function () {
return MyClass;
}());
exports.MyClass = MyClass;
//// [index.js]
//// [/src/library-b/index.js]
"use strict";
var library_a_1 = require("library-a");
exports.MyClass2 = library_a_1.MyClass;
//// [app.js]
//// [/src/app.js]
"use strict";
var x;
var y;
x = y;
y = x;
/*
# To reproduce in a real project:
mkdir src; cd src
mkdir library-a
echo 'export class MyClass { private x: number; }' > library-a/index.ts
mkdir library-b; cd library-b
echo 'import {MyClass} from "library-a"; export { MyClass as MyClass2 }' > index.ts
mkdir node_modules; cd node_modules
ln -s ../../library-a library-a # Linux
# Windows: open command prompt as administrator and run: mklink /D library-a ..\..\library-a
cd ../.. # back to src
echo 'import { MyClass } from "./library-a"; import { MyClass2 } from "./library-b"; let x: MyClass; let y: MyClass2; x = y; y = x;' > app.ts
tsc app.ts # Should write to library-a/index.js, library-b/index.js, and app.js
*/

View File

@@ -21,11 +21,32 @@ y = x;
>y : Symbol(y, Decl(app.ts, 4, 3))
>x : Symbol(x, Decl(app.ts, 3, 3))
/*
# To reproduce in a real project:
mkdir src; cd src
mkdir library-a
echo 'export class MyClass { private x: number; }' > library-a/index.ts
mkdir library-b; cd library-b
echo 'import {MyClass} from "library-a"; export { MyClass as MyClass2 }' > index.ts
mkdir node_modules; cd node_modules
ln -s ../../library-a library-a # Linux
# Windows: open command prompt as administrator and run: mklink /D library-a ..\..\library-a
cd ../.. # back to src
echo 'import { MyClass } from "./library-a"; import { MyClass2 } from "./library-b"; let x: MyClass; let y: MyClass2; x = y; y = x;' > app.ts
tsc app.ts # Should write to library-a/index.js, library-b/index.js, and app.js
*/
=== /src/library-a/index.ts ===
// When symlinked files are in node_modules, they are resolved with realpath;
// so a linked file does not create a duplicate SourceFile of the real one.
export class MyClass { private x: number; }
>MyClass : Symbol(MyClass, Decl(index.ts, 0, 0))
>x : Symbol(MyClass.x, Decl(index.ts, 1, 22))
>x : Symbol(MyClass.x, Decl(index.ts, 3, 22))
=== /src/library-b/index.ts ===
import {MyClass} from "library-a";

View File

@@ -7,7 +7,6 @@
"File '/src/library-a.d.ts' does not exist.",
"File '/src/library-a/package.json' does not exist.",
"File '/src/library-a/index.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/library-a/index.ts', result '/src/library-a/index.ts'",
"======== Module name './library-a' was successfully resolved to '/src/library-a/index.ts'. ========",
"======== Resolving module './library-b' from '/src/app.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@@ -17,7 +16,6 @@
"File '/src/library-b.d.ts' does not exist.",
"File '/src/library-b/package.json' does not exist.",
"File '/src/library-b/index.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/library-b/index.ts', result '/src/library-b/index.ts'",
"======== Module name './library-b' was successfully resolved to '/src/library-b/index.ts'. ========",
"======== Resolving module 'library-a' from '/src/library-b/index.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",

View File

@@ -23,7 +23,28 @@ y = x;
>y : MyClass
>x : MyClass
/*
# To reproduce in a real project:
mkdir src; cd src
mkdir library-a
echo 'export class MyClass { private x: number; }' > library-a/index.ts
mkdir library-b; cd library-b
echo 'import {MyClass} from "library-a"; export { MyClass as MyClass2 }' > index.ts
mkdir node_modules; cd node_modules
ln -s ../../library-a library-a # Linux
# Windows: open command prompt as administrator and run: mklink /D library-a ..\..\library-a
cd ../.. # back to src
echo 'import { MyClass } from "./library-a"; import { MyClass2 } from "./library-b"; let x: MyClass; let y: MyClass2; x = y; y = x;' > app.ts
tsc app.ts # Should write to library-a/index.js, library-b/index.js, and app.js
*/
=== /src/library-a/index.ts ===
// When symlinked files are in node_modules, they are resolved with realpath;
// so a linked file does not create a duplicate SourceFile of the real one.
export class MyClass { private x: number; }
>MyClass : MyClass

View File

@@ -0,0 +1,32 @@
//// [tests/cases/compiler/moduleResolutionWithSymlinks_notInNodeModules.ts] ////
//// [abc.ts]
// When symlinked files are not in node_modules, realpath is not used.
// A symlink file acts like the real thing. So, 2 symlinks act like 2 different files.
// See GH#10364.
export const x = 0;
//// [app.ts]
import { x } from "./shared/abc";
import { x as x2 } from "./shared2/abc";
x + x2;
//// [/src/bin/shared/abc.js]
// When symlinked files are not in node_modules, realpath is not used.
// A symlink file acts like the real thing. So, 2 symlinks act like 2 different files.
// See GH#10364.
"use strict";
exports.x = 0;
//// [/src/bin/shared2/abc.js]
// When symlinked files are not in node_modules, realpath is not used.
// A symlink file acts like the real thing. So, 2 symlinks act like 2 different files.
// See GH#10364.
"use strict";
exports.x = 0;
//// [/src/bin/app.js]
"use strict";
var abc_1 = require("./shared/abc");
var abc_2 = require("./shared2/abc");
abc_1.x + abc_2.x;

View File

@@ -0,0 +1,12 @@
=== /src/app.ts ===
import { x } from "./shared/abc";
>x : Symbol(x, Decl(app.ts, 0, 8))
import { x as x2 } from "./shared2/abc";
>x : Symbol(x2, Decl(app.ts, 1, 8))
>x2 : Symbol(x2, Decl(app.ts, 1, 8))
x + x2;
>x : Symbol(x, Decl(app.ts, 0, 8))
>x2 : Symbol(x2, Decl(app.ts, 1, 8))

View File

@@ -0,0 +1,12 @@
[
"======== Resolving module './shared/abc' from '/src/app.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/src/shared/abc'.",
"File '/src/shared/abc.ts' exist - use it as a name resolution result.",
"======== Module name './shared/abc' was successfully resolved to '/src/shared/abc.ts'. ========",
"======== Resolving module './shared2/abc' from '/src/app.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/src/shared2/abc'.",
"File '/src/shared2/abc.ts' exist - use it as a name resolution result.",
"======== Module name './shared2/abc' was successfully resolved to '/src/shared2/abc.ts'. ========"
]

View File

@@ -0,0 +1,13 @@
=== /src/app.ts ===
import { x } from "./shared/abc";
>x : 0
import { x as x2 } from "./shared2/abc";
>x : 0
>x2 : 0
x + x2;
>x + x2 : number
>x : 0
>x2 : 0

View File

@@ -0,0 +1,22 @@
//// [tests/cases/compiler/moduleResolutionWithSymlinks_referenceTypes.ts] ////
//// [index.d.ts]
// Symlinks are always resolved for type reference directives.
// NOTE: This test would still compile without errors even if they were not,
// because `processTypeReferenceDirective` also checks for textual equivalence of file contents.
// But the `moduleResolutionWithSymlinks_referenceTypes.trace.json` shows the difference.
declare class MyClass { private x: number; }
//// [index.d.ts]
/// <reference types="library-a" />
//// [app.ts]
/// <reference types="library-a" />
/// <reference types="library-b" />
//// [/app.js]
/// <reference types="library-a" />
/// <reference types="library-b" />

View File

@@ -0,0 +1,19 @@
=== /app.ts ===
/// <reference types="library-a" />
No type information for this code./// <reference types="library-b" />
No type information for this code.
No type information for this code.=== /node_modules/@types/library-a/index.d.ts ===
// Symlinks are always resolved for type reference directives.
// NOTE: This test would still compile without errors even if they were not,
// because `processTypeReferenceDirective` also checks for textual equivalence of file contents.
// But the `moduleResolutionWithSymlinks_referenceTypes.trace.json` shows the difference.
declare class MyClass { private x: number; }
>MyClass : Symbol(MyClass, Decl(index.d.ts, 0, 0))
>x : Symbol(MyClass.x, Decl(index.d.ts, 6, 23))
=== /node_modules/@types/library-b/index.d.ts ===
/// <reference types="library-a" />
No type information for this code.
No type information for this code.

View File

@@ -0,0 +1,35 @@
[
"======== Resolving type reference directive 'library-a', containing file '/app.ts', root directory ''. ========",
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/'",
"File '/node_modules/library-a.d.ts' does not exist.",
"File '/node_modules/library-a/package.json' does not exist.",
"File '/node_modules/library-a/index.d.ts' does not exist.",
"File '/node_modules/@types/library-a.d.ts' does not exist.",
"File '/node_modules/@types/library-a/package.json' does not exist.",
"File '/node_modules/@types/library-a/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/library-a/index.d.ts', result '/node_modules/@types/library-a/index.d.ts'",
"======== Type reference directive 'library-a' was successfully resolved to '/node_modules/@types/library-a/index.d.ts', primary: false. ========",
"======== Resolving type reference directive 'library-b', containing file '/app.ts', root directory ''. ========",
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/'",
"File '/node_modules/library-b.d.ts' does not exist.",
"File '/node_modules/library-b/package.json' does not exist.",
"File '/node_modules/library-b/index.d.ts' does not exist.",
"File '/node_modules/@types/library-b.d.ts' does not exist.",
"File '/node_modules/@types/library-b/package.json' does not exist.",
"File '/node_modules/@types/library-b/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/library-b/index.d.ts', result '/node_modules/@types/library-b/index.d.ts'",
"======== Type reference directive 'library-b' was successfully resolved to '/node_modules/@types/library-b/index.d.ts', primary: false. ========",
"======== Resolving type reference directive 'library-a', containing file '/node_modules/@types/library-b/index.d.ts', root directory ''. ========",
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/node_modules/@types/library-b'",
"File '/node_modules/@types/library-b/node_modules/library-a.d.ts' does not exist.",
"File '/node_modules/@types/library-b/node_modules/library-a/package.json' does not exist.",
"File '/node_modules/@types/library-b/node_modules/library-a/index.d.ts' does not exist.",
"File '/node_modules/@types/library-b/node_modules/@types/library-a.d.ts' does not exist.",
"File '/node_modules/@types/library-b/node_modules/@types/library-a/package.json' does not exist.",
"File '/node_modules/@types/library-b/node_modules/@types/library-a/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/library-b/node_modules/@types/library-a/index.d.ts', result '/node_modules/@types/library-a/index.d.ts'",
"======== Type reference directive 'library-a' was successfully resolved to '/node_modules/@types/library-a/index.d.ts', primary: false. ========"
]

View File

@@ -0,0 +1,19 @@
=== /app.ts ===
/// <reference types="library-a" />
No type information for this code./// <reference types="library-b" />
No type information for this code.
No type information for this code.=== /node_modules/@types/library-a/index.d.ts ===
// Symlinks are always resolved for type reference directives.
// NOTE: This test would still compile without errors even if they were not,
// because `processTypeReferenceDirective` also checks for textual equivalence of file contents.
// But the `moduleResolutionWithSymlinks_referenceTypes.trace.json` shows the difference.
declare class MyClass { private x: number; }
>MyClass : MyClass
>x : number
=== /node_modules/@types/library-b/index.d.ts ===
/// <reference types="library-a" />
No type information for this code.
No type information for this code.

View File

@@ -0,0 +1,40 @@
//// [tests/cases/compiler/moduleResolutionWithSymlinks_withOutDir.ts] ////
//// [index.ts]
// Same as moduleResolutionWithSymlinks.ts, but with outDir
export class MyClass { private x: number; }
//// [index.ts]
import {MyClass} from "library-a";
export { MyClass as MyClass2 }
//// [app.ts]
import { MyClass } from "./library-a";
import { MyClass2 } from "./library-b";
let x: MyClass;
let y: MyClass2;
x = y;
y = x;
//// [/src/bin/library-a/index.js]
// Same as moduleResolutionWithSymlinks.ts, but with outDir
"use strict";
var MyClass = (function () {
function MyClass() {
}
return MyClass;
}());
exports.MyClass = MyClass;
//// [/src/bin/library-b/index.js]
"use strict";
var library_a_1 = require("library-a");
exports.MyClass2 = library_a_1.MyClass;
//// [/src/bin/app.js]
"use strict";
var x;
var y;
x = y;
y = x;

View File

@@ -0,0 +1,38 @@
=== /src/app.ts ===
import { MyClass } from "./library-a";
>MyClass : Symbol(MyClass, Decl(app.ts, 0, 8))
import { MyClass2 } from "./library-b";
>MyClass2 : Symbol(MyClass2, Decl(app.ts, 1, 8))
let x: MyClass;
>x : Symbol(x, Decl(app.ts, 3, 3))
>MyClass : Symbol(MyClass, Decl(app.ts, 0, 8))
let y: MyClass2;
>y : Symbol(y, Decl(app.ts, 4, 3))
>MyClass2 : Symbol(MyClass2, Decl(app.ts, 1, 8))
x = y;
>x : Symbol(x, Decl(app.ts, 3, 3))
>y : Symbol(y, Decl(app.ts, 4, 3))
y = x;
>y : Symbol(y, Decl(app.ts, 4, 3))
>x : Symbol(x, Decl(app.ts, 3, 3))
=== /src/library-a/index.ts ===
// Same as moduleResolutionWithSymlinks.ts, but with outDir
export class MyClass { private x: number; }
>MyClass : Symbol(MyClass, Decl(index.ts, 0, 0))
>x : Symbol(MyClass.x, Decl(index.ts, 2, 22))
=== /src/library-b/index.ts ===
import {MyClass} from "library-a";
>MyClass : Symbol(MyClass, Decl(index.ts, 0, 8))
export { MyClass as MyClass2 }
>MyClass : Symbol(MyClass2, Decl(index.ts, 1, 8))
>MyClass2 : Symbol(MyClass2, Decl(index.ts, 1, 8))

View File

@@ -0,0 +1,30 @@
[
"======== Resolving module './library-a' from '/src/app.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/src/library-a'.",
"File '/src/library-a.ts' does not exist.",
"File '/src/library-a.tsx' does not exist.",
"File '/src/library-a.d.ts' does not exist.",
"File '/src/library-a/package.json' does not exist.",
"File '/src/library-a/index.ts' exist - use it as a name resolution result.",
"======== Module name './library-a' was successfully resolved to '/src/library-a/index.ts'. ========",
"======== Resolving module './library-b' from '/src/app.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/src/library-b'.",
"File '/src/library-b.ts' does not exist.",
"File '/src/library-b.tsx' does not exist.",
"File '/src/library-b.d.ts' does not exist.",
"File '/src/library-b/package.json' does not exist.",
"File '/src/library-b/index.ts' exist - use it as a name resolution result.",
"======== Module name './library-b' was successfully resolved to '/src/library-b/index.ts'. ========",
"======== Resolving module 'library-a' from '/src/library-b/index.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'library-a' from 'node_modules' folder.",
"File '/src/library-b/node_modules/library-a.ts' does not exist.",
"File '/src/library-b/node_modules/library-a.tsx' does not exist.",
"File '/src/library-b/node_modules/library-a.d.ts' does not exist.",
"File '/src/library-b/node_modules/library-a/package.json' does not exist.",
"File '/src/library-b/node_modules/library-a/index.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/library-b/node_modules/library-a/index.ts', result '/src/library-a/index.ts'",
"======== Module name 'library-a' was successfully resolved to '/src/library-a/index.ts'. ========"
]

View File

@@ -0,0 +1,40 @@
=== /src/app.ts ===
import { MyClass } from "./library-a";
>MyClass : typeof MyClass
import { MyClass2 } from "./library-b";
>MyClass2 : typeof MyClass
let x: MyClass;
>x : MyClass
>MyClass : MyClass
let y: MyClass2;
>y : MyClass
>MyClass2 : MyClass
x = y;
>x = y : MyClass
>x : MyClass
>y : MyClass
y = x;
>y = x : MyClass
>y : MyClass
>x : MyClass
=== /src/library-a/index.ts ===
// Same as moduleResolutionWithSymlinks.ts, but with outDir
export class MyClass { private x: number; }
>MyClass : MyClass
>x : number
=== /src/library-b/index.ts ===
import {MyClass} from "library-a";
>MyClass : typeof MyClass
export { MyClass as MyClass2 }
>MyClass : typeof MyClass
>MyClass2 : typeof MyClass

View File

@@ -5,13 +5,11 @@
"Resolving module name 'folder2/file2' relative to base url 'c:/root' - 'c:/root/folder2/file2'.",
"Loading module as file / folder, candidate module location 'c:/root/folder2/file2'.",
"File 'c:/root/folder2/file2.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/folder2/file2.ts', result 'c:/root/folder2/file2.ts'",
"======== Module name 'folder2/file2' was successfully resolved to 'c:/root/folder2/file2.ts'. ========",
"======== Resolving module './file3' from 'c:/root/folder2/file2.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module as file / folder, candidate module location 'c:/root/folder2/file3'.",
"File 'c:/root/folder2/file3.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/folder2/file3.ts', result 'c:/root/folder2/file3.ts'",
"======== Module name './file3' was successfully resolved to 'c:/root/folder2/file3.ts'. ========",
"======== Resolving module 'file4' from 'c:/root/folder2/file2.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",

View File

@@ -5,13 +5,11 @@
"Resolving module name 'folder2/file2' relative to base url 'c:/root' - 'c:/root/folder2/file2'.",
"Loading module as file / folder, candidate module location 'c:/root/folder2/file2'.",
"File 'c:/root/folder2/file2.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/folder2/file2.ts', result 'c:/root/folder2/file2.ts'",
"======== Module name 'folder2/file2' was successfully resolved to 'c:/root/folder2/file2.ts'. ========",
"======== Resolving module './file3' from 'c:/root/folder2/file2.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module as file / folder, candidate module location 'c:/root/folder2/file3'.",
"File 'c:/root/folder2/file3.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/folder2/file3.ts', result 'c:/root/folder2/file3.ts'",
"======== Module name './file3' was successfully resolved to 'c:/root/folder2/file3.ts'. ========",
"======== Resolving module 'file4' from 'c:/root/folder2/file2.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",

View File

@@ -7,7 +7,6 @@
"Trying substitution '*', candidate module location: 'folder2/file1'.",
"Loading module as file / folder, candidate module location 'c:/root/folder2/file1'.",
"File 'c:/root/folder2/file1.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/folder2/file1.ts', result 'c:/root/folder2/file1.ts'",
"======== Module name 'folder2/file1' was successfully resolved to 'c:/root/folder2/file1.ts'. ========",
"======== Resolving module 'folder3/file2' from 'c:/root/folder1/file1.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@@ -26,7 +25,6 @@
"Trying substitution 'generated/*', candidate module location: 'generated/folder3/file2'.",
"Loading module as file / folder, candidate module location 'c:/root/generated/folder3/file2'.",
"File 'c:/root/generated/folder3/file2.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/generated/folder3/file2.ts', result 'c:/root/generated/folder3/file2.ts'",
"======== Module name 'folder3/file2' was successfully resolved to 'c:/root/generated/folder3/file2.ts'. ========",
"======== Resolving module 'components/file3' from 'c:/root/folder1/file1.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@@ -42,7 +40,6 @@
"File 'c:/root/shared/components/file3/index.ts' does not exist.",
"File 'c:/root/shared/components/file3/index.tsx' does not exist.",
"File 'c:/root/shared/components/file3/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/shared/components/file3/index.d.ts', result 'c:/root/shared/components/file3/index.d.ts'",
"======== Module name 'components/file3' was successfully resolved to 'c:/root/shared/components/file3/index.d.ts'. ========",
"======== Resolving module 'file4' from 'c:/root/folder1/file1.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",

View File

@@ -18,7 +18,6 @@
"Loading 'project/file3' from the root dir 'c:/root/generated/src', candidate location 'c:/root/generated/src/project/file3'",
"Loading module as file / folder, candidate module location 'c:/root/generated/src/project/file3'.",
"File 'c:/root/generated/src/project/file3.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/generated/src/project/file3.ts', result 'c:/root/generated/src/project/file3.ts'",
"======== Module name './project/file3' was successfully resolved to 'c:/root/generated/src/project/file3.ts'. ========",
"======== Resolving module '../file2' from 'c:/root/generated/src/project/file3.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@@ -45,6 +44,5 @@
"File 'c:/root/src/file2/index.ts' does not exist.",
"File 'c:/root/src/file2/index.tsx' does not exist.",
"File 'c:/root/src/file2/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/src/file2/index.d.ts', result 'c:/root/src/file2/index.d.ts'",
"======== Module name '../file2' was successfully resolved to 'c:/root/src/file2/index.d.ts'. ========"
]

View File

@@ -18,7 +18,6 @@
"Loading 'project/file2' from the root dir 'c:/root/generated/src', candidate location 'c:/root/generated/src/project/file2'",
"Loading module as file / folder, candidate module location 'c:/root/generated/src/project/file2'.",
"File 'c:/root/generated/src/project/file2.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/generated/src/project/file2.ts', result 'c:/root/generated/src/project/file2.ts'",
"======== Module name './project/file2' was successfully resolved to 'c:/root/generated/src/project/file2.ts'. ========",
"======== Resolving module 'module3' from 'c:/root/src/file1.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@@ -92,7 +91,6 @@
"File 'c:/shared/module1/index.ts' does not exist.",
"File 'c:/shared/module1/index.tsx' does not exist.",
"File 'c:/shared/module1/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/shared/module1/index.d.ts', result 'c:/shared/module1/index.d.ts'",
"======== Module name 'module1' was successfully resolved to 'c:/shared/module1/index.d.ts'. ========",
"======== Resolving module 'templates/module2' from 'c:/root/generated/src/project/file2.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@@ -102,7 +100,6 @@
"Trying substitution 'generated/src/templates/*', candidate module location: 'generated/src/templates/module2'.",
"Loading module as file / folder, candidate module location 'c:/root/generated/src/templates/module2'.",
"File 'c:/root/generated/src/templates/module2.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/generated/src/templates/module2.ts', result 'c:/root/generated/src/templates/module2.ts'",
"======== Module name 'templates/module2' was successfully resolved to 'c:/root/generated/src/templates/module2.ts'. ========",
"======== Resolving module '../file3' from 'c:/root/generated/src/project/file2.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@@ -129,6 +126,5 @@
"File 'c:/root/src/file3/index.ts' does not exist.",
"File 'c:/root/src/file3/index.tsx' does not exist.",
"File 'c:/root/src/file3/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/src/file3/index.d.ts', result 'c:/root/src/file3/index.d.ts'",
"======== Module name '../file3' was successfully resolved to 'c:/root/src/file3/index.d.ts'. ========"
]

View File

@@ -3,10 +3,12 @@
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
]

View File

@@ -3,6 +3,7 @@
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving module './ref' from '/app.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@@ -10,11 +11,11 @@
"File '/ref.ts' does not exist.",
"File '/ref.tsx' does not exist.",
"File '/ref.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/ref.d.ts', result '/ref.d.ts'",
"======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
]

View File

@@ -3,11 +3,11 @@
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/mod1'.",
"File '/mod1.ts' exist - use it as a name resolution result.",
"Resolving real path for '/mod1.ts', result '/mod1.ts'",
"======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/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. ========"
]

View File

@@ -3,28 +3,27 @@
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/main'.",
"File '/main.ts' exist - use it as a name resolution result.",
"Resolving real path for '/main.ts', result '/main.ts'",
"======== Module name './main' was successfully resolved to '/main.ts'. ========",
"======== Resolving module './mod1' from '/mod2.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/mod1'.",
"File '/mod1.ts' exist - use it as a name resolution result.",
"Resolving real path for '/mod1.ts', result '/mod1.ts'",
"======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/mod1.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/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 module './main' from '/mod1.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/main'.",
"File '/main.ts' exist - use it as a name resolution result.",
"Resolving real path for '/main.ts', result '/main.ts'",
"======== Module name './main' was successfully resolved to '/main.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
]

View File

@@ -3,6 +3,7 @@
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving module './ref' from '/app.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@@ -10,11 +11,11 @@
"File '/ref.ts' does not exist.",
"File '/ref.tsx' does not exist.",
"File '/ref.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/ref.d.ts', result '/ref.d.ts'",
"======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
]

View File

@@ -3,5 +3,6 @@
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
]

View File

@@ -3,10 +3,12 @@
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
]

View File

@@ -3,10 +3,12 @@
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
]

View File

@@ -3,6 +3,7 @@
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving module './ref' from '/app.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@@ -10,11 +11,11 @@
"File '/ref.ts' does not exist.",
"File '/ref.tsx' does not exist.",
"File '/ref.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/ref.d.ts', result '/ref.d.ts'",
"======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
]

View File

@@ -3,10 +3,12 @@
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
]

View File

@@ -3,10 +3,12 @@
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
]

View File

@@ -3,11 +3,11 @@
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/mod1'.",
"File '/mod1.ts' exist - use it as a name resolution result.",
"Resolving real path for '/mod1.ts', result '/mod1.ts'",
"======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/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. ========"
]

View File

@@ -3,28 +3,27 @@
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/main'.",
"File '/main.ts' exist - use it as a name resolution result.",
"Resolving real path for '/main.ts', result '/main.ts'",
"======== Module name './main' was successfully resolved to '/main.ts'. ========",
"======== Resolving module './mod1' from '/mod2.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/mod1'.",
"File '/mod1.ts' exist - use it as a name resolution result.",
"Resolving real path for '/mod1.ts', result '/mod1.ts'",
"======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/mod1.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/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 module './main' from '/mod1.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/main'.",
"File '/main.ts' exist - use it as a name resolution result.",
"Resolving real path for '/main.ts', result '/main.ts'",
"======== Module name './main' was successfully resolved to '/main.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/types/lib/index.d.ts', result '/types/lib/index.d.ts'",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
]

View File

@@ -153,11 +153,13 @@
"Resolving with primary search path '/foo/node_modules/@types, /node_modules/@types'",
"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 '/src/__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'",
"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 '/src/__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'",
@@ -165,5 +167,6 @@
"File '/foo/node_modules/@types/dopey/index.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'",
"======== Type reference directive 'dopey' was successfully resolved to '/node_modules/@types/dopey/index.d.ts', primary: true. ========"
]

View File

@@ -38,5 +38,6 @@
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/foo/package.json' does not exist.",
"File '/node_modules/@types/foo/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/foo/index.d.ts', result '/node_modules/@types/foo/index.d.ts'",
"======== Type reference directive 'foo' was successfully resolved to '/node_modules/@types/foo/index.d.ts', primary: true. ========"
]

View File

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

View File

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

View File

@@ -56,6 +56,7 @@
"Found 'package.json' at '/node_modules/@types/jquery/package.json'.",
"'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.",
"File '/node_modules/@types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/jquery/jquery.d.ts', result '/node_modules/@types/jquery/jquery.d.ts'",
"======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/jquery.d.ts', primary: true. ========",
"======== Resolving type reference directive 'kquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
@@ -65,6 +66,7 @@
"File '/node_modules/@types/kquery/kquery.ts' does not exist.",
"File '/node_modules/@types/kquery/kquery.tsx' does not exist.",
"File '/node_modules/@types/kquery/kquery.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/kquery/kquery.d.ts', result '/node_modules/@types/kquery/kquery.d.ts'",
"======== 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'",
@@ -72,5 +74,6 @@
"'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.",
"File '/node_modules/@types/lquery/lquery' does not exist.",
"File '/node_modules/@types/lquery/lquery.ts' exist - use it as a name resolution result.",
"Resolving real path for '/node_modules/@types/lquery/lquery.ts', result '/node_modules/@types/lquery/lquery.ts'",
"======== Type reference directive 'lquery' was successfully resolved to '/node_modules/@types/lquery/lquery.ts', primary: true. ========"
]

View File

@@ -51,5 +51,6 @@
"Resolving with primary search path '/node_modules/@types'",
"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'",
"======== Type reference directive 'a' was successfully resolved to '/node_modules/@types/a/index.d.ts', primary: true. ========"
]

View File

@@ -1,6 +1,8 @@
// @module: commonjs
// When symlinked files are in node_modules, they are resolved with realpath;
// so a linked file does not create a duplicate SourceFile of the real one.
// @noImplicitReferences: true
// @traceResolution: true
// @fullEmitPaths: true
// @filename: /src/library-a/index.ts
// @symlink: /src/library-b/node_modules/library-a/index.ts
@@ -17,4 +19,23 @@ import { MyClass2 } from "./library-b";
let x: MyClass;
let y: MyClass2;
x = y;
y = x;
y = x;
/*
# To reproduce in a real project:
mkdir src; cd src
mkdir library-a
echo 'export class MyClass { private x: number; }' > library-a/index.ts
mkdir library-b; cd library-b
echo 'import {MyClass} from "library-a"; export { MyClass as MyClass2 }' > index.ts
mkdir node_modules; cd node_modules
ln -s ../../library-a library-a # Linux
# Windows: open command prompt as administrator and run: mklink /D library-a ..\..\library-a
cd ../.. # back to src
echo 'import { MyClass } from "./library-a"; import { MyClass2 } from "./library-b"; let x: MyClass; let y: MyClass2; x = y; y = x;' > app.ts
tsc app.ts # Should write to library-a/index.js, library-b/index.js, and app.js
*/

View File

@@ -0,0 +1,38 @@
// When symlinked files are not in node_modules, realpath is not used.
// A symlink file acts like the real thing. So, 2 symlinks act like 2 different files.
// See GH#10364.
// @noImplicitReferences: true
// @traceResolution: true
// @fullEmitPaths: true
// @filename: /shared/abc.ts
// @symlink: /src/shared/abc.ts,/src/shared2/abc.ts
export const x = 0;
// @filename: /src/app.ts
import { x } from "./shared/abc";
import { x as x2 } from "./shared2/abc";
x + x2;
// @filename: /src/tsconfig.json
{
"compilerOptions": {
"outDir": "bin"
}
}
/*
# To reproduce in a real project:
mkdir shared
echo 'export const x = 0;' > shared/abc.ts
mkdir src; cd src
echo 'import { x } from "./shared/abc"; import { x as x2 } from "./shared2/abc"; x + x2;' > app.ts
ln -s ../shared ./shared; ln -s ../shared ./shared2 # Linux
# Windows: Open command prompt as administrator and run: `mklink /D shared ..\shared; mklink /D shared2 ..\shared`
echo '{ "compilerOptions": { "outDir": "bin" } }' > tsconfig.json
tsc # Should create `bin/app.js`, `bin/shared/abc.js`, and `bin/shared2/abc.js`
*/

View File

@@ -0,0 +1,54 @@
// Symlinks are always resolved for type reference directives.
// NOTE: This test would still compile without errors even if they were not,
// because `processTypeReferenceDirective` also checks for textual equivalence of file contents.
// But the `moduleResolutionWithSymlinks_referenceTypes.trace.json` shows the difference.
// @noImplicitReferences: true
// @traceResolution: true
// @fullEmitPaths: true
// @filename: /node_modules/@types/library-a/index.d.ts
// @symlink: /node_modules/@types/library-b/node_modules/@types/library-a/index.d.ts
declare class MyClass { private x: number; }
// @filename: /node_modules/@types/library-b/index.d.ts
/// <reference types="library-a" />
// @filename: /app.ts
/// <reference types="library-a" />
/// <reference types="library-b" />
// @filename: tsconfig.json
{
"compilerOptions": {
// If this is its default of node_modules/@types,
// node_modules/@types/library-a will be looked up be fore node_modules/@types/library-b/node_modules/@types/library-a
"typeRoots": []
}
}
/*
# To reproduce in a real project:
echo '/// <reference types="library-a" />' > app.ts
echo '/// <reference types="library-b" />' >> app.ts
mkdir node_modules/@types
cd mode_modules/@types
mkdir library-a
echo 'declare class MyClass { private x: number; }' > library-a/index.d.ts
mkdir library-b
cd library-b
echo '/// <reference types="library-a" />' > index.d.ts
mkdir node_modules
cd node_modules
ln -s ../../library-a ./library-a
# Windows: Open command prompt as administrator and run: `mklink /D library-a ..\..\library-a`
cd ../../.. # back to root
tsc app.ts # Should create `app.js`
*/

View File

@@ -0,0 +1,22 @@
// Same as moduleResolutionWithSymlinks.ts, but with outDir
// @noImplicitReferences: true
// @traceResolution: true
// @fullEmitPaths: true
// @outDir: /src/bin
// @filename: /src/library-a/index.ts
// @symlink: /src/library-b/node_modules/library-a/index.ts
export class MyClass { private x: number; }
// @filename: /src/library-b/index.ts
import {MyClass} from "library-a";
export { MyClass as MyClass2 }
// @filename: /src/app.ts
import { MyClass } from "./library-a";
import { MyClass2 } from "./library-b";
let x: MyClass;
let y: MyClass2;
x = y;
y = x;