Skip to content

Commit 99f4ff0

Browse files
clydinmgechev
authored andcommitted
refactor(@angular-devkit/schematics): allow rule to return void or rule promise
This allows a rule to conditionally not return a followup rule when asynchronous. This is useful to handle error conditions where no further action should be taken and returning void best expresses this case.
1 parent 9886e27 commit 99f4ff0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

etc/api/angular_devkit/schematics/src/_golden-api.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ export interface RequiredWorkflowExecutionContext {
419419
schematic: string;
420420
}
421421

422-
export declare type Rule = (tree: Tree, context: SchematicContext) => Tree | Observable<Tree> | Rule | Promise<void> | Promise<Rule> | void;
422+
export declare type Rule = (tree: Tree, context: SchematicContext) => Tree | Observable<Tree> | Rule | Promise<void | Rule> | void;
423423

424424
export declare type RuleFactory<T extends object> = (options: T) => Rule;
425425

packages/angular_devkit/schematics/src/engine/interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,4 @@ export type AsyncFileOperator = (tree: FileEntry) => Observable<FileEntry | null
227227
*/
228228
export type Source = (context: SchematicContext) => Tree | Observable<Tree>;
229229
export type Rule = (tree: Tree, context: SchematicContext) =>
230-
Tree | Observable<Tree> | Rule | Promise<void> | Promise<Rule> | void;
230+
Tree | Observable<Tree> | Rule | Promise<void | Rule> | void;

0 commit comments

Comments
 (0)