@@ -15,6 +15,7 @@ import {
15
15
CommandLineOptionOfListType ,
16
16
CompilerOptions ,
17
17
CompilerOptionsValue ,
18
+ computedOptions ,
18
19
ConfigFileSpecs ,
19
20
containsPath ,
20
21
convertToRelativePath ,
@@ -103,6 +104,7 @@ import {
103
104
removeTrailingDirectorySeparator ,
104
105
returnTrue ,
105
106
ScriptTarget ,
107
+ some ,
106
108
startsWith ,
107
109
StringLiteral ,
108
110
SyntaxKind ,
@@ -2475,9 +2477,10 @@ export function convertToTSConfig(configParseResult: ParsedCommandLine, configFi
2475
2477
) ,
2476
2478
f => getRelativePathFromFile ( getNormalizedAbsolutePath ( configFileName , host . getCurrentDirectory ( ) ) , getNormalizedAbsolutePath ( f , host . getCurrentDirectory ( ) ) , getCanonicalFileName ) ,
2477
2479
) ;
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 ) ;
2479
2482
const watchOptionMap = configParseResult . watchOptions && serializeWatchOptions ( configParseResult . watchOptions ) ;
2480
- const config = {
2483
+ const config : TSConfig & { watchOptions ?: object ; } = {
2481
2484
compilerOptions : {
2482
2485
...optionMapToObject ( optionMap ) ,
2483
2486
showConfig : undefined ,
@@ -2500,6 +2503,19 @@ export function convertToTSConfig(configParseResult: ParsedCommandLine, configFi
2500
2503
} : { } ) ,
2501
2504
compileOnSave : ! ! configParseResult . compileOnSave ? true : undefined ,
2502
2505
} ;
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 ) ) ) ;
2503
2519
return config ;
2504
2520
}
2505
2521
0 commit comments