-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
Description
With Angular 19, components are standalone by default and do not require an explicit standalone: true flag. The @ionic/angular-toolkit:component schematic exhibits two inconsistent behaviors:
-
With
"standalone": trueinangular.jsonschematics- The generated component and test scaffold are correct for standalone usage.
- However, the component decorator still includes
standalone: trueexplicitly, which is redundant in Angular 19.
-
Without the
standaloneoption in schematics- The generated component decorator omits
standalone: true(correct). - The generated test
.spec.tsfalls back to the legacy NgModule-based pattern:rather than the standalone pattern:TestBed.configureTestingModule({ declarations: [TestComponent], imports: [IonicModule.forRoot()] }).compileComponents();
TestBed.configureTestingModule({ imports: [TestComponent], }).compileComponents();
- The generated component decorator omits
This inconsistency forces maintainers to either keep a redundant flag in their code or manually update specs.
Current Behavior
- With
standalone: truein schematics:- Component decorator contains
standalone: true. - Test spec uses standalone-compatible setup.
- Component decorator contains
- Without
standalonein schematics:- Component decorator is correct (no
standalone). - Test spec uses
declarationsandIonicModule.forRoot(), i.e., NgModule-based.
- Component decorator is correct (no
Expected Behavior
- The schematic should not inject
standalone: truein the component decorator (Angular 19 default). - The
.spec.tsshould consistently use the standalone testing pattern, regardless of the schematicsstandalonesetting:TestBed.configureTestingModule({ imports: [TestComponent], }).compileComponents();
Reproduction Steps
- Create a new Ionic + Angular 19 project:
ionic start myApp blank --type=angular cd myApp npm install @ionic/angular-toolkit@latest - Case A: Add to
angular.json:- Run
ionic generate component test - Observe redundant
standalone: trueintest.component.ts.
- Run
- Case B: Remove the
standaloneoption:"schematics": { "@ionic/angular-toolkit:component": { "styleext": "scss" } }
- Run
ionic generate component test - Observe legacy NgModule-based test in
test.component.spec.ts.
- Run
Environment
- @ionic/angular: 8.5.5
- @ionic/angular-toolkit: 12.2.0
- Angular CLI: 19.2
Thank you for looking into this! Please let me know if you need further details.
gabrielseron and Spinnenzunge
Metadata
Metadata
Assignees
Labels
No labels