Title: `ng generate app-shell` and `ng generate module --route` produce broken imports when a component `type` is configured · Issue #34449 · angular/angular-cli · GitHub
Open Graph Title: `ng generate app-shell` and `ng generate module --route` produce broken imports when a component `type` is configured · Issue #34449 · angular/angular-cli
X Title: `ng generate app-shell` and `ng generate module --route` produce broken imports when a component `type` is configured · Issue #34449 · angular/angular-cli
Description: Command generate Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was 19.x (before the v20 file naming change) Description ng generate app-shell and ng g...
Open Graph Description: Command generate Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was 19.x (before the v20 file naming change) De...
X Description: Command generate Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was 19.x (before the v20 file naming change) De...
Opengraph URL: https://github.com/angular/angular-cli/issues/34449
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`ng generate app-shell` and `ng generate module --route` produce broken imports when a component `type` is configured","articleBody":"### Command\n\ngenerate\n\n### Is this a regression?\n\n- [x] Yes, this behavior used to work in the previous version\n\n### The previous version in which this bug was not present was\n\n19.x (before the v20 file naming change)\n\n### Description\n\n`ng generate app-shell` and `ng generate module \u003cname> --route \u003cpath> --module \u003cparent>` generate a component and then\nreference it with a hard-coded file path and class name. Both assume the v20+ defaults (no type in the file or class\nname). When the workspace configures a component `type`, the component inherits it and the hard-coded references no\nlonger match, so the build fails.\n\nWorkspaces get a component `type` in two common ways:\n\n1. Every workspace updated to v20 with `ng update`: the migration that keeps the previous style guide behaviour\n (fdc6291dda) adds `\"@schematics/angular:component\": { \"type\": \"component\" }`.\n2. `ng new --file-name-style-guide=2016`, which adds `{ \"type\": \"component\", \"addTypeToClassName\": false }`.\n\nHard-coded references:\n\n- `packages/schematics/angular/app-shell/index.ts`: `withAppShell(AppShell)` and\n `insertImport(..., 'AppShell', './app-shell/app-shell')`.\n- `packages/schematics/angular/module/files/.../__name@dasherize__-routing__typeSeparator__module.ts.template` (and the\n non-routing module template for `--route` without a routing module): `import { \u003c%= classify(name) %> } from './\u003c%= dasherize(name) %>';`\n\nThe library schematic had the same problem (#26981) and was fixed in 661609e3e by passing an explicit `type: ''` to the\ncomponent schematic.\n\n### Minimal Reproduction\n\n**app-shell** (updated-workspace configuration):\n\n```sh\nng new ws --defaults\ncd ws\n# what `ng update` to v20 adds to angular.json under projects.ws.schematics:\n# \"@schematics/angular:component\": { \"type\": \"component\" }\nng generate app-shell\nng build\n```\n\nGenerated `src/app/app-shell/app-shell.component.ts` contains `export class AppShellComponent {}`, but\n`src/app/app.config.server.ts` contains:\n\n```ts\nimport { AppShell } from './app-shell/app-shell';\n...\nprovideServerRendering(withRoutes(serverRoutes), withAppShell(AppShell))\n```\n\n**module --route** (2016 file name style):\n\n```sh\nng new ws --no-standalone --file-name-style-guide=2016 --defaults\ncd ws\nng generate module feature --route feature --module app\nng build\n```\n\nGenerated `src/app/feature/feature-routing.module.ts`:\n\n```ts\nimport { Feature } from './feature'; // the file is feature.component.ts\n```\n\n### Exception or Error\n\n```text\n# app-shell\n✘ [ERROR] TS2307: Cannot find module './app-shell/app-shell' or its corresponding type declarations. [plugin angular-compiler]\n✘ [ERROR] Could not resolve \"./app-shell/app-shell\"\n\n# module --route\n✘ [ERROR] Could not resolve \"./feature\"\n✘ [ERROR] TS2307: Cannot find module './feature' or its corresponding type declarations. [plugin angular-compiler]\n```\n\n### Your Environment\n\n```text\nAngular CLI : 22.2.3\nNode.js : 24.15.0\nPackage Manager : npm 11.12.1\nOperating System : darwin arm64\n@schematics/angular : 22.2.3\n```\n\n### Anything else relevant?\n\n- Affected since 20.0.0 (hard-coded names from 23fc8e1e17, \"generate components without a `.component`\n extension/type\"). Same code on `21.2.x` and `22.2.x`.\n- Suggested fix: follow 661609e3e and pass `type: ''` (and `addTypeToClassName: false`, so the class name stays\n `AppShell`/`Feature`) to the component schematic in `app-shell` and `module`, so the generated files always match\n the references. Happy to send a PR.\n- The `module --route` case with `addTypeToClassName: false` also hits #\u003cissue for 01> (wrong NgModule declaration);\n link the two once filed.","author":{"url":"https://github.com/MeAkib","@type":"Person","name":"MeAkib"},"datePublished":"2026-10-20T18:09:49Z","url":"https://github.com/angular/angular-cli/issues/34449"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3d81f569-53c5-e460-df78-2e0cb86f4709 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CD5C:3E418A:11BCA35:1759E17:6B01E456 |
| html-safe-nonce | 1e6531181d7de938fbb9fd651a5373ad8d91f8f7a65e494d1b64b017660c2d93 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDVDOjNFNDE4QToxMUJDQTM1OjE3NTlFMTc6NkIwMUU0NTYiLCJ2aXNpdG9yX2lkIjoiMzkyMDU5NDkzMTU0NjE4NjgzOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 893468e4a3657f809798b644ec9451940be7f897d07732e51bf2e1c67fed2a7f |
| hovercard-subject-tag | issue:5946995910 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular-cli/34449/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2ac3ed8de96adf99560b273e52b9332a85a23fdf3521cedc1b6bfe3089275fc8/angular/angular-cli/issues/34449 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2ac3ed8de96adf99560b273e52b9332a85a23fdf3521cedc1b6bfe3089275fc8/angular/angular-cli/issues/34449 |
| og:image:alt | Command generate Is this a regression? Yes, this behavior used to work in the previous version The previous version in which this bug was not present was 19.x (before the v20 file naming change) De... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MeAkib |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular-cli git https://github.com/angular/angular-cli.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 36891867 |
| octolytics-dimension-repository_nwo | angular/angular-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 36891867 |
| octolytics-dimension-repository_network_root_nwo | angular/angular-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width