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(angular): generate directives without a .directive/Directive suffix/type (#31236)
- Update generators to generate directives without the
`.directive`/`Directive` suffix/type by default for Angular v20
- Keep the ability to generate directives with the
`.directive`/`Directive` suffix/type by providing the `type` option for
the `@nx/angular:directive` and `@nx/angular:scam-directive` generators
- When the workspace uses a version lower than v20, the generators will
still generate directives with the `.directive`/`Directive` suffix/type
by default
Note: a migration will be provided in a separate PR so existing
workspaces continue generating directives with the
`.directive`/`Directive` suffix/type.
Copy file name to clipboardExpand all lines: docs/generated/packages/angular/generators/directive.json
+10-2
Original file line number
Diff line number
Diff line change
@@ -15,11 +15,15 @@
15
15
"command": "nx g @nx/angular:directive mylib/src/lib/foo.directive.ts"
16
16
},
17
17
{
18
-
"description": "Generate a directive without providing the file extension. It results in the directive `FooDirective` at `mylib/src/lib/foo.directive.ts`",
18
+
"description": "Generate a directive without providing the file extension. It results in the directive `Foo` at `mylib/src/lib/foo.ts`",
19
19
"command": "nx g @nx/angular:directive mylib/src/lib/foo"
20
20
},
21
21
{
22
-
"description": "Generate a directive with the exported symbol different from the file name. It results in the directive `CustomDirective` at `mylib/src/lib/foo.directive.ts`",
22
+
"description": "Generate a directive with a given type/suffix. It results in the directive `FooDirective` at `mylib/src/lib/foo.directive.ts`",
23
+
"command": "nx g @nx/angular:directive mylib/src/lib/foo --type=directive"
24
+
},
25
+
{
26
+
"description": "Generate a directive with the exported symbol different from the file name. It results in the directive `Custom` at `mylib/src/lib/foo.ts`",
23
27
"command": "nx g @nx/angular:directive mylib/src/lib/foo --name=custom"
24
28
}
25
29
],
@@ -73,6 +77,10 @@
73
77
"default": false,
74
78
"description": "The declaring NgModule exports this directive."
75
79
},
80
+
"type": {
81
+
"type": "string",
82
+
"description": "Append a custom type to the directive's filename. It defaults to 'directive' for Angular versions below v20. For Angular v20 and above, no type is appended unless specified."
Copy file name to clipboardExpand all lines: docs/generated/packages/angular/generators/scam-directive.json
+10-2
Original file line number
Diff line number
Diff line change
@@ -13,11 +13,15 @@
13
13
"command": "nx g @nx/angular:scam-directive mylib/src/lib/foo.directive.ts"
14
14
},
15
15
{
16
-
"description": "Generate a directive without providing the file extension. It results in the directive `FooDirective` at `mylib/src/lib/foo.directive.ts`",
16
+
"description": "Generate a directive without providing the file extension. It results in the directive `Foo` at `mylib/src/lib/foo.ts`",
17
17
"command": "nx g @nx/angular:scam-directive mylib/src/lib/foo"
18
18
},
19
19
{
20
-
"description": "Generate a directive with the exported symbol different from the file name. It results in the directive `CustomDirective` at `mylib/src/lib/foo.directive.ts`",
20
+
"description": "Generate a directive with a given type/suffix. It results in the directive `FooDirective` at `mylib/src/lib/foo.directive.ts`",
21
+
"command": "nx g @nx/angular:scam-directive mylib/src/lib/foo --type=directive"
22
+
},
23
+
{
24
+
"description": "Generate a directive with the exported symbol different from the file name. It results in the directive `Custom` at `mylib/src/lib/foo.ts`",
21
25
"command": "nx g @nx/angular:scam-directive mylib/src/lib/foo --name=custom"
22
26
}
23
27
],
@@ -65,6 +69,10 @@
65
69
"default": true,
66
70
"x-priority": "important"
67
71
},
72
+
"type": {
73
+
"type": "string",
74
+
"description": "Append a custom type to the directive's filename. It defaults to 'directive' for Angular versions below v20. For Angular v20 and above, no type is appended unless specified."
0 commit comments