mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Describe defaults of more options (#46498)
* Describe defaults of more options * Use enum members/values vs. strings * Update Baselines and/or Applied Lint Fixes Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
This commit is contained in:
@@ -160,7 +160,13 @@ namespace ts {
|
||||
|
||||
// value type and possible value
|
||||
const valueCandidates = getValueCandidate(option);
|
||||
const defaultValueDescription = typeof option.defaultValueDescription === "object" ? getDiagnosticText(option.defaultValueDescription) : option.defaultValueDescription;
|
||||
const defaultValueDescription =
|
||||
typeof option.defaultValueDescription === "object"
|
||||
? getDiagnosticText(option.defaultValueDescription)
|
||||
: formatDefaultValue(
|
||||
option.defaultValueDescription,
|
||||
option.type === "list" ? option.element.type : option.type
|
||||
);
|
||||
const terminalWidth = sys.getWidthOfTerminal?.() ?? 0;
|
||||
|
||||
// Note: child_process might return `terminalWidth` as undefined.
|
||||
@@ -203,6 +209,19 @@ namespace ts {
|
||||
}
|
||||
return text;
|
||||
|
||||
function formatDefaultValue(
|
||||
defaultValue: CommandLineOption["defaultValueDescription"],
|
||||
type: CommandLineOption["type"]
|
||||
) {
|
||||
return defaultValue !== undefined && typeof type === "object"
|
||||
// e.g. ScriptTarget.ES2015 -> "es6/es2015"
|
||||
? arrayFrom(type.entries())
|
||||
.filter(([, value]) => value === defaultValue)
|
||||
.map(([name]) => name)
|
||||
.join("/")
|
||||
: String(defaultValue);
|
||||
}
|
||||
|
||||
function showAdditionalInfoOutput(valueCandidates: ValueCandidate | undefined, option: CommandLineOption): boolean {
|
||||
const ignoreValues = ["string"];
|
||||
const ignoredDescriptions = [undefined, "false", "n/a"];
|
||||
@@ -286,8 +305,14 @@ namespace ts {
|
||||
break;
|
||||
default:
|
||||
// ESMap<string, number | string>
|
||||
const keys = arrayFrom(option.type.keys());
|
||||
possibleValues = keys.join(", ");
|
||||
// Group synonyms: es6/es2015
|
||||
const inverted: { [value: string]: string[] } = {};
|
||||
option.type.forEach((value, name) => {
|
||||
(inverted[value] ||= []).push(name);
|
||||
});
|
||||
return getEntries(inverted)
|
||||
.map(([, synonyms]) => synonyms.join("/"))
|
||||
.join(", ");
|
||||
}
|
||||
return possibleValues;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user