Merge branch 'master' into requireJson

This commit is contained in:
Sheetal Nandi
2018-04-13 15:26:16 -07:00
400 changed files with 11097 additions and 11468 deletions

View File

@@ -1,6 +1,3 @@
/// <reference path="core.ts" />
/// <reference path="diagnosticInformationMap.generated.ts" />
namespace ts {
/* @internal */
export function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void;
@@ -118,7 +115,8 @@ namespace ts {
}
}
function readJson(path: string, host: ModuleResolutionHost): PackageJson {
/* @internal */
export function readJson(path: string, host: { readFile(fileName: string): string | undefined }): object {
try {
const jsonText = host.readFile(path);
return jsonText ? JSON.parse(jsonText) : {};
@@ -301,7 +299,7 @@ namespace ts {
// `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types.
// See `createNotNeededPackageJSON` in the types-publisher` repo.
// tslint:disable-next-line:no-null-keyword
const isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null;
const isNotNeededPackage = host.fileExists(packageJsonPath) && (readJson(packageJsonPath, host) as PackageJson).typings === null;
if (!isNotNeededPackage) {
// Return just the type directive names
result.push(getBaseFileName(normalized));
@@ -995,7 +993,7 @@ namespace ts {
const directoryExists = !onlyRecordFailures && directoryProbablyExists(nodeModuleDirectory, host);
const packageJsonPath = pathToPackageJson(nodeModuleDirectory);
if (directoryExists && host.fileExists(packageJsonPath)) {
const packageJsonContent = readJson(packageJsonPath, host);
const packageJsonContent = readJson(packageJsonPath, host) as PackageJson;
if (subModuleName === "") { // looking up the root - need to handle types/typings/main redirects for subModuleName
const path = tryReadPackageJsonFields(/*readTypes*/ true, packageJsonContent, nodeModuleDirectory, state);
if (typeof path === "string") {
@@ -1046,7 +1044,7 @@ namespace ts {
const onlyRecordFailures = !directoryProbablyExists(getDirectoryPath(file), state.host);
const fromFile = tryFile(file, failedLookupLocations, onlyRecordFailures, state);
if (fromFile) {
const resolved = fromFile && resolvedIfExtensionMatches(extensions, fromFile);
const resolved = resolvedIfExtensionMatches(extensions, fromFile);
if (resolved) {
return resolved;
}