Skip to content

Commit ce652dc

Browse files
committed
Fixing few code review comments
1 parent 0fe282e commit ce652dc

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

src/compiler/commandLineParser.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,14 @@ namespace ts {
375375
}
376376
}
377377

378+
/**
379+
* Parses non quoted strings separated by comma e.g. "a,b" would result in string array ["a", "b"]
380+
* @param s
381+
* @param existingValue
382+
*/
378383
function parseMultiValueStringArray(s: string, existingValue: string[]) {
379384
let value: string[] = existingValue || [];
380-
let hasError: boolean;
385+
let hasError = false;
381386
let currentString = "";
382387
if (s) {
383388
for (let i = 0; i < s.length; i++) {
@@ -480,8 +485,7 @@ namespace ts {
480485
}
481486
// Check if the value asked was string[] and value provided was not string[]
482487
else if (expectedType !== "string[]" ||
483-
typeof jsonValue !== "object" ||
484-
typeof jsonValue.length !== "number" ||
488+
!(jsonValue instanceof Array) ||
485489
forEach(<string[]>jsonValue, individualValue => typeof individualValue !== "string")) {
486490
// Not expectedType
487491
errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType));

src/compiler/program.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ namespace ts {
1414

1515
export const version = "1.7.0";
1616

17-
export function findConfigFile(searchPath: string, moduleResolutionHost: ModuleResolutionHost): string {
17+
export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string {
1818
let fileName = "tsconfig.json";
1919
while (true) {
20-
if (moduleResolutionHost.fileExists(fileName)) {
20+
if (fileExists(fileName)) {
2121
return fileName;
2222
}
2323
let parentPath = getDirectoryPath(searchPath);

src/compiler/tsc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ namespace ts {
188188
}
189189
else if (commandLine.fileNames.length === 0 && isJSONSupported()) {
190190
let searchPath = normalizePath(sys.getCurrentDirectory());
191-
configFileName = findConfigFile(searchPath, sys);
191+
configFileName = findConfigFile(searchPath, sys.fileExists);
192192
}
193193

194194
if (commandLine.fileNames.length === 0 && !configFileName) {

src/harness/projectsRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class ProjectRunner extends RunnerBase {
195195
assert(!inputFiles || inputFiles.length === 0, "cannot specify input files and project option together");
196196
}
197197
else if (!inputFiles || inputFiles.length === 0) {
198-
configFileName = ts.findConfigFile("", { fileExists, readFile: getSourceFileText });
198+
configFileName = ts.findConfigFile("", fileExists);
199199
}
200200

201201
if (configFileName) {

0 commit comments

Comments
 (0)