From c7f3fceb4cd18009fc749a50238e90aed94f0de1 Mon Sep 17 00:00:00 2001 From: MeAkib Date: Wed, 21 Oct 2026 00:10:05 +0600 Subject: [PATCH 1/2] fix(@schematics/angular): set explicit type for the app-shell component `ng generate app-shell` adds an `AppShell` import from `./app-shell/app-shell`, but the component it generates inherits the workspace `type` option. In workspaces that set `"@schematics/angular:component": { "type": "component" }`, such as those updated to v20, the component was generated as `app-shell.component.ts` and the import failed to resolve. Pass an empty `type`, as the library schematic does (661609e3e). Refs #34449 --- .../schematics/angular/app-shell/index.ts | 3 +++ .../angular/app-shell/index_spec.ts | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/packages/schematics/angular/app-shell/index.ts b/packages/schematics/angular/app-shell/index.ts index 20793404782b..4676fec483ae 100644 --- a/packages/schematics/angular/app-shell/index.ts +++ b/packages/schematics/angular/app-shell/index.ts @@ -210,6 +210,9 @@ const appShellSchematic: RuleFactory = createProjectSchematic( module: 'app.module.server.ts', project: options.project, standalone: isStandalone, + // The `AppShell` import added above expects the default file and class name, so the + // component must not inherit a `type` from the workspace. + type: '', }), ]); }, diff --git a/packages/schematics/angular/app-shell/index_spec.ts b/packages/schematics/angular/app-shell/index_spec.ts index fa6a664f9869..10be925bfda7 100644 --- a/packages/schematics/angular/app-shell/index_spec.ts +++ b/packages/schematics/angular/app-shell/index_spec.ts @@ -136,5 +136,27 @@ describe('App Shell Schematic', () => { const content = tree.readContent(filePath); expect(content).toContain(`import { AppShell } from './app-shell/app-shell';`); }); + + it('should not inherit the component `type` from the workspace defaults', async () => { + // The CLI applies the `schematics` defaults of `angular.json` to nested schematics as well. + // Emulate it with a fresh runner so that other tests are not affected. + const runner = new SchematicTestRunner( + '@schematics/angular', + require.resolve('../collection.json'), + ); + runner['_engineHost'].registerOptionsTransform( + (schematic: { name: string }, options: Record) => + schematic.name === 'component' && options['type'] === undefined + ? { ...options, type: 'component' } + : options, + ); + + const tree = await runner.runSchematic('app-shell', defaultOptions, appTree); + + expect(tree.exists('/projects/bar/src/app/app-shell/app-shell.ts')).toBe(true); + expect(tree.exists('/projects/bar/src/app/app-shell/app-shell.component.ts')).toBe(false); + const content = tree.readContent('/projects/bar/src/app/app.config.server.ts'); + expect(content).toContain(`import { AppShell } from './app-shell/app-shell';`); + }); }); }); From 17dedf1d2f675f30fe2b7f53c81a009dd1fdb4f5 Mon Sep 17 00:00:00 2001 From: MeAkib Date: Thu, 22 Oct 2026 08:05:01 +0600 Subject: [PATCH 2/2] fixup! fix(@schematics/angular): set explicit type for the app-shell component --- .../angular/app-shell/index_spec.ts | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/packages/schematics/angular/app-shell/index_spec.ts b/packages/schematics/angular/app-shell/index_spec.ts index 10be925bfda7..fa6a664f9869 100644 --- a/packages/schematics/angular/app-shell/index_spec.ts +++ b/packages/schematics/angular/app-shell/index_spec.ts @@ -136,27 +136,5 @@ describe('App Shell Schematic', () => { const content = tree.readContent(filePath); expect(content).toContain(`import { AppShell } from './app-shell/app-shell';`); }); - - it('should not inherit the component `type` from the workspace defaults', async () => { - // The CLI applies the `schematics` defaults of `angular.json` to nested schematics as well. - // Emulate it with a fresh runner so that other tests are not affected. - const runner = new SchematicTestRunner( - '@schematics/angular', - require.resolve('../collection.json'), - ); - runner['_engineHost'].registerOptionsTransform( - (schematic: { name: string }, options: Record) => - schematic.name === 'component' && options['type'] === undefined - ? { ...options, type: 'component' } - : options, - ); - - const tree = await runner.runSchematic('app-shell', defaultOptions, appTree); - - expect(tree.exists('/projects/bar/src/app/app-shell/app-shell.ts')).toBe(true); - expect(tree.exists('/projects/bar/src/app/app-shell/app-shell.component.ts')).toBe(false); - const content = tree.readContent('/projects/bar/src/app/app.config.server.ts'); - expect(content).toContain(`import { AppShell } from './app-shell/app-shell';`); - }); }); });