I recently upgraded our project to Angular 10 from version 8. Below is a piece of code that went buggy:
@ViewChild('searchTextBox', { read: false }) searchTextBox: ElementRef;
This was working in v8 but not in v10.
The fix is to assign the expected type to 'read' property.
@ViewChild('searchTextBox', { read: ElementRef }) searchTextBox: ElementRef;
As I am debugging this in v10, I noticed that the error is not reproducible when running ng serve
but will appear if you run ng serve --prod
.
Lesson Learned: Always do a sanity test in prod build. Note that prod build is not debuggable and takes a while to build.
Top comments (0)