Skip to content

fix(@schematics/angular): use the generated class name when declaring in an NgModule - #34448

Open
MeAkib wants to merge 1 commit into
angular:mainfrom
MeAkib:fix/ng-module-declaration-class-name
Open

MeAkib wants to merge 1 commit into
angular:mainfrom
MeAkib:fix/ng-module-declaration-class-name

Conversation

@MeAkib

@MeAkib MeAkib commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

With addTypeToClassName: false, the component and directive schematics name the class without
the type, but the NgModule declaration was added with the type appended (e.g. FooComponent),
so the module no longer compiled.

Honour addTypeToClassName when computing the declared symbol.

Fixes #34447

… in an NgModule

With `addTypeToClassName: false`, the component and directive schematics name the class without
the type, but the NgModule declaration was added with the type appended (e.g. `FooComponent`),
so the module no longer compiled.

Honour `addTypeToClassName` when computing the declared symbol.

Fixes angular#34447

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for generating component and directive class names without their type suffix when addTypeToClassName is set to false. This is implemented by updating the DeclarationToNgModuleOptions interface and the addDeclarationToNgModule utility, and is verified with new unit tests. Feedback on the changes points out a bug in the new component schematic test where the assertion expects App instead of AppComponent in the module declarations, which will cause the test to fail.

Comment thread packages/schematics/angular/component/index_spec.ts

@alan-agius4 alan-agius4 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alan-agius4 alan-agius4 added target: patch This PR is targeted for the next patch release action: merge The PR is ready for merge by the caretaker labels Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @schematics/angular target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ng generate component/directive --module declares a class that doesn't exist when addTypeToClassName is false

2 participants