Allow "typings" in a package.json to be missing its extension (but also allow it to have an extension)

This commit is contained in:
Andy Hanson
2016-08-22 13:03:49 -07:00
parent bb6c6fd003
commit 92eb8df68c
6 changed files with 220 additions and 2 deletions

View File

@@ -720,8 +720,9 @@ namespace ts {
const typesFile = tryReadTypesSection(packageJsonPath, candidate, state);
if (typesFile) {
const onlyRecordFailures = !directoryProbablyExists(getDirectoryPath(typesFile), state.host);
// The package.json "typings" property must specify the file with extension, so just try that exact filename.
const result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures, state);
// A package.json "typings" may specify an exact filename, or may choose to omit an extension.
const result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures, state) ||
tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures, state);
if (result) {
return result;
}