From b2720adbc31bf7692db3a163f1f87be24af0eca6 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 21 May 2018 10:56:24 -0700 Subject: [PATCH] Lint --- src/compiler/tsbuild.ts | 51 ++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index e0929e355b2..40c23dc300d 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -1,6 +1,6 @@ namespace ts { - const MinimumDate = new Date(-8640000000000000); - const MaximumDate = new Date(8640000000000000); + const minimumDate = new Date(-8640000000000000); + const maximumDate = new Date(8640000000000000); /** * A BuildContext tracks what's going on during the course of a build. @@ -133,7 +133,8 @@ namespace ts { * A FileMap maintains a normalized-key to value relationship */ function createFileMap(): FileMap { - const lookup: { [key: string]: T } = Object.create(null); + // tslint:disable-next-line:no-null-keyword + const lookup: { [key: string]: T } = Object.create(/*prototype*/ null); return { setValue, @@ -141,7 +142,7 @@ namespace ts { getValueOrUndefined, getValueOrDefault, tryGetValue - } + }; function setValue(fileName: string, value: T) { lookup[normalizePath(fileName)] = value; @@ -151,7 +152,8 @@ namespace ts { const f = normalizePath(fileName); if (f in lookup) { return lookup[f]; - } else { + } + else { throw new Error(`No value corresponding to ${fileName} exists in this map`); } } @@ -160,7 +162,8 @@ namespace ts { const f = normalizePath(fileName); if (f in lookup) { return lookup[f]; - } else { + } + else { return undefined; } } @@ -169,7 +172,8 @@ namespace ts { const f = normalizePath(fileName); if (f in lookup) { return lookup[f]; - } else { + } + else { return defaultValue; } } @@ -178,26 +182,27 @@ namespace ts { const f = normalizePath(fileName); if (f in lookup) { return [true as true, lookup[f]]; - } else { + } + else { return [false as false, undefined]; } } } - function getOutputDeclarationFileName(inputFileName: string, configFile: ts.ParsedCommandLine) { - const relativePath = getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath), inputFileName, true); + function getOutputDeclarationFileName(inputFileName: string, configFile: ParsedCommandLine) { + const relativePath = getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath), inputFileName, /*ignoreCase*/ true); const outputPath = resolvePath(configFile.options.declarationDir || configFile.options.outDir || getDirectoryPath(configFile.options.configFilePath), relativePath); return changeExtension(outputPath, ".d.ts"); } - function getOutputJavaScriptFileName(inputFileName: string, configFile: ts.ParsedCommandLine) { + function getOutputJavaScriptFileName(inputFileName: string, configFile: ParsedCommandLine) { // TODO handle JSX: Preserve - const relativePath = getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath), inputFileName, true); + const relativePath = getRelativePathFromDirectory(rootDirOfOptions(configFile.options, configFile.options.configFilePath), inputFileName, /*ignoreCase*/ true); const outputPath = resolvePath(configFile.options.outDir || getDirectoryPath(configFile.options.configFilePath), relativePath); return changeExtension(outputPath, (fileExtensionIs(inputFileName, ".tsx") && configFile.options.jsx === JsxEmit.Preserve) ? ".jsx" : ".js"); } - function getOutputFileNames(inputFileName: string, configFile: ts.ParsedCommandLine): ReadonlyArray { + function getOutputFileNames(inputFileName: string, configFile: ParsedCommandLine): ReadonlyArray { if (configFile.options.outFile) { return emptyArray; } @@ -213,7 +218,7 @@ namespace ts { return outputs; } - function getOutFileOutputs(project: ts.ParsedCommandLine): ReadonlyArray { + function getOutFileOutputs(project: ParsedCommandLine): ReadonlyArray { Debug.assert(!!project.options.outFile, "outFile must be set"); const outputs: string[] = []; outputs.push(project.options.outFile); @@ -226,7 +231,7 @@ namespace ts { return outputs; } - function rootDirOfOptions(opts: ts.CompilerOptions, configFileName: string) { + function rootDirOfOptions(opts: CompilerOptions, configFileName: string) { return opts.rootDir || path.dirname(configFileName); } @@ -245,7 +250,7 @@ namespace ts { return { parseConfigFile - } + }; } function newer(date1: Date, date2: Date): Date { @@ -270,8 +275,8 @@ namespace ts { } function getUpToDateStatusWorker(project: ParsedCommandLine, context: BuildContext): UpToDateStatus { - let newestInputFileName: string = '???'; - let newestInputFileTime = MinimumDate; + let newestInputFileName: string = undefined!; + let newestInputFileTime = minimumDate; // Get timestamps of input files for (const inputFile of project.fileNames) { if (!host.fileExists(inputFile)) { @@ -301,10 +306,10 @@ namespace ts { } // Now see if all outputs are newer than the newest input - let oldestOutputFileName: string = "n/a"; - let oldestOutputFileTime: Date = MinimumDate; - let newestOutputFileTime: Date = MaximumDate; - let newestDeclarationFileContentChangedTime: Date = MinimumDate; + let oldestOutputFileName: string = undefined!; + let oldestOutputFileTime: Date = minimumDate; + let newestOutputFileTime: Date = maximumDate; + let newestDeclarationFileContentChangedTime: Date = minimumDate; for (const output of outputs) { // Output is missing if (!host.fileExists(output)) { @@ -356,7 +361,7 @@ namespace ts { return { type: UpToDateStatusType.UpstreamOutOfDate, upstreamProjectName: ref.path - } + }; } // If the upstream project's newest file is older than our oldest output, we