angular / angular/angular-cli

ng g module with route option not working with the new provideRouter

未關閉
#24,497 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
area: @schematics/angular freq1: low severity3: broken type: bug/fix
主要語言
TypeScript
星號
27k
分支
11.8k
平均合併
14 小時 23 分鐘
30 天內合併 PR
162

描述

### 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

_No response_

### Description

when using the new way `provideRouter` the command `ng g m foo --route=foo -m=app` stop working

### Minimal Reproduction

create new angular 15 project
in `app-routing.module.ts`

1. remove `AppRoutingModule`
2. export the `routes` const

in `app.module.ts`

1. remove `AppRoutingModule` from `import` array
2. add `provideRouter(routes)` to the `providers` array

then in the command line run `ng g m foo --route=foo -m=app`

### Exception or Error

```text
Couldn't find a route declaration in /src/app/app-routing.module.ts.
Use the '--module' option to specify a different routing module.
```

### Your Environment

```text
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1500.5
@angular-devkit/build-angular 15.0.5
@angular-devkit/core 15.0.5
@angular-devkit/schematics 15.0.5
@angular/cli 15.0.5
@schematics/angular 15.0.5
rxjs 7.5.7
typescript 4.8.4
```

### Anything else relevant?

changing the file name from `app-routing.module.ts` to `routes.ts` gives a different but similar error message
```
Couldn't find a route declaration in /src/app/app.module.ts.
Use the '--module' option to specify a different routing module.
```

貢獻指南

開啟貢獻指南

研究方向

在使用 `provideRouter` 的 Angular 15 專案中重現 `ng g m foo --route=foo -m=app`,然後對照 `app-routing.module.ts` 和 `app.module.ts` 檢查模組產生中的路由處理。完成標準是:該命令能夠找到匯出的路由宣告,並在沒有所示錯誤的情況下產生包含要求路由的模組。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
angular, typescript
領域
cli, tooling
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。