Skip to content

Commit 7a214bd

Browse files
committed
Removed string | list type implementation
1 parent 1b36b57 commit 7a214bd

File tree

5 files changed

+8
-38
lines changed

5 files changed

+8
-38
lines changed

src/compiler/commandLineParser.ts

+5-12
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,7 @@ export function parseListTypeOption(opt: CommandLineOptionOfListType, value = ""
16641664
if (startsWith(value, "-")) {
16651665
return undefined;
16661666
}
1667-
if (opt.type === "string | list" && !stringContains(value, ",")) {
1667+
if (opt.type === "listOrElement" && !stringContains(value, ",")) {
16681668
return validateJsonOptionValue(opt, value, errors);
16691669
}
16701670
if (value === "") {
@@ -1678,7 +1678,7 @@ export function parseListTypeOption(opt: CommandLineOptionOfListType, value = ""
16781678
return mapDefined(values, v => validateJsonOptionValue(opt.element, v || "", errors));
16791679
case "boolean":
16801680
case "object":
1681-
case "string | list":
1681+
case "listOrElement":
16821682
return Debug.fail(`List of ${opt.element.type} is not yet supported.`);
16831683
default:
16841684
return mapDefined(values, v => parseCustomTypeOption(opt.element as CommandLineOptionOfCustomType, v, errors));
@@ -1851,7 +1851,6 @@ function parseOptionValue(
18511851
options[opt.name] = validateJsonOptionValue(opt, args[i] || "", errors);
18521852
i++;
18531853
break;
1854-
case "string | list":
18551854
case "list":
18561855
const result = parseListTypeOption(opt, args[i], errors);
18571856
options[opt.name] = result || [];
@@ -2371,7 +2370,7 @@ export function convertToObjectWorker(
23712370
if (!isDoubleQuotedString(valueExpression)) {
23722371
errors.push(createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, Diagnostics.String_literal_with_double_quotes_expected));
23732372
}
2374-
reportInvalidOptionValue(option && isString(option.type) && option.type !== "string" && (option.type !== "listOrElement" || (isString(option.element.type) && option.element.type !== "string")) && option.type !== "string | list");
2373+
reportInvalidOptionValue(option && isString(option.type) && option.type !== "string" && (option.type !== "listOrElement" || (isString(option.element.type) && option.element.type !== "string")));
23752374
const text = (valueExpression as StringLiteral).text;
23762375
if (option) {
23772376
Debug.assert(option.type !== "listOrElement" || option.element.type === "string", "Only string or array of string is handled for now");
@@ -2403,7 +2402,7 @@ export function convertToObjectWorker(
24032402
return validateValue(-Number(((valueExpression as PrefixUnaryExpression).operand as NumericLiteral).text));
24042403

24052404
case SyntaxKind.ObjectLiteralExpression:
2406-
reportInvalidOptionValue(option && option.type !== "object" && (option.type !== "listOrElement" || option.element.type !== "object") && option.type !== "string | list");
2405+
reportInvalidOptionValue(option && option.type !== "object" && (option.type !== "listOrElement" || option.element.type !== "object"));
24072406
const objectLiteralExpression = valueExpression as ObjectLiteralExpression;
24082407

24092408
// Currently having element option declaration in the tsconfig with type "object"
@@ -2481,9 +2480,6 @@ function isCompilerOptionsValue(option: CommandLineOption | undefined, value: an
24812480
if (option.type === "listOrElement") {
24822481
return isArray(value) || isCompilerOptionsValue(option.element, value);
24832482
}
2484-
if (option.type === "string | list") {
2485-
return typeof value === "string" || isArray(value);
2486-
}
24872483
const expectedType = isString(option.type) ? option.type : "string";
24882484
return typeof value === expectedType;
24892485
}
@@ -2603,7 +2599,6 @@ function getCustomTypeMapOfCommandLineOption(optionDefinition: CommandLineOption
26032599
case "number":
26042600
case "boolean":
26052601
case "object":
2606-
case "string | list":
26072602
// this is of a type CommandLineOptionOfPrimitiveType
26082603
return undefined;
26092604
case "list":
@@ -3521,7 +3516,7 @@ function convertOptionsFromJson(optionsNameMap: Map<string, CommandLineOption>,
35213516
export function convertJsonOption(opt: CommandLineOption, value: any, basePath: string, errors: Push<Diagnostic>): CompilerOptionsValue {
35223517
if (isCompilerOptionsValue(opt, value)) {
35233518
const optType = opt.type;
3524-
if ((optType === "list" || opt.type === "string | list") && isArray(value)) {
3519+
if ((optType === "list") && isArray(value)) {
35253520
return convertJsonOptionOfListType(opt, value, basePath, errors);
35263521
}
35273522
else if (optType === "listOrElement") {
@@ -3975,7 +3970,6 @@ function getOptionValueWithEmptyStrings(value: any, option: CommandLineOption):
39753970
if (!isArray(value)) return getOptionValueWithEmptyStrings(value, option.element);
39763971
// fall through to list
39773972
case "list":
3978-
case "string | list":
39793973
const elementType = option.element;
39803974
return isArray(value) ? value.map(v => getOptionValueWithEmptyStrings(v, elementType)) : "";
39813975
default:
@@ -3995,7 +3989,6 @@ function getDefaultValueForOption(option: CommandLineOption): {} {
39953989
case "boolean":
39963990
return true;
39973991
case "string":
3998-
case "string | list":
39993992
const defaultValue = option.defaultValueDescription;
40003993
return option.isFilePath ? `./${defaultValue && typeof defaultValue === "string" ? defaultValue : ""}` : "";
40013994
case "list":

src/compiler/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6960,7 +6960,7 @@ export interface CreateProgramOptions {
69606960
/** @internal */
69616961
export interface CommandLineOptionBase {
69626962
name: string;
6963-
type: "string" | "number" | "boolean" | "object" | "list" | "listOrElement" | "string | list" | Map<string, number | string> ; // a value of a primitive type, or an object literal mapping named values to actual values
6963+
type: "string" | "number" | "boolean" | "object" | "list" | "listOrElement" | Map<string, number | string> ; // a value of a primitive type, or an object literal mapping named values to actual values
69646964
isFilePath?: boolean; // True if option value is a path or fileName
69656965
shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'
69666966
description?: DiagnosticMessage; // The message describing what the command line switch does.
@@ -7030,7 +7030,7 @@ export interface TsConfigOnlyOption extends CommandLineOptionBase {
70307030

70317031
/** @internal */
70327032
export interface CommandLineOptionOfListType extends CommandLineOptionBase {
7033-
type: "list" | "listOrElement" | "string | list";
7033+
type: "list" | "listOrElement";
70347034
element: CommandLineOptionOfCustomType | CommandLineOptionOfStringType | CommandLineOptionOfNumberType | CommandLineOptionOfBooleanType | TsConfigOnlyOption;
70357035
listPreserveFalsyValues?: boolean;
70367036
}

src/executeCommandLine/executeCommandLine.ts

-4
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,6 @@ function generateOptionOutput(sys: System, option: CommandLineOption, rightAlign
372372
case "boolean":
373373
return getDiagnosticText(Diagnostics.type_Colon);
374374
case "list":
375-
case "string | list":
376375
return getDiagnosticText(Diagnostics.one_or_more_Colon);
377376
default:
378377
return getDiagnosticText(Diagnostics.one_of_Colon);
@@ -391,9 +390,6 @@ function generateOptionOutput(sys: System, option: CommandLineOption, rightAlign
391390
case "listOrElement":
392391
possibleValues = getPossibleValues(option.element);
393392
break;
394-
case "string | list":
395-
possibleValues = "string";
396-
break;
397393
case "object":
398394
possibleValues = "";
399395
break;

src/harness/harnessIO.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ export namespace Compiler {
380380
}
381381
// If not a primitive, the possible types are specified in what is effectively a map of options.
382382
case "list":
383-
case "string | list":
383+
case "listOrElement":
384384
return ts.parseListTypeOption(option, value, errors);
385385
default:
386386
return ts.parseCustomTypeOption(option as ts.CommandLineOptionOfCustomType, value, errors);

src/testRunner/unittests/config/showConfig.ts

-19
Original file line numberDiff line numberDiff line change
@@ -126,24 +126,6 @@ describe("unittests:: config:: showConfig", () => {
126126
if (option.name === "project") return;
127127
let args: string[];
128128
let optionValue: object | undefined;
129-
if (option.type === "string | list") {
130-
if (option.isTSConfigOnly) {
131-
showTSConfigCorrectly(
132-
`Shows tsconfig for single option/${option.name}WithStringValue`,
133-
["-p", "tsconfig.json"],
134-
isCompilerOptions ?
135-
{ compilerOptions: { [option.name]: "someString" } } :
136-
{ watchOptions: { [option.name]: "someString" } }
137-
);
138-
}
139-
else {
140-
showTSConfigCorrectly(
141-
`Shows tsconfig for single option/${option.name}WithStringValue`,
142-
[`--${option.name}`, "someString"],
143-
/*configJson*/ undefined,
144-
);
145-
}
146-
}
147129
switch (option.type) {
148130
case "boolean": {
149131
if (option.isTSConfigOnly) {
@@ -155,7 +137,6 @@ describe("unittests:: config:: showConfig", () => {
155137
}
156138
break;
157139
}
158-
case "string | list":
159140
case "list": {
160141
if (option.isTSConfigOnly) {
161142
args = ["-p", "tsconfig.json"];

0 commit comments

Comments
 (0)