From c3f60f92f748381f8293311f483f1b35071d9216 Mon Sep 17 00:00:00 2001 From: nagahara-naoki <118710021+nagahara-naoki@users.noreply.github.com> Date: Wed, 11 Nov 2026 20:59:41 +0900 Subject: [PATCH] fix(@schematics/angular): set explicit type for the application root component Pass an empty type for the 2025 application root component so workspace component defaults cannot produce filenames that differ from the application templates. Keep the 2016 naming behavior and ordinary component defaults intact. Add an E2E regression test that builds both naming styles with a workspace type configured and verifies that separate component generation still uses that type. Closes #34684 --- .../schematics/angular/application/index.ts | 2 ++ .../application-workspace-type-default.ts | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/e2e/tests/generate/application/application-workspace-type-default.ts diff --git a/packages/schematics/angular/application/index.ts b/packages/schematics/angular/application/index.ts index cac60c23177b..969dc08ff70c 100644 --- a/packages/schematics/angular/application/index.ts +++ b/packages/schematics/angular/application/index.ts @@ -420,6 +420,8 @@ function getComponentOptions(options: ApplicationOptions): Partial { + config.schematics = { + '@schematics/angular:component': { type: 'component' }, + }; + }); + + for (const style of ['2025', '2016']) { + const project = `app-${style}`; + const appPath = `projects/${project}/src/app`; + const componentName = style === '2016' ? 'app.component' : 'app'; + + await ng( + 'generate', + 'application', + project, + `--file-name-style-guide=${style}`, + '--style=css', + '--ssr=false', + '--skip-install', + ); + await ng('build', project, '--configuration=development'); + await expectFileToMatch(`${appPath}/${componentName}.ts`, `styleUrl: './${componentName}.css'`); + await expectFileNotToExist(`${appPath}/${style === '2016' ? 'app' : 'app.component'}.ts`); + } + + // Ordinary component generation should still use the workspace default. + await ng('generate', 'component', 'example', '--project=app-2025', '--skip-tests'); + await expectFileToMatch('projects/app-2025/src/app/example/example.component.ts', 'export class'); +}