feat(ivy): support template type check narrowing for *ngFor and *ngIf (#26203)
This commit adds an ngTemplateGuard_ngIf static method to the NgIf directive and an ngTemplateContextGuard static method to NgFor. The function of these two static methods is to enable type narrowing within generated type checking code for consumers of the directives. PR Close #26203
This commit is contained in:

committed by
Jason Aden

parent
868047e87f
commit
36d6e6076e
2
tools/public_api_guard/common/common.d.ts
vendored
2
tools/public_api_guard/common/common.d.ts
vendored
@ -263,6 +263,7 @@ export declare class NgForOf<T> implements DoCheck {
|
||||
ngForTrackBy: TrackByFunction<T>;
|
||||
constructor(_viewContainer: ViewContainerRef, _template: TemplateRef<NgForOfContext<T>>, _differs: IterableDiffers);
|
||||
ngDoCheck(): void;
|
||||
static ngTemplateContextGuard<T>(dir: NgForOf<T>, ctx: any): ctx is NgForOfContext<T>;
|
||||
}
|
||||
|
||||
export declare class NgForOfContext<T> {
|
||||
@ -282,6 +283,7 @@ export declare class NgIf {
|
||||
ngIfElse: TemplateRef<NgIfContext> | null;
|
||||
ngIfThen: TemplateRef<NgIfContext> | null;
|
||||
constructor(_viewContainer: ViewContainerRef, templateRef: TemplateRef<NgIfContext>);
|
||||
static ngTemplateGuard_ngIf<E>(dir: NgIf, expr: E): expr is NonNullable<E>;
|
||||
}
|
||||
|
||||
export declare class NgIfContext {
|
||||
|
Reference in New Issue
Block a user