diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 2ee0f67382..603dff9e77 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -375,9 +375,14 @@ namespace ts { } } + /** + * Parses non quoted strings separated by comma e.g. "a,b" would result in string array ["a", "b"] + * @param s + * @param existingValue + */ function parseMultiValueStringArray(s: string, existingValue: string[]) { let value: string[] = existingValue || []; - let hasError: boolean; + let hasError = false; let currentString = ""; if (s) { for (let i = 0; i < s.length; i++) { @@ -480,8 +485,7 @@ namespace ts { } // Check if the value asked was string[] and value provided was not string[] else if (expectedType !== "string[]" || - typeof jsonValue !== "object" || - typeof jsonValue.length !== "number" || + !(jsonValue instanceof Array) || forEach(jsonValue, individualValue => typeof individualValue !== "string")) { // Not expectedType errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, expectedType)); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index f6daf4880b..999b8bd6df 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -14,10 +14,10 @@ namespace ts { export const version = "1.7.0"; - export function findConfigFile(searchPath: string, moduleResolutionHost: ModuleResolutionHost): string { + export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string { let fileName = "tsconfig.json"; while (true) { - if (moduleResolutionHost.fileExists(fileName)) { + if (fileExists(fileName)) { return fileName; } let parentPath = getDirectoryPath(searchPath); diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 8c1bf962aa..a0c3cc642e 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -188,7 +188,7 @@ namespace ts { } else if (commandLine.fileNames.length === 0 && isJSONSupported()) { let searchPath = normalizePath(sys.getCurrentDirectory()); - configFileName = findConfigFile(searchPath, sys); + configFileName = findConfigFile(searchPath, sys.fileExists); } if (commandLine.fileNames.length === 0 && !configFileName) { diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index a250cb3daa..700423a721 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -195,7 +195,7 @@ class ProjectRunner extends RunnerBase { assert(!inputFiles || inputFiles.length === 0, "cannot specify input files and project option together"); } else if (!inputFiles || inputFiles.length === 0) { - configFileName = ts.findConfigFile("", { fileExists, readFile: getSourceFileText }); + configFileName = ts.findConfigFile("", fileExists); } if (configFileName) {