ng generate module produce wrong code for specific code pattern

オープン
#15,923 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
angular, typescript
領域
cli, tooling

調査の方向性

記載されている ng new、ng g c、ng g module コマンドで問題を再現し、生成前後の src/app/app-routing.module.ts を調べます。lazy-loaded route が無効なカンマや削除された区切り文字なしで挿入され、既存の route1 が引き続き有効であれば完了です。

索引モデルが issue の本文から書いたものです。

説明

area: @schematics/angular freq1: low severity3: broken type: bug/fix

🐞 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
平均マージ
16時間 35分
マージ済み PR(30日)
176

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

angular/angular-cli のほかの issue

angular/angular-cli の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。