ng generate module produce wrong code for specific code pattern
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- angular, typescript
研究方向
使用列出的 ng new、ng g c 和 ng g module 命令重現此問題,然後檢查產生前後的 src/app/app-routing.module.ts。完成的標準是:延遲載入路由插入時沒有無效的逗號或遺失的分隔符號,同時現有的 route1 仍然有效。
由索引模型根據 Issue 內容生成。
描述
🐞 Bug report
Command (mark with an x)
- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [x] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Is this a regression?
No.
Description
The ng generate module produce wrong code.
🔬 Minimal Reproduction
ng new demo1 --routing --style css
cd demo1
ng g c test1
Add route config in src/app/app-routing.module.ts just like below:
const route1 = { path: 'test1', component: Test1Component };
const routes: Routes = [
route1
];
Then I creating an lazy-loaded module named test.
ng g module test --route test --module app
Then the route config will turn into this. And this is wrong.
const route1 = { path: 'test1', component: Test1Component };
const routes: Routes = [,
{ path: 'test', loadChildren: () => import('./test/test.module').then(m => m.TestModule) }
route1
];
🔥 Exception or Error
ERROR in Cannot read property 'loadChildren' of undefined
🌍 Your Environment
Angular CLI: 8.3.13
Node: 10.16.3
OS: win32 x64
Angular: 8.2.11
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.803.13
@angular-devkit/build-angular 0.803.13
@angular-devkit/build-optimizer 0.803.13
@angular-devkit/build-webpack 0.803.13
@angular-devkit/core 8.3.13
@angular-devkit/schematics 8.3.13
@angular/cli 8.3.13
@ngtools/webpack 8.3.13
@schematics/angular 8.3.13
@schematics/update 0.803.13
rxjs 6.4.0
typescript 3.5.3
webpack 4.39.2
Anything else relevant?
- 主要語言
- TypeScript
- 星號
- 27k
- 分支
- 11.8k
- 平均合併
- 17 小時 21 分鐘
- 30 天內合併 PR
- 181
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
angular/angular-cli 的其他 Issue
-
area: @angular/build gemini-triaged
難度 2/5 1-3 小時 新手友好度 74/100
angular/angular-cli#33955 ·
-
area: @angular/cli gemini-triaged
難度 2/5 1-3 小時 新手友好度 72/100
angular/angular-cli#33055 · 1 則留言 · 3 個 reaction ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34131 · 已指派 1 人 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34130 · 已指派 1 人 ·
-
angular/build:library area: @angular/build gemini-triaged
angular/angular-cli#34128 · 已指派 1 人 ·
查看 angular/angular-cli 的全部 Issue
相似的 Issue
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) 未關閉
難度 2/5 1-3 小時 新手友好度 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 2/5 1-3 小時 新手友好度 65/100
-
難度 1/5 1 小時以內 新手友好度 85/100
-
Mend: dependency security vulnerability untriaged
難度 2/5 1-3 小時 新手友好度 70/100