Skip to content

Commit f76b521

Browse files
committed
fix: Errors due to bad options in tsconfig file were dropped
Closes #1444
1 parent 09bf048 commit f76b521

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

src/lib/utils/options/readers/tsconfig.ts

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,8 @@ export class TSConfigReader implements OptionsReader {
2020
name = "tsconfig-json";
2121

2222
read(container: Options, logger: Logger): void {
23-
const tsconfigOpt = container.getValue("tsconfig");
23+
const file = container.getValue("tsconfig");
2424

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 {
3925
let fileToRead: string | undefined = file;
4026
if (!isFile(fileToRead)) {
4127
fileToRead = ts.findConfigFile(
@@ -48,7 +34,10 @@ export class TSConfigReader implements OptionsReader {
4834
}
4935

5036
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+
}
5241
return;
5342
}
5443

@@ -61,7 +50,7 @@ export class TSConfigReader implements OptionsReader {
6150
{
6251
...ts.sys,
6352
onUnRecoverableConfigFileDiagnostic(error) {
64-
logger?.diagnostic(error);
53+
logger.diagnostic(error);
6554
fatalError = true;
6655
},
6756
}
@@ -71,11 +60,11 @@ export class TSConfigReader implements OptionsReader {
7160
return;
7261
}
7362

74-
logger?.diagnostics(parsed.errors);
63+
logger.diagnostics(parsed.errors);
7564

7665
const typedocOptions = parsed.raw?.typedocOptions ?? {};
7766
if (typedocOptions.options) {
78-
logger?.error(
67+
logger.error(
7968
[
8069
"typedocOptions in tsconfig file specifies an option file to read but the option",
8170
"file has already been read. This is likely a misconfiguration.",
@@ -84,7 +73,7 @@ export class TSConfigReader implements OptionsReader {
8473
delete typedocOptions.options;
8574
}
8675
if (typedocOptions.tsconfig) {
87-
logger?.error(
76+
logger.error(
8877
"typedocOptions in tsconfig file may not specify a tsconfig file to read"
8978
);
9079
delete typedocOptions.tsconfig;
@@ -97,9 +86,10 @@ export class TSConfigReader implements OptionsReader {
9786
);
9887
for (const [key, val] of Object.entries(typedocOptions || {})) {
9988
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);
10191
} catch (error) {
102-
logger?.error(error.message);
92+
logger.error(error.message);
10393
}
10494
}
10595
}

0 commit comments

Comments
 (0)