Skip to content

Commit 661609e

Browse files
crisbetodgp1130
authored andcommitted
fix(@schematics/angular): set explicit type in library schematic
Explicitly sets an empty `type` when the `library` calls into the `component` schematic for a few reasons: 1. The `type` for classes mostly makes sense in an application contenxt. E.g. libraries are unlikely to have guards. 2. The generated component is there primarily as an example and library authors are likely to either delete it or modify it to match their expected public API. 3. It ensures that the generated files remain correect if the `component` schematic ends up inheriting the `type` from the workspace.
1 parent 2016e53 commit 661609e

File tree

1 file changed

+4
-0
lines changed
  • packages/schematics/angular/library

1 file changed

+4
-0
lines changed

Diff for: packages/schematics/angular/library/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ export default function (options: LibraryOptions): Rule {
181181
export: true,
182182
standalone: options.standalone,
183183
project: packageName,
184+
// Explicitly set an empty `type` since it doesn't necessarily make sense in a library.
185+
// This also ensures that the generated files are valid even if the `component` schematic
186+
// inherits its `type` from the workspace.
187+
type: '',
184188
}),
185189
(_tree: Tree, context: SchematicContext) => {
186190
if (!options.skipPackageJson && !options.skipInstall) {

0 commit comments

Comments
 (0)