Merge pull request #16023 from Microsoft/mrjs

In path mapping module resolution, try loading from path as directory even if it has an extension
This commit is contained in:
Andy
2017-05-23 09:58:06 -07:00
committed by GitHub
7 changed files with 115 additions and 4 deletions

View File

@@ -653,11 +653,13 @@ namespace ts {
if (state.traceEnabled) {
trace(state.host, Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path);
}
// A path mapping may have a ".ts" extension; in contrast to an import, which should omit it.
const tsExtension = tryGetExtensionFromPath(candidate);
if (tsExtension !== undefined) {
// A path mapping may have an extension, in contrast to an import, which should omit it.
const extension = tryGetExtensionFromPath(candidate);
if (extension !== undefined) {
const path = tryFile(candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state);
return path && { path, extension: tsExtension };
if (path !== undefined) {
return { path, extension };
}
}
return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(getDirectoryPath(candidate), state.host), state);