Encode the conditional presence of 'error' in the type system.

This commit is contained in:
Daniel Rosenwasser
2015-09-10 14:23:56 -07:00
parent 4b15c5f628
commit 535efd1b5d
2 changed files with 17 additions and 7 deletions

View File

@@ -327,11 +327,8 @@ namespace ts {
if (hasProperty(map, key)) {
options[opt.name] = map[key];
}
else if (opt.error) {
errors.push(createCompilerDiagnostic(opt.error));
}
else {
Debug.fail(`Command line option for '${opt.name}' doesn't account for invalid options.`);
errors.push(createCompilerDiagnostic((<CommandLineOptionOfCustomType>opt).error));
}
}
}
@@ -444,7 +441,7 @@ namespace ts {
value = optType[key];
}
else {
errors.push(createCompilerDiagnostic(opt.error));
errors.push(createCompilerDiagnostic((<CommandLineOptionOfCustomType>opt).error));
value = 0;
}
}