CLI

generate class

Command
ng generate class
ng generate cl

Creates a new class in your project. Classes are the fundamental building blocks for object-oriented programming in TypeScript. They provide a blueprint for creating objects with properties and methods. This schematic helps you generate a new class with the basic structure and optional test files.

Arguments

name

The name for the new class. This will be used to create the class file (e.g., my-class.ts) and, if enabled, the corresponding test file my-class.spec.ts.

Value Typestring

Options

project

The name of the project where the class should be added. If not specified, the CLI will determine the project from the current directory.

Value Typestring
skip-tests

Skip the generation of a unit test file spec.ts for the new class.

Value TypebooleanDefaultfalse
type

Adds a custom type to the filename, allowing you to create more descriptive class names. For example, if you set the type to helper, the filename will be my-class.helper.ts.

Value Typestring
Jump to details