mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Encode the conditional presence of 'error' in the type system.
This commit is contained in:
parent
4b15c5f628
commit
535efd1b5d
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2112,17 +2112,30 @@ namespace ts {
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export interface CommandLineOption {
|
||||
interface CommandLineOptionBase {
|
||||
name: string;
|
||||
type: string | Map<number>; // "string", "number", "boolean", or an object literal mapping named values to actual values
|
||||
isFilePath?: boolean; // True if option value is a path or fileName
|
||||
shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'
|
||||
description?: DiagnosticMessage; // The message describing what the command line switch does
|
||||
paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter
|
||||
error?: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'
|
||||
experimental?: boolean;
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export interface CommandLineOptionOfPrimitiveType extends CommandLineOptionBase {
|
||||
type: string; // "string" | "number" | "boolean"
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export interface CommandLineOptionOfCustomType extends CommandLineOptionBase {
|
||||
type: Map<number>; // an object literal mapping named values to actual values
|
||||
error: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export type CommandLineOption = CommandLineOptionOfCustomType | CommandLineOptionOfPrimitiveType;
|
||||
|
||||
/* @internal */
|
||||
export const enum CharacterCodes {
|
||||
nullCharacter = 0,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user