Skip to content

Commit 8a93b48

Browse files
committed
fix lint: prefer const
1 parent 51fc4f2 commit 8a93b48

28 files changed

Lines changed: 2959 additions & 2962 deletions

src/compiler/binder.ts

Lines changed: 41 additions & 41 deletions
Large diffs are not rendered by default.

src/compiler/checker.ts

Lines changed: 1227 additions & 1227 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ namespace ts {
295295
return optionNameMapCache;
296296
}
297297

298-
let optionNameMap: Map<CommandLineOption> = {};
299-
let shortOptionNames: Map<string> = {};
298+
const optionNameMap: Map<CommandLineOption> = {};
299+
const shortOptionNames: Map<string> = {};
300300
forEach(optionDeclarations, option => {
301301
optionNameMap[option.name.toLowerCase()] = option;
302302
if (option.shortName) {
@@ -309,10 +309,10 @@ namespace ts {
309309
}
310310

311311
export function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine {
312-
let options: CompilerOptions = {};
313-
let fileNames: string[] = [];
314-
let errors: Diagnostic[] = [];
315-
let { optionNameMap, shortOptionNames } = getOptionNameMap();
312+
const options: CompilerOptions = {};
313+
const fileNames: string[] = [];
314+
const errors: Diagnostic[] = [];
315+
const { optionNameMap, shortOptionNames } = getOptionNameMap();
316316

317317
parseStrings(commandLine);
318318
return {
@@ -337,7 +337,7 @@ namespace ts {
337337
}
338338

339339
if (hasProperty(optionNameMap, s)) {
340-
let opt = optionNameMap[s];
340+
const opt = optionNameMap[s];
341341

342342
// Check to see if no argument was provided (e.g. "--locale" is the last command-line argument).
343343
if (!args[i] && opt.type !== "boolean") {
@@ -377,19 +377,19 @@ namespace ts {
377377
}
378378

379379
function parseResponseFile(fileName: string) {
380-
let text = readFile ? readFile(fileName) : sys.readFile(fileName);
380+
const text = readFile ? readFile(fileName) : sys.readFile(fileName);
381381

382382
if (!text) {
383383
errors.push(createCompilerDiagnostic(Diagnostics.File_0_not_found, fileName));
384384
return;
385385
}
386386

387-
let args: string[] = [];
387+
const args: string[] = [];
388388
let pos = 0;
389389
while (true) {
390390
while (pos < text.length && text.charCodeAt(pos) <= CharacterCodes.space) pos++;
391391
if (pos >= text.length) break;
392-
let start = pos;
392+
const start = pos;
393393
if (text.charCodeAt(start) === CharacterCodes.doubleQuote) {
394394
pos++;
395395
while (pos < text.length && text.charCodeAt(pos) !== CharacterCodes.doubleQuote) pos++;
@@ -432,7 +432,7 @@ namespace ts {
432432
*/
433433
export function parseConfigFileTextToJson(fileName: string, jsonText: string): { config?: any; error?: Diagnostic } {
434434
try {
435-
let jsonTextWithoutComments = removeComments(jsonText);
435+
const jsonTextWithoutComments = removeComments(jsonText);
436436
return { config: /\S/.test(jsonTextWithoutComments) ? JSON.parse(jsonTextWithoutComments) : {} };
437437
}
438438
catch (e) {
@@ -449,7 +449,7 @@ namespace ts {
449449
*/
450450
function removeComments(jsonText: string): string {
451451
let output = "";
452-
let scanner = createScanner(ScriptTarget.ES5, /* skipTrivia */ false, LanguageVariant.Standard, jsonText);
452+
const scanner = createScanner(ScriptTarget.ES5, /* skipTrivia */ false, LanguageVariant.Standard, jsonText);
453453
let token: SyntaxKind;
454454
while ((token = scanner.scan()) !== SyntaxKind.EndOfFileToken) {
455455
switch (token) {
@@ -475,7 +475,7 @@ namespace ts {
475475
* file to. e.g. outDir
476476
*/
477477
export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string): ParsedCommandLine {
478-
let { options, errors } = convertCompilerOptionsFromJson(json["compilerOptions"], basePath);
478+
const { options, errors } = convertCompilerOptionsFromJson(json["compilerOptions"], basePath);
479479

480480
return {
481481
options,
@@ -494,12 +494,12 @@ namespace ts {
494494
}
495495
}
496496
else {
497-
let exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
498-
let sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude));
497+
const exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
498+
const sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude));
499499
for (let i = 0; i < sysFiles.length; i++) {
500-
let name = sysFiles[i];
500+
const name = sysFiles[i];
501501
if (fileExtensionIs(name, ".d.ts")) {
502-
let baseName = name.substr(0, name.length - ".d.ts".length);
502+
const baseName = name.substr(0, name.length - ".d.ts".length);
503503
if (!contains(sysFiles, baseName + ".tsx") && !contains(sysFiles, baseName + ".ts")) {
504504
fileNames.push(name);
505505
}
@@ -519,24 +519,24 @@ namespace ts {
519519
}
520520

521521
export function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string): { options: CompilerOptions, errors: Diagnostic[] } {
522-
let options: CompilerOptions = {};
523-
let errors: Diagnostic[] = [];
522+
const options: CompilerOptions = {};
523+
const errors: Diagnostic[] = [];
524524

525525
if (!jsonOptions) {
526526
return { options, errors };
527527
}
528528

529-
let optionNameMap = arrayToMap(optionDeclarations, opt => opt.name);
529+
const optionNameMap = arrayToMap(optionDeclarations, opt => opt.name);
530530

531-
for (let id in jsonOptions) {
531+
for (const id in jsonOptions) {
532532
if (hasProperty(optionNameMap, id)) {
533-
let opt = optionNameMap[id];
534-
let optType = opt.type;
533+
const opt = optionNameMap[id];
534+
const optType = opt.type;
535535
let value = jsonOptions[id];
536-
let expectedType = typeof optType === "string" ? optType : "string";
536+
const expectedType = typeof optType === "string" ? optType : "string";
537537
if (typeof value === expectedType) {
538538
if (typeof optType !== "string") {
539-
let key = value.toLowerCase();
539+
const key = value.toLowerCase();
540540
if (hasProperty(optType, key)) {
541541
value = optType[key];
542542
}

0 commit comments

Comments
 (0)