Skip to content

Commit c735a98

Browse files
committed
Respond to code review comments
1 parent 48d0e6d commit c735a98

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/harness/fourslash.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ module FourSlash {
125125
// List of allowed metadata names
126126
let fileMetadataNames = [metadataOptionNames.fileName, metadataOptionNames.emitThisFile, metadataOptionNames.resolveReference];
127127

128-
function convertGlobalOptionsToCompilerOptions(globalOptions: { [idx: string]: string }): ts.CompilerOptions {
128+
function convertGlobalOptionsToCompilerOptions(globalOptions: Harness.TestCaseParser.CompilerSettings): ts.CompilerOptions {
129129
let settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 };
130130
Harness.Compiler.setCompilerOptionsFromHarnessSetting(globalOptions, settings);
131131
return settings;

src/harness/harness.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ module Harness {
949949
};
950950
}
951951

952-
interface HarnesOptions {
952+
interface HarnessOptions {
953953
useCaseSensitiveFileNames?: boolean;
954954
includeBuiltFile?: string;
955955
baselineFile?: string;
@@ -977,10 +977,13 @@ module Harness {
977977
return ts.lookUp(optionsIndex, name.toLowerCase());
978978
}
979979

980-
export function setCompilerOptionsFromHarnessSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnesOptions): void {
980+
export function setCompilerOptionsFromHarnessSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnessOptions): void {
981981
for (let name in settings) {
982982
if (settings.hasOwnProperty(name)) {
983983
let value = settings[name];
984+
if (value === undefined) {
985+
throw new Error(`Cannot have undefined value for compiler option '${name}'.`);
986+
}
984987
let option = getCommandLineOption(name);
985988
if (option) {
986989
switch (option.type) {
@@ -993,17 +996,17 @@ module Harness {
993996
// If not a primitive, the possible types are specified in what is effectively a map of options.
994997
default:
995998
let map = <ts.Map<number>>option.type;
996-
let key = (value).toLowerCase();
999+
let key = value.toLowerCase();
9971000
if (ts.hasProperty(map, key)) {
9981001
options[option.name] = map[key];
9991002
}
10001003
else {
1001-
throw new Error(`Unkown value '${value}' for compiler option '${name}'.`);
1004+
throw new Error(`Unknown value '${value}' for compiler option '${name}'.`);
10021005
}
10031006
}
10041007
}
10051008
else {
1006-
throw new Error(`Unkown compiler option '${name}'.`);
1009+
throw new Error(`Unknown compiler option '${name}'.`);
10071010
}
10081011
}
10091012
}
@@ -1062,7 +1065,7 @@ module Harness {
10621065
otherFiles: { unitName: string; content: string }[],
10631066
onComplete: (result: CompilerResult, program: ts.Program) => void,
10641067
settingsCallback?: (settings: ts.CompilerOptions) => void,
1065-
options?: ts.CompilerOptions & HarnesOptions,
1068+
options?: ts.CompilerOptions & HarnessOptions,
10661069
// Current directory is needed for rwcRunner to be able to use currentDirectory defined in json file
10671070
currentDirectory?: string) {
10681071

0 commit comments

Comments
 (0)