Skip to content

Commit 9cd4b07

Browse files
authored
Add link to documentation in tsconfig.json template generated by tsc --init (#34686)
* Add Advanced Compile Options to --init command * removed advanced options and descriptioncolumn * tests: fix tsconfig.json baselines * tests: fix failing tests * feat: adjusted link to specification * fix: removed duplicate increment flag * chore: moved position back * return of the comments * fix for missalignment * return of the comment
1 parent 1f56ab0 commit 9cd4b07

File tree

16 files changed

+45
-14
lines changed

16 files changed

+45
-14
lines changed

src/compiler/commandLineParser.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,15 +2119,12 @@ namespace ts {
21192119
// Serialize all options and their descriptions
21202120
let marginLength = 0;
21212121
let seenKnownKeys = 0;
2122-
const nameColumn: string[] = [];
2123-
const descriptionColumn: string[] = [];
2122+
const entries: { value: string, description?: string }[] = [];
21242123
categorizedOptions.forEach((options, category) => {
2125-
if (nameColumn.length !== 0) {
2126-
nameColumn.push("");
2127-
descriptionColumn.push("");
2124+
if (entries.length !== 0) {
2125+
entries.push({ value: "" });
21282126
}
2129-
nameColumn.push(`/* ${category} */`);
2130-
descriptionColumn.push("");
2127+
entries.push({ value: `/* ${category} */` });
21312128
for (const option of options) {
21322129
let optionName;
21332130
if (compilerOptionsMap.has(option.name)) {
@@ -2136,8 +2133,10 @@ namespace ts {
21362133
else {
21372134
optionName = `// "${option.name}": ${JSON.stringify(getDefaultValueForOption(option))},`;
21382135
}
2139-
nameColumn.push(optionName);
2140-
descriptionColumn.push(`/* ${option.description && getLocaleSpecificMessage(option.description) || option.name} */`);
2136+
entries.push({
2137+
value: optionName,
2138+
description: `/* ${option.description && getLocaleSpecificMessage(option.description) || option.name} */`
2139+
});
21412140
marginLength = Math.max(optionName.length, marginLength);
21422141
}
21432142
});
@@ -2147,11 +2146,12 @@ namespace ts {
21472146
const result: string[] = [];
21482147
result.push(`{`);
21492148
result.push(`${tab}"compilerOptions": {`);
2149+
result.push(`${tab}${tab}/* ${getLocaleSpecificMessage(Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file)} */`);
2150+
result.push("");
21502151
// Print out each row, aligning all the descriptions on the same column.
2151-
for (let i = 0; i < nameColumn.length; i++) {
2152-
const optionName = nameColumn[i];
2153-
const description = descriptionColumn[i];
2154-
result.push(optionName && `${tab}${tab}${optionName}${description && (makePadding(marginLength - optionName.length + 2) + description)}`);
2152+
for (const entry of entries) {
2153+
const { value, description = "" } = entry;
2154+
result.push(value && `${tab}${tab}${value}${description && (makePadding(marginLength - value.length + 2) + description)}`);
21552155
}
21562156
if (fileNames.length) {
21572157
result.push(`${tab}},`);

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5613,7 +5613,10 @@
56135613
"category": "Message",
56145614
"code": 95109
56155615
},
5616-
5616+
"Visit https://aka.ms/tsconfig.json to read more about this file": {
5617+
"category": "Message",
5618+
"code": 95110
5619+
},
56175620
"No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": {
56185621
"category": "Error",
56195622
"code": 18004

tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"compilerOptions": {
3+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
4+
35
/* Basic Options */
46
// "incremental": true, /* Enable incremental compilation */
57
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */

tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"compilerOptions": {
3+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
4+
35
/* Basic Options */
46
// "incremental": true, /* Enable incremental compilation */
57
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */

tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"compilerOptions": {
3+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
4+
35
/* Basic Options */
46
// "incremental": true, /* Enable incremental compilation */
57
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */

tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"compilerOptions": {
3+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
4+
35
/* Basic Options */
46
// "incremental": true, /* Enable incremental compilation */
57
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */

tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"compilerOptions": {
3+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
4+
35
/* Basic Options */
46
// "incremental": true, /* Enable incremental compilation */
57
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */

tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"compilerOptions": {
3+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
4+
35
/* Basic Options */
46
// "incremental": true, /* Enable incremental compilation */
57
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */

tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"compilerOptions": {
3+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
4+
35
/* Basic Options */
46
// "incremental": true, /* Enable incremental compilation */
57
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */

tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"compilerOptions": {
3+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
4+
35
/* Basic Options */
46
// "incremental": true, /* Enable incremental compilation */
57
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */

tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"compilerOptions": {
3+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
4+
35
/* Basic Options */
46
// "incremental": true, /* Enable incremental compilation */
57
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */

tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/declarationDir-is-specified.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ interface Array<T> { length: number; [n: number]: T; }
2121
//// [/user/username/projects/myproject/tsconfig.json]
2222
{
2323
"compilerOptions": {
24+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
25+
2426
/* Basic Options */
2527
// "incremental": true, /* Enable incremental compilation */
2628
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */

tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-and-declarationDir-is-specified.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ interface Array<T> { length: number; [n: number]: T; }
2121
//// [/user/username/projects/myproject/tsconfig.json]
2222
{
2323
"compilerOptions": {
24+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
25+
2426
/* Basic Options */
2527
// "incremental": true, /* Enable incremental compilation */
2628
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */

tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/when-outDir-is-specified.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ interface Array<T> { length: number; [n: number]: T; }
2121
//// [/user/username/projects/myproject/tsconfig.json]
2222
{
2323
"compilerOptions": {
24+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
25+
2426
/* Basic Options */
2527
// "incremental": true, /* Enable incremental compilation */
2628
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */

tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/with-outFile.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ interface Array<T> { length: number; [n: number]: T; }
2121
//// [/user/username/projects/myproject/tsconfig.json]
2222
{
2323
"compilerOptions": {
24+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
25+
2426
/* Basic Options */
2527
// "incremental": true, /* Enable incremental compilation */
2628
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */

tests/baselines/reference/tscWatch/programUpdates/should-not-trigger-recompilation-because-of-program-emit/without-outDir-or-outFile-is-specified.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ interface Array<T> { length: number; [n: number]: T; }
2121
//// [/user/username/projects/myproject/tsconfig.json]
2222
{
2323
"compilerOptions": {
24+
/* Visit https://aka.ms/tsconfig.json to read more about this file */
25+
2426
/* Basic Options */
2527
// "incremental": true, /* Enable incremental compilation */
2628
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */

0 commit comments

Comments
 (0)