79613423

Date: 2025-05-09 02:51:52
Score: 0.5
Natty:
Report link

Well, it seems that you have to either pass a second type parameter or pass no type parameters at all:

searchBar = viewChild<SearchBarComponent, ElementRef>('searchBar', { read: ElementRef });

Or

searchBar = viewChild('searchBar', { read: ElementRef });

This is TypeScript behavior. Since the read option relies on the second type, it either has to be specified or no types should be specified - at which TypeScript will infer the type from whatever you pass in.

Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Schnitzler