Skip to content

Commit 971133d

Browse files
ShuiRuTianorta
andauthored
New command line help developer experience. (#44157)
* refactor help CLI output. * fix typo and omit false condition boolean output. * fix typo * add line break * add --plugins option to basic option category. * add ts icon and remove old print help function. * better command description for --jsx. * Fix test * fix lint * Improvements to the UX * Fix tests * fix test. * add missing help out. * use environemnt variable to control test case. * fix merge issues. * No `No Category` * make getWidthOfTerminal optional. * fix test * fix review. * fix review. * Update baselines Co-authored-by: Orta <[email protected]>
1 parent 6bb1f07 commit 971133d

File tree

13 files changed

+881
-213
lines changed

13 files changed

+881
-213
lines changed

src/compiler/commandLineParser.ts

Lines changed: 143 additions & 76 deletions
Large diffs are not rendered by default.

src/compiler/diagnosticMessages.json

Lines changed: 124 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4031,11 +4031,11 @@
40314031
"category": "Message",
40324032
"code": 6014
40334033
},
4034-
"Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'.": {
4034+
"Specify ECMAScript target version.": {
40354035
"category": "Message",
40364036
"code": 6015
40374037
},
4038-
"Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'.": {
4038+
"Specify module code generation.": {
40394039
"category": "Message",
40404040
"code": 6016
40414041
},
@@ -4243,7 +4243,7 @@
42434243
"category": "Message",
42444244
"code": 6079
42454245
},
4246-
"Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'.": {
4246+
"Specify JSX code generation.": {
42474247
"category": "Message",
42484248
"code": 6080
42494249
},
@@ -5638,6 +5638,127 @@
56385638
"code": 6803
56395639
},
56405640

5641+
"one of:": {
5642+
"category": "Message",
5643+
"code": 6900
5644+
},
5645+
"one or more:": {
5646+
"category": "Message",
5647+
"code": 6901
5648+
},
5649+
"type:": {
5650+
"category": "Message",
5651+
"code": 6902
5652+
},
5653+
"default:": {
5654+
"category": "Message",
5655+
"code": 6903
5656+
},
5657+
"module === \"system\" or esModuleInterop": {
5658+
"category": "Message",
5659+
"code": 6904
5660+
},
5661+
"`false`, unless `strict` is set": {
5662+
"category": "Message",
5663+
"code": 6905
5664+
},
5665+
"`false`, unless `composite` is set": {
5666+
"category": "Message",
5667+
"code": 6906
5668+
},
5669+
"`[\"node_modules\", \"bower_components\", \"jspm_packages\"]`, plus the value of `outDir` if one is specified.": {
5670+
"category": "Message",
5671+
"code": 6907
5672+
},
5673+
"`[]` if `files` is specified, otherwise `[\"**/*\"]`": {
5674+
"category": "Message",
5675+
"code": 6908
5676+
},
5677+
"`true` if `composite`, `false` otherwise": {
5678+
"category": "Message",
5679+
"code": 6909
5680+
},
5681+
"module === `AMD` or `UMD` or `System` or `ES6`, then `Classic`, Otherwise `Node`": {
5682+
"category": "Message",
5683+
"code": 69010
5684+
},
5685+
"Computed from the list of input files": {
5686+
"category": "Message",
5687+
"code": 6911
5688+
},
5689+
"Platform specific": {
5690+
"category": "Message",
5691+
"code": 6912
5692+
},
5693+
"You can learn about all of the compiler options at {0}": {
5694+
"category": "Message",
5695+
"code": 6913
5696+
},
5697+
"Including --watch, -w will start watching the current project for the file changes. Once set, you can config watch mode with:": {
5698+
"category": "Message",
5699+
"code": 6914
5700+
},
5701+
"Using --build, -b will make tsc behave more like a build orchestrator than a compiler. This is used to trigger building composite projects which you can learn more about at {0}": {
5702+
"category": "Message",
5703+
"code": 6915
5704+
},
5705+
"COMMON COMMANDS": {
5706+
"category": "Message",
5707+
"code": 6916
5708+
},
5709+
"ALL COMPILER OPTIONS": {
5710+
"category": "Message",
5711+
"code": 6917
5712+
},
5713+
"WATCH OPTIONS": {
5714+
"category": "Message",
5715+
"code": 6918
5716+
},
5717+
"BUILD OPTIONS": {
5718+
"category": "Message",
5719+
"code": 6919
5720+
},
5721+
"COMMON COMPILER OPTIONS": {
5722+
"category": "Message",
5723+
"code": 6920
5724+
},
5725+
"COMMAND LINE FLAGS": {
5726+
"category": "Message",
5727+
"code": 6921
5728+
},
5729+
"tsc: The TypeScript Compiler": {
5730+
"category": "Message",
5731+
"code": 6922
5732+
},
5733+
"Compiles the current project (tsconfig.json in the working directory.)": {
5734+
"category": "Message",
5735+
"code": 6923
5736+
},
5737+
"Ignoring tsconfig.json, compiles the specified files with default compiler options": {
5738+
"category": "Message",
5739+
"code": 6924
5740+
},
5741+
"Build a composite project in the working directory.": {
5742+
"category": "Message",
5743+
"code": 6925
5744+
},
5745+
"Creates a tsconfig.json with the recommended settings in the working directory.": {
5746+
"category": "Message",
5747+
"code": 6926
5748+
},
5749+
"Compiles the TypeScript project located at the specified path": {
5750+
"category": "Message",
5751+
"code": 6927
5752+
},
5753+
"An expanded version of this information, showing all possible compiler options": {
5754+
"category": "Message",
5755+
"code": 6928
5756+
},
5757+
"Compiles the current project, with additional settings": {
5758+
"category": "Message",
5759+
"code": 6929
5760+
},
5761+
56415762
"Variable '{0}' implicitly has an '{1}' type.": {
56425763
"category": "Error",
56435764
"code": 7005

src/compiler/sys.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,7 @@ namespace ts {
11621162
useCaseSensitiveFileNames: boolean;
11631163
write(s: string): void;
11641164
writeOutputIsTTY?(): boolean;
1165+
getWidthOfTerminal?(): number;
11651166
readFile(path: string, encoding?: string): string | undefined;
11661167
getFileSize?(path: string): number;
11671168
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
@@ -1308,6 +1309,9 @@ namespace ts {
13081309
write(s: string): void {
13091310
process.stdout.write(s);
13101311
},
1312+
getWidthOfTerminal(){
1313+
return process.stdout.columns;
1314+
},
13111315
writeOutputIsTTY() {
13121316
return process.stdout.isTTY;
13131317
},

src/compiler/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6224,7 +6224,8 @@ namespace ts {
62246224
type: "string" | "number" | "boolean" | "object" | "list" | ESMap<string, number | string>; // a value of a primitive type, or an object literal mapping named values to actual values
62256225
isFilePath?: boolean; // True if option value is a path or fileName
62266226
shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help'
6227-
description?: DiagnosticMessage; // The message describing what the command line switch does
6227+
description?: DiagnosticMessage; // The message describing what the command line switch does.
6228+
defaultValueDescription?: string | DiagnosticMessage; // The message describing what the dafault value is. string type is prepared for fixed chosen like "false" which do not need I18n.
62286229
paramType?: DiagnosticMessage; // The name to be used for a non-boolean option's parameter
62296230
isTSConfigOnly?: boolean; // True if option can only be specified via tsconfig.json file
62306231
isCommandLineOnly?: boolean;

0 commit comments

Comments
 (0)