You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(@schematics/angular): Add addTypeToClassName option to relevant schematics
Introduces a new `addTypeToClassName` option to the `component`, `directive`, and `service` schematics. This option controls whether the schematic's `type` (e.g., 'Component', 'Directive', 'Service') is appended to the generated class name.
When `fileNameStyleGuide` is set to `'2016'` in `ng new`, `addTypeToClassName` is automatically set to `false` for these schematics in `angular.json`. This ensures that while file names follow the 2016 style (e.g., `app.component.ts`), class names remain concise (e.g., `AppComponent` instead of `AppComponentComponent`), aligning with future selectorless template conventions.
This change provides greater flexibility in naming conventions, allowing users to choose between more verbose class names (default for 2025 style guide) and more concise ones (for 2016 style guide).
Copy file name to clipboardExpand all lines: packages/schematics/angular/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.spec.ts.template
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
import { ComponentFixture, TestBed } from '@angular/core/testing';
Copy file name to clipboardExpand all lines: packages/schematics/angular/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template
Copy file name to clipboardExpand all lines: packages/schematics/angular/component/schema.json
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -95,6 +95,11 @@
95
95
"type": "string",
96
96
"description": "Append a custom type to the component's filename. For example, if you set the type to `container`, the file will be named `my-component.container.ts`."
97
97
},
98
+
"addTypeToClassName": {
99
+
"type": "boolean",
100
+
"default": true,
101
+
"description": "When true, the 'type' option will be appended to the generated class name. When false, only the file name will include the type."
102
+
},
98
103
"skipTests": {
99
104
"type": "boolean",
100
105
"description": "Skip the generation of unit test files `spec.ts`.",
0 commit comments