nx
nx copied to clipboard
Trailing comma when using component generator with style set to none and changeDetection set
Current Behavior
Trailing comma when using component generator with style set to none and changeDetection set causing compilation error.
Expected Behavior
No trailing comma when using component generator with style set to none and changeDetection set
Steps to Reproduce
In nx.json set the component generator as:
"@nrwl/angular:component": {
"style": "none",
"changeDetection": "OnPush"
}
When running npx nx g c test output is as follows:

Environment
@nrwl/[email protected] @nrwl/[email protected]
Thanks for reporting this!
This is an issue with the @schematics/angular:component schematic in the Angular CLI repo. In the version of Nx you are in, when you generate using the @nrwl/angular:component generator you are actually running the @schematics/angular:component. In the latest versions of Nx, we do have a component generator implemented but it still invokes the @schematics/angular:component schematic for the base generation and it adds some things on top.
Please note this issue was reported in the Angular CLI repo here https://github.com/angular/angular-cli/issues/22857 and it was fixed here https://github.com/angular/angular-cli/pull/22905. Unfortunately, the solution seems to have been made available only in Angular v14 (Nx ^14.2.0). You could reach out there and ask the fix to be backported to the version you're using (Angular v12 support ends in November this year).
I'm closing this issue since it's not caused by Nx.