Angular schematics collection providing code generators for Angular applications, components, services, and other constructs.
—
Angular schematics are code generators that create and modify files in an Angular project. @schematics/angular provides 24 schematics that can be invoked through the Angular CLI or programmatically.
Creates a new Angular application with routing, styling, and initial project structure.
/**
* Creates a new Angular application
* @param options - Application configuration options
* @returns Rule for creating the application
*/
declare function application(options: ApplicationSchema): Rule;
interface ApplicationSchema {
name: string;
version?: string;
routing?: boolean;
inlineStyle?: boolean;
inlineTemplate?: boolean;
style?: Style;
skipTests?: boolean;
skipPackageJson?: boolean;
skipInstall?: boolean;
strict?: boolean;
standalone?: boolean;
ssr?: boolean;
viewEncapsulation?: ViewEncapsulation;
prefix?: string;
displayBlock?: boolean;
}
enum Style {
Css = 'css',
Scss = 'scss',
Sass = 'sass',
Less = 'less',
Styl = 'styl'
}Usage Example:
import { application } from '@schematics/angular';
const appRule = application({
name: 'my-app',
routing: true,
style: Style.Scss,
standalone: true
});Creates Angular components with template, styles, and test files.
/**
* Creates an Angular component
* @param options - Component configuration options
* @returns Rule for creating the component
*/
declare function component(options: ComponentSchema): Rule;
interface ComponentSchema {
name: string;
path?: string;
project?: string;
inlineTemplate?: boolean;
inlineStyle?: boolean;
displayBlock?: boolean;
changeDetection?: ChangeDetectionStrategy;
style?: Style;
type?: string;
skipTests?: boolean;
flat?: boolean;
skipImport?: boolean;
selector?: string;
module?: string;
export?: boolean;
prefix?: string;
standalone?: boolean;
}
enum ChangeDetectionStrategy {
Default = 'Default',
OnPush = 'OnPush'
}
enum ViewEncapsulation {
Emulated = 'Emulated',
None = 'None',
ShadowDom = 'ShadowDom'
}Creates Angular services with dependency injection setup.
/**
* Creates an Angular service
* @param options - Service configuration options
* @returns Rule for creating the service
*/
declare function service(options: ServiceSchema): Rule;
interface ServiceSchema {
name: string;
path?: string;
project?: string;
flat?: boolean;
skipTests?: boolean;
}Creates Angular modules with routing and component organization.
/**
* Creates an Angular module
* @param options - Module configuration options
* @returns Rule for creating the module
*/
declare function module(options: ModuleSchema): Rule;
interface ModuleSchema {
name: string;
path?: string;
project?: string;
routing?: boolean;
routingScope?: RoutingScope;
flat?: boolean;
commonModule?: boolean;
module?: string;
}
enum RoutingScope {
Child = 'Child',
Root = 'Root'
}Creates Angular directives for DOM manipulation and behavior.
/**
* Creates an Angular directive
* @param options - Directive configuration options
* @returns Rule for creating the directive
*/
declare function directive(options: DirectiveSchema): Rule;
interface DirectiveSchema {
name: string;
path?: string;
project?: string;
skipTests?: boolean;
skipImport?: boolean;
selector?: string;
flat?: boolean;
module?: string;
export?: boolean;
prefix?: string;
standalone?: boolean;
}Creates Angular pipes for data transformation in templates.
/**
* Creates an Angular pipe
* @param options - Pipe configuration options
* @returns Rule for creating the pipe
*/
declare function pipe(options: PipeSchema): Rule;
interface PipeSchema {
name: string;
path?: string;
project?: string;
skipTests?: boolean;
skipImport?: boolean;
flat?: boolean;
module?: string;
export?: boolean;
standalone?: boolean;
}Creates route guards for navigation control and security.
/**
* Creates a route guard
* @param options - Guard configuration options
* @returns Rule for creating the guard
*/
declare function guard(options: GuardSchema): Rule;
interface GuardSchema {
name: string;
path?: string;
project?: string;
skipTests?: boolean;
flat?: boolean;
implements?: GuardType[];
}
enum GuardType {
CanActivate = 'CanActivate',
CanActivateChild = 'CanActivateChild',
CanDeactivate = 'CanDeactivate',
CanLoad = 'CanLoad',
CanMatch = 'CanMatch'
}Creates HTTP interceptors for request/response processing.
/**
* Creates an HTTP interceptor
* @param options - Interceptor configuration options
* @returns Rule for creating the interceptor
*/
declare function interceptor(options: InterceptorSchema): Rule;
interface InterceptorSchema {
name: string;
path?: string;
project?: string;
skipTests?: boolean;
flat?: boolean;
functional?: boolean;
}Creates route resolvers for pre-loading data before navigation.
/**
* Creates a route resolver
* @param options - Resolver configuration options
* @returns Rule for creating the resolver
*/
declare function resolver(options: ResolverSchema): Rule;
interface ResolverSchema {
name: string;
path?: string;
project?: string;
skipTests?: boolean;
flat?: boolean;
}Creates Angular libraries for code sharing and distribution.
/**
* Creates an Angular library
* @param options - Library configuration options
* @returns Rule for creating the library
*/
declare function library(options: LibrarySchema): Rule;
interface LibrarySchema {
name: string;
prefix?: string;
skipPackageJson?: boolean;
skipInstall?: boolean;
skipTsConfig?: boolean;
standalone?: boolean;
}declare function class(options: ClassSchema): Rule;
interface ClassSchema {
name: string;
path?: string;
project?: string;
skipTests?: boolean;
type?: string;
}declare function interface(options: InterfaceSchema): Rule;
interface InterfaceSchema {
name: string;
path?: string;
project?: string;
prefix?: string;
type?: string;
}declare function enum(options: EnumSchema): Rule;
interface EnumSchema {
name: string;
path?: string;
project?: string;
type?: string;
}declare function serviceWorker(options: ServiceWorkerSchema): Rule;
interface ServiceWorkerSchema {
project: string;
target?: string;
configuration?: string;
}declare function webWorker(options: WebWorkerSchema): Rule;
interface WebWorkerSchema {
name: string;
path?: string;
project?: string;
target?: string;
snippet?: boolean;
}declare function appShell(options: AppShellSchema): Rule;
interface AppShellSchema {
project: string;
route?: string;
name?: string;
}declare function environments(options: EnvironmentsSchema): Rule;
interface EnvironmentsSchema {
project: string;
}declare function config(options: ConfigSchema): Rule;
interface ConfigSchema {
project: string;
type: ConfigType;
}
enum ConfigType {
Karma = 'karma',
Browserslist = 'browserslist'
}declare function aiConfig(options: AiConfigSchema): Rule;
interface AiConfigSchema {
project: string;
}declare function webWorker(options: WebWorkerSchema): Rule;
interface WebWorkerSchema {
name: string;
path?: string;
project?: string;
target?: string;
snippet?: boolean;
}declare function appShell(options: AppShellSchema): Rule;
interface AppShellSchema {
project: string;
route?: string;
name?: string;
}declare function environments(options: EnvironmentsSchema): Rule;
interface EnvironmentsSchema {
project: string;
}declare function config(options: ConfigSchema): Rule;
interface ConfigSchema {
project: string;
type: ConfigType;
}
enum ConfigType {
Karma = 'karma',
Browserslist = 'browserslist'
}These schematics are marked as hidden and are primarily used internally by Angular CLI:
@schematics/angular includes a migration collection for automatic project updates between Angular versions. These migrations handle breaking changes and deprecated APIs:
// Migration collection available at @schematics/angular/migrations.json
interface MigrationSchema {
version: string;
description: string;
factory: string;
}Usage:
ng update @angular/cli --migrate-only --from=19 --to=20Install with Tessl CLI
npx tessl i tessl/npm-schematics--angular