From e4a1c97b7ddc0c191387760e77d370f1944d9114 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Jul 2015 18:57:48 -0700 Subject: [PATCH] Address comments. --- src/harness/fourslash.ts | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 06ff5d4234b..5d73e04c8cb 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2479,10 +2479,10 @@ module FourSlash { // @Filename is the only directive that can be used in a test that contains tsconfig.json file. if (containTSConfigJson(files)) { let directive = getNonFileNameOptionInFileList(files); - if (directive == null) { + if (!directive) { directive = getNonFileNameOptionInObject(globalOptions); } - if (directive !== null) { + if (directive) { throw Error("It is not allowed to use tsconfig.json along with directive '" + directive + "'"); } } @@ -2497,22 +2497,11 @@ module FourSlash { } function containTSConfigJson(files: FourSlashFile[]): boolean { - for (let i = 0; i < files.length; ++i) { - if (files[i].fileOptions['Filename'] === 'tsconfig.json') { - return true; - } - } - return false; + return ts.forEach(files, f => f.fileOptions['Filename'] === 'tsconfig.json'); } function getNonFileNameOptionInFileList(files: FourSlashFile[]): string { - for (let i = 0; i < files.length; ++i) { - let option = getNonFileNameOptionInObject(files[i].fileOptions); - if (option !== null) { - return option; - } - } - return null; + return ts.forEach(files, f => getNonFileNameOptionInObject(f.fileOptions)); } function getNonFileNameOptionInObject(optionObject: { [s: string]: string }): string { @@ -2521,7 +2510,7 @@ module FourSlash { return option; } } - return null; + return undefined; } const enum State {