Skip to content

Commit 1544525

Browse files
authored
Merge pull request #9961 from IgniteUI/dpetev/migration-tsconfig-fix
fix(migrations): read tsconfig using typescript's parser
2 parents 85cb244 + e9f3216 commit 1544525

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

projects/igniteui-angular/migrations/common/UpdateChanges.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -489,16 +489,15 @@ export class UpdateChanges {
489489
return;
490490
}
491491
let content;
492-
try {
493-
// there could be comments in the json file and JSON.parse would fail
494-
// TODO: use some 3rd party parser or write our own.
495-
// @angular-devkit/core.parseJson is deprecated
496-
content = JSON.parse(originalContent);
497-
} catch (e: any) {
492+
// use ts parser as it handles jsonc-style files w/ comments
493+
const result = ts.parseConfigFileTextToJson(TSCONFIG_PATH, originalContent);
494+
if (!result.error) {
495+
content = result.config;
496+
} else {
498497
this.context?.logger
499498
.warn(`Could not parse ${TSCONFIG_PATH}. Angular Ivy language service might be unavailable during migrations.`);
500499
this.context?.logger
501-
.warn(`Error:\n${e}`);
500+
.warn(`Error:\n${result.error}`);
502501
return;
503502
}
504503
if (!content.angularCompilerOptions) {

0 commit comments

Comments
 (0)