Skip to content

Commit 9c1112d

Browse files
committed
fix(cdk/schematics): avoid throwing an error for empty program (#27060)
Fixes that the `ng update` schematics were throwing an error if the tsconfig doesn't match any files. Fixes #27055. (cherry picked from commit 1ce3a3b)
1 parent 3ee392e commit 9c1112d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/cdk/schematics/update-tool/utils/parse-tsconfig.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import {FileSystemHost} from './virtual-host';
1212
import {dirname} from 'path';
1313
import {formatDiagnostics} from './diagnostics';
1414

15+
/** Code of the error raised by TypeScript when a tsconfig doesn't match any files. */
16+
const NO_INPUTS_ERROR_CODE = 18003;
17+
1518
/** Class capturing a tsconfig parse error. */
1619
export class TsconfigParseError extends Error {}
1720

@@ -45,8 +48,12 @@ export function parseTsconfigFile(
4548
{},
4649
);
4750

48-
if (parsed.errors.length) {
49-
throw new TsconfigParseError(formatDiagnostics(parsed.errors, fileSystem));
51+
// Skip the "No inputs found..." error since we don't want to interrupt the migration if a
52+
// tsconfig doesn't match a file. This will result in an empty `Program` which is still valid.
53+
const errors = parsed.errors.filter(diag => diag.code !== NO_INPUTS_ERROR_CODE);
54+
55+
if (errors.length) {
56+
throw new TsconfigParseError(formatDiagnostics(errors, fileSystem));
5057
}
5158

5259
return parsed;

0 commit comments

Comments
 (0)