You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(cdk/scrolling): expand type for "cdkVirtualForOf" input to… (#17421)
Currently the `cdkVirtualForOf` input accepts `null` or `undefined` as valid
values. Although when using strict template input type checking
(which will be supported by `ngtsc`), passing `null` or `undefined`
with strict null checks enabled causes a type check failure because
the type definition of the input becomes too strict with "--strictNullChecks" enabled.
For extra content: by default if strict null checks are not enabled, `null` or `undefined`
are assignable to _every_ type. The current type definiton of the `cdkVirtualForOf` input
is incorrectly making the assumption that `null` or `undefined` are always assignable.
The type of the input needs to be expanded to explicitly accept `null` or
`undefined` to behave consistently regardless of the `strictNullChecks` flag.
A common scenario where this breaks is the use of `cdkVirtualFor` in combination
with the async pipe from `@angular/common`. This is because the async pipe returns
`null` until a value has been emitted. This means that with strict null checks, the type
checking will fail because `null` is not allowed.
This is similar to what we did for `ngFor` in framework: angular/angular@c1bb886Fixes#17411
0 commit comments