-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cdk/scrolling): improve template type checking for CdkVirtualForOf Directive #26609
Comments
implements ngTemplateContextGuard for CdkVirtualForOf directive fixes angular#26609
implements ngTemplateContextGuard for CdkVirtualForOf directive fixes angular#26609
Still an Issue |
If anyone wants a workaround, I was suggested one here: basically add: in the
declaration. |
@mstawick but this just gets completely blown away whenever we update packages right? Fixes like this just drop through the cracks and can't be considered safe in any way, as far as I can tell :( |
@medchat-layton I know this might not be ideal but for workarounds like this I like to use https://github.com/ds300/patch-package to create a diff of such workarounds that you can add to your repository. On |
@medchat-layton I completely agree with you, that's why I used the word "workaround". Given current state, not having proper type inference in templates destroys my productivity, so I'd rather apply the workaround after update if I have to, rather then have no workaround at all. |
I'm trying to figure it out in a way that would not require changing library files. In the past I managed to achive such thing for
and then you simply change It's not perfect but for me it gets job done. |
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
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Feature Description
Feature Description
The CdkVirtualForOf Directive in the "@angular/cdk/scrolling" module does not implement the ng-template context guard, as it is done at the *ngFor Structual Directive in the Angular Common package.
Thus, when using the *cdkVirtualFor Structual Directive in an HTML Template, the type of the item is "any".
Expample:
Although the type of the property "items" is "string[]", the type of "item" is "any".
Expected behavior
The type of the property "item" should be "string" when the type of "items" is "string[]".
Suggested solution
Implement the static method "ngTemplateContextGuard" for the CdkVirtualForOf Directive.
https://angular.io/guide/structural-directives#typing-the-directives-context
If you want, I can create a PR therefore, because I tried this solution already.
Use Case
No response
The text was updated successfully, but these errors were encountered: