Skip to content

ng new --viewEncapsulation Native|None|ShadowDom generates invalid code #13742

@thojo

Description

@thojo

🐞 Bug report

Command (mark with an x)

- [x] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Yes, the previous version in which this bug was not present was: 7.3.2

Description

The fix for #13689 now generates a second comma between styleUrls and encapsulation. The comma behind styleUrls is now also present if the flag --viewEncapsulation is not set at all and styleUrls is the last property.

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],, // ❗ duplicate comma
  encapsulation: ViewEncapsulation.Native
})
export class AppComponent {
}
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'], // ❗ unnecessary comma
})
export class AppComponent {
}

🔬 Minimal Reproduction

  • ng new view-test --skipGit --skipInstall --viewEncapsulation None
  • ng new view-test --skipGit --skipInstall

🔥 Exception or Error

ERROR in src/app/app.component.ts(6,38): error TS1136: Property assignment expected.

🌍 Your Environment

Angular CLI: 7.3.3
Node: 10.15.1
OS: win32 x64
Angular: 7.2.6
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.13.3
@angular-devkit/build-angular     0.13.3
@angular-devkit/build-optimizer   0.13.3
@angular-devkit/build-webpack     0.13.3
@angular-devkit/core              7.3.3
@angular-devkit/schematics        7.3.3
@angular/cli                      7.3.3
@ngtools/webpack                  7.3.3
@schematics/angular               7.3.3
@schematics/update                0.13.3
rxjs                              6.3.3
typescript                        3.2.4
webpack                           4.29.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions