Skip to content

Commit 1032991

Browse files
committed
Show implied options in --showConfig
1 parent 7e1c297 commit 1032991

File tree

9 files changed

+198
-150
lines changed

9 files changed

+198
-150
lines changed

src/compiler/commandLineParser.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
CommandLineOptionOfListType,
1616
CompilerOptions,
1717
CompilerOptionsValue,
18+
computedOptions,
1819
ConfigFileSpecs,
1920
containsPath,
2021
convertToRelativePath,
@@ -103,6 +104,7 @@ import {
103104
removeTrailingDirectorySeparator,
104105
returnTrue,
105106
ScriptTarget,
107+
some,
106108
startsWith,
107109
StringLiteral,
108110
SyntaxKind,
@@ -2475,9 +2477,10 @@ export function convertToTSConfig(configParseResult: ParsedCommandLine, configFi
24752477
),
24762478
f => getRelativePathFromFile(getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName),
24772479
);
2478-
const optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames });
2480+
const pathOptions = { configFilePath: getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames };
2481+
const optionMap = serializeCompilerOptions(configParseResult.options, pathOptions);
24792482
const watchOptionMap = configParseResult.watchOptions && serializeWatchOptions(configParseResult.watchOptions);
2480-
const config = {
2483+
const config: TSConfig & { watchOptions?: object; } = {
24812484
compilerOptions: {
24822485
...optionMapToObject(optionMap),
24832486
showConfig: undefined,
@@ -2500,6 +2503,19 @@ export function convertToTSConfig(configParseResult: ParsedCommandLine, configFi
25002503
} : {}),
25012504
compileOnSave: !!configParseResult.compileOnSave ? true : undefined,
25022505
};
2506+
2507+
const providedKeys = new Set(optionMap.keys());
2508+
const impliedCompilerOptions: Record<string, CompilerOptionsValue> = {};
2509+
for (const option in computedOptions) {
2510+
if (!providedKeys.has(option) && some(computedOptions[option as keyof typeof computedOptions].dependencies, dep => providedKeys.has(dep))) {
2511+
const implied = computedOptions[option as keyof typeof computedOptions].computeValue(configParseResult.options);
2512+
const defaultValue = computedOptions[option as keyof typeof computedOptions].computeValue({});
2513+
if (implied !== defaultValue) {
2514+
impliedCompilerOptions[option] = computedOptions[option as keyof typeof computedOptions].computeValue(configParseResult.options);
2515+
}
2516+
}
2517+
}
2518+
assign(config.compilerOptions, optionMapToObject(serializeCompilerOptions(impliedCompilerOptions, pathOptions)));
25032519
return config;
25042520
}
25052521

src/compiler/utilities.ts

Lines changed: 164 additions & 141 deletions
Large diffs are not rendered by default.

tests/baselines/reference/config/showConfig/Show TSConfig with compileOnSave and more/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"esModuleInterop": true,
44
"target": "es5",
55
"module": "commonjs",
6-
"strict": true
6+
"strict": true,
7+
"allowSyntheticDefaultImports": true
78
},
89
"references": [
910
{

tests/baselines/reference/config/showConfig/Show TSConfig with paths and more/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
},
2626
"experimentalDecorators": true,
2727
"emitDecoratorMetadata": true,
28-
"resolveJsonModule": true
28+
"resolveJsonModule": true,
29+
"allowSyntheticDefaultImports": true
2930
},
3031
"include": [
3132
"./src/**/*"
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"compilerOptions": {
3-
"checkJs": true
3+
"checkJs": true,
4+
"allowJs": true
45
}
56
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"compilerOptions": {
3-
"composite": true
3+
"composite": true,
4+
"declaration": true,
5+
"incremental": true
46
}
57
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"compilerOptions": {
3-
"isolatedModules": true
3+
"isolatedModules": true,
4+
"preserveConstEnums": true
45
}
56
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"compilerOptions": {
3-
"module": "none"
3+
"module": "none",
4+
"moduleResolution": "classic"
45
}
56
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"compilerOptions": {
3-
"verbatimModuleSyntax": true
3+
"verbatimModuleSyntax": true,
4+
"isolatedModules": true,
5+
"preserveConstEnums": true
46
}
57
}

0 commit comments

Comments
 (0)