Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng generate module produce wrong code for specific code pattern #15923

Open
doggy8088 opened this issue Oct 23, 2019 · 0 comments
Open

ng generate module produce wrong code for specific code pattern #15923

doggy8088 opened this issue Oct 23, 2019 · 0 comments
Labels
area: schematics/angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Milestone

Comments

@doggy8088
Copy link
Contributor

馃悶 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?

@ngbot ngbot bot added this to the needsTriage milestone Oct 23, 2019
@alan-agius4 alan-agius4 added freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix labels Oct 23, 2019
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: schematics/angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Projects
None yet
Development

No branches or pull requests

2 participants