@@ -20,22 +20,8 @@ export class TSConfigReader implements OptionsReader {
20
20
name = "tsconfig-json" ;
21
21
22
22
read ( container : Options , logger : Logger ) : void {
23
- const tsconfigOpt = container . getValue ( "tsconfig" ) ;
23
+ const file = container . getValue ( "tsconfig" ) ;
24
24
25
- if ( ! container . isDefault ( "tsconfig" ) ) {
26
- this . _tryReadOptions ( tsconfigOpt , container , logger ) ;
27
- return ;
28
- }
29
-
30
- // Don't log errors if we try to read by default.
31
- this . _tryReadOptions ( tsconfigOpt , container ) ;
32
- }
33
-
34
- private _tryReadOptions (
35
- file : string ,
36
- container : Options & { setValue ( name : string , value : unknown ) : void } ,
37
- logger ?: Logger
38
- ) : void {
39
25
let fileToRead : string | undefined = file ;
40
26
if ( ! isFile ( fileToRead ) ) {
41
27
fileToRead = ts . findConfigFile (
@@ -48,7 +34,10 @@ export class TSConfigReader implements OptionsReader {
48
34
}
49
35
50
36
if ( ! fileToRead || ! isFile ( fileToRead ) ) {
51
- logger ?. error ( `The tsconfig file ${ file } does not exist` ) ;
37
+ // If the user didn't give us this option, we shouldn't complain about not being able to find it.
38
+ if ( ! container . isDefault ( "tsconfig" ) ) {
39
+ logger . error ( `The tsconfig file ${ file } does not exist` ) ;
40
+ }
52
41
return ;
53
42
}
54
43
@@ -61,7 +50,7 @@ export class TSConfigReader implements OptionsReader {
61
50
{
62
51
...ts . sys ,
63
52
onUnRecoverableConfigFileDiagnostic ( error ) {
64
- logger ? .diagnostic ( error ) ;
53
+ logger . diagnostic ( error ) ;
65
54
fatalError = true ;
66
55
} ,
67
56
}
@@ -71,11 +60,11 @@ export class TSConfigReader implements OptionsReader {
71
60
return ;
72
61
}
73
62
74
- logger ? .diagnostics ( parsed . errors ) ;
63
+ logger . diagnostics ( parsed . errors ) ;
75
64
76
65
const typedocOptions = parsed . raw ?. typedocOptions ?? { } ;
77
66
if ( typedocOptions . options ) {
78
- logger ? .error (
67
+ logger . error (
79
68
[
80
69
"typedocOptions in tsconfig file specifies an option file to read but the option" ,
81
70
"file has already been read. This is likely a misconfiguration." ,
@@ -84,7 +73,7 @@ export class TSConfigReader implements OptionsReader {
84
73
delete typedocOptions . options ;
85
74
}
86
75
if ( typedocOptions . tsconfig ) {
87
- logger ? .error (
76
+ logger . error (
88
77
"typedocOptions in tsconfig file may not specify a tsconfig file to read"
89
78
) ;
90
79
delete typedocOptions . tsconfig ;
@@ -97,9 +86,10 @@ export class TSConfigReader implements OptionsReader {
97
86
) ;
98
87
for ( const [ key , val ] of Object . entries ( typedocOptions || { } ) ) {
99
88
try {
100
- container . setValue ( key , val ) ;
89
+ // We catch the error, so can ignore the strict type checks
90
+ container . setValue ( key as never , val as never ) ;
101
91
} catch ( error ) {
102
- logger ? .error ( error . message ) ;
92
+ logger . error ( error . message ) ;
103
93
}
104
94
}
105
95
}
0 commit comments