Skip to content

fix(@schematics/angular): set explicit type for the module --route component - #34472

Open
MeAkib wants to merge 2 commits into
angular:mainfrom
MeAkib:fix/module-route-component-type
Open

MeAkib wants to merge 2 commits into
angular:mainfrom
MeAkib:fix/module-route-component-type

Conversation

@MeAkib

@MeAkib MeAkib commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

ng generate module --route generates a component and references it from the routing module template by its default file and class name (./foo, Foo). The component inherited the workspace type option, so in workspaces that set it (e.g. after updating to v20) the component was generated as foo.component.ts and the routing module import failed to resolve.

Pass an empty type, as the library and app-shell schematics do.

Fixes #34449

…component

`ng generate module --route` generates a component and references it from the routing module
template by its default file and class name (`./foo`, `Foo`). The component inherited the
workspace `type` option, so in workspaces that set it (e.g. after updating to v20) the component
was generated as `foo.component.ts` and the routing module import failed to resolve.

Pass an empty `type`, as the library and app-shell schematics do.

Fixes angular#34449

@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 ensures that when generating a module, the nested component does not inherit a type from the workspace defaults, preventing broken route templates. A corresponding unit test has been added. A review comment suggests using the public engine property instead of accessing the private _engineHost property in the test to register the options transform, which improves type safety and avoids relying on private implementation details.

Comment thread packages/schematics/angular/module/index_spec.ts Outdated
@alan-agius4
alan-agius4 self-requested a review October 22, 2026 11:14
@alan-agius4 alan-agius4 added target: minor This PR is targeted for the next minor release action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release and removed target: minor This PR is targeted for the next minor release labels Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer 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 app-shell and ng generate module --route produce broken imports when a component type is configured

2 participants