mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-23 07:07:09 -05:00
Use realpathSync.native on case-insensitive file systems (#44966)
* Make getSourceOfProjectReferenceRedirect take a Path * Add useCaseSensitiveFileNames to ModuleResolutionHost ...so that path comparisons can use it during module resolution. * Re-enable realpathSync.native for case-insensitive file systems
This commit is contained in:
@@ -280,6 +280,11 @@ namespace ts {
|
||||
}
|
||||
const nodeModulesAtTypes = combinePaths("node_modules", "@types");
|
||||
|
||||
function arePathsEqual(path1: string, path2: string, host: ModuleResolutionHost): boolean {
|
||||
const useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames;
|
||||
return comparePaths(path1, path2, !useCaseSensitiveFileNames) === Comparison.EqualTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
|
||||
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
|
||||
@@ -343,7 +348,7 @@ namespace ts {
|
||||
resolvedTypeReferenceDirective = {
|
||||
primary,
|
||||
resolvedFileName,
|
||||
originalPath: fileName === resolvedFileName ? undefined : fileName,
|
||||
originalPath: arePathsEqual(fileName, resolvedFileName, host) ? undefined : fileName,
|
||||
packageId,
|
||||
isExternalLibraryImport: pathContainsNodeModules(fileName),
|
||||
};
|
||||
@@ -1122,7 +1127,7 @@ namespace ts {
|
||||
let resolvedValue = resolved.value;
|
||||
if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) {
|
||||
const path = realPath(resolvedValue.path, host, traceEnabled);
|
||||
const originalPath = path === resolvedValue.path ? undefined : resolvedValue.path;
|
||||
const originalPath = arePathsEqual(path, resolvedValue.path, host) ? undefined : resolvedValue.path;
|
||||
resolvedValue = { ...resolvedValue, path, originalPath };
|
||||
}
|
||||
// For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files.
|
||||
|
||||
Reference in New Issue
Block a user