From 5439460d1fe166f8ec34ab7d48f05e0dd7f6a946 Mon Sep 17 00:00:00 2001 From: Naji <54370141+naaajii@users.noreply.github.com> Date: Mon, 2 Sep 2024 15:22:16 +0500 Subject: [PATCH] fix(cdk/scrolling): adds ngTemplateContextGuard (#27276) BREAKING CHANGE: * Virtual scrolling lists now have proper type checking which can reveal some previously-hidden compilation errors. * fix(cdk/scrolling): adds ngTemplateContextGuard implements ngTemplateContextGuard for CdkVirtualForOf directive fixes #26609 * fixup! fix(cdk/scrolling): adds ngTemplateContextGuard --- src/cdk/scrolling/virtual-for-of.ts | 7 +++++++ tools/public_api_guard/cdk/scrolling.md | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/cdk/scrolling/virtual-for-of.ts b/src/cdk/scrolling/virtual-for-of.ts index 2b1d0b89c137..0407383f97a5 100644 --- a/src/cdk/scrolling/virtual-for-of.ts +++ b/src/cdk/scrolling/virtual-for-of.ts @@ -395,4 +395,11 @@ export class CdkVirtualForOf index, }; } + + static ngTemplateContextGuard( + directive: CdkVirtualForOf, + context: unknown, + ): context is CdkVirtualForOfContext { + return true; + } } diff --git a/tools/public_api_guard/cdk/scrolling.md b/tools/public_api_guard/cdk/scrolling.md index ca520ef4b7df..014312a5189b 100644 --- a/tools/public_api_guard/cdk/scrolling.md +++ b/tools/public_api_guard/cdk/scrolling.md @@ -120,6 +120,8 @@ export class CdkVirtualForOf implements CdkVirtualScrollRepeater, Collecti ngDoCheck(): void; // (undocumented) ngOnDestroy(): void; + // (undocumented) + static ngTemplateContextGuard(directive: CdkVirtualForOf, context: unknown): context is CdkVirtualForOfContext; readonly viewChange: Subject; // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration, "[cdkVirtualFor][cdkVirtualForOf]", never, { "cdkVirtualForOf": { "alias": "cdkVirtualForOf"; "required": false; }; "cdkVirtualForTrackBy": { "alias": "cdkVirtualForTrackBy"; "required": false; }; "cdkVirtualForTemplate": { "alias": "cdkVirtualForTemplate"; "required": false; }; "cdkVirtualForTemplateCacheSize": { "alias": "cdkVirtualForTemplateCacheSize"; "required": false; }; }, {}, never, never, true, never>;