diff --git a/packages/schematics/angular/migrations/update-10/remove-solution-style-tsconfig.ts b/packages/schematics/angular/migrations/update-10/remove-solution-style-tsconfig.ts index 3dc86ee9f873..2518eeb11d1b 100644 --- a/packages/schematics/angular/migrations/update-10/remove-solution-style-tsconfig.ts +++ b/packages/schematics/angular/migrations/update-10/remove-solution-style-tsconfig.ts @@ -35,8 +35,7 @@ export default function (): Rule { return (host, context) => { const logger = context.logger; - const tsConfig = new JSONFile(host, 'tsconfig.json'); - const files = tsConfig.get(['files']); + const files = new JSONFile(host, 'tsconfig.json').get(['files']); if (!(Array.isArray(files) && files.length === 0)) { logger.info('Migration has already been executed.'); @@ -51,16 +50,15 @@ export default function (): Rule { // Iterate over all tsconfig files and change the extends from 'tsconfig.base.json' to 'tsconfig.json'. const extendsJsonPath = ['extends']; for (const path of visitExtendedJsonFiles(host.root)) { - const tsConfigDir = dirname(normalize(path)); - let tsConfigJson; try { - tsConfigJson = new JSONFile(host, path); + const tsConfigDir = dirname(normalize(path)); + const tsConfigJson = new JSONFile(host, path); const extendsValue = tsConfigJson.get(extendsJsonPath); if (typeof extendsValue === 'string' && '/tsconfig.base.json' === resolve(tsConfigDir, normalize(extendsValue))) { // tsconfig extends the workspace tsconfig path. - tsConfig.modify(extendsJsonPath, extendsValue.replace('tsconfig.base.json', 'tsconfig.json')); + tsConfigJson.modify(extendsJsonPath, extendsValue.replace('tsconfig.base.json', 'tsconfig.json')); } } catch (error) { logger.warn( diff --git a/packages/schematics/angular/migrations/update-10/remove-solution-style-tsconfig_spec.ts b/packages/schematics/angular/migrations/update-10/remove-solution-style-tsconfig_spec.ts index 04b452e77485..78c3c20a53a9 100644 --- a/packages/schematics/angular/migrations/update-10/remove-solution-style-tsconfig_spec.ts +++ b/packages/schematics/angular/migrations/update-10/remove-solution-style-tsconfig_spec.ts @@ -73,12 +73,12 @@ describe('Migration to remove "Solution Style" tsconfig', () => { createJsonFile(tree, 'tsconfig.json', { files: [] }); createJsonFile(tree, 'tsconfig.base.json', { compilerOptions }); createJsonFile(tree, 'tsconfig.common.json', { compilerOptions }); - createJsonFile(tree, 'src/tsconfig.json', { extends: './../tsconfig.json', compilerOptions }); - createJsonFile(tree, 'src/tsconfig.base.json', { extends: './../tsconfig.json', compilerOptions }); + createJsonFile(tree, 'src/tsconfig.json', { extends: './../tsconfig.base.json', compilerOptions }); + createJsonFile(tree, 'src/tsconfig.base.json', { extends: './../tsconfig.base.json', compilerOptions }); createJsonFile(tree, 'src/tsconfig.tsc.json', { extends: './tsconfig.base.json', compilerOptions }); createJsonFile(tree, 'src/tsconfig.app.json', { extends: './../tsconfig.common.json', compilerOptions }); - createJsonFile(tree, 'src/tsconfig.spec.json', { extends: './../tsconfig.json', compilerOptions }); - createJsonFile(tree, 'src/tsconfig.worker.json', { extends: './../tsconfig.json', compilerOptions }); + createJsonFile(tree, 'src/tsconfig.spec.json', { extends: './../tsconfig.base.json', compilerOptions }); + createJsonFile(tree, 'src/tsconfig.worker.json', { extends: './../tsconfig.base.json', compilerOptions }); }); it(`should rename 'tsconfig.base.json' to 'tsconfig.json'`, async () => {