mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-17 00:34:47 -05:00
An import ending in "/" is always an import of a directory.
This commit is contained in:
@@ -829,8 +829,20 @@ namespace ts {
|
||||
export function normalizePath(path: string): string {
|
||||
path = normalizeSlashes(path);
|
||||
const rootLength = getRootLength(path);
|
||||
const root = path.substr(0, rootLength);
|
||||
const normalized = getNormalizedParts(path, rootLength);
|
||||
return path.substr(0, rootLength) + normalized.join(directorySeparator);
|
||||
if (normalized.length) {
|
||||
const joinedParts = root + normalized.join(directorySeparator);
|
||||
return isPathToDirectory(path) ? joinedParts + "/" : joinedParts;
|
||||
}
|
||||
else {
|
||||
return root;
|
||||
}
|
||||
}
|
||||
|
||||
/** A path ending with '/' refers to a directory only, never a file. */
|
||||
export function isPathToDirectory(path: string): boolean {
|
||||
return path.charCodeAt(path.length - 1) === CharacterCodes.slash;
|
||||
}
|
||||
|
||||
export function getDirectoryPath(path: Path): Path;
|
||||
|
||||
@@ -646,7 +646,7 @@ namespace ts {
|
||||
trace(state.host, Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate);
|
||||
}
|
||||
|
||||
const resolvedFileName = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state);
|
||||
const resolvedFileName = !isPathToDirectory(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state);
|
||||
|
||||
return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user