ngOnChanges(changes: SimpleChanges) {
const {previousValue: prevDate, currentValue: currDate}: SimpleChange = changes.dateFilter;
}
In the above code snippet I want to specify type DateFilter to the prevDate and currDate variables. How can I achieve that?
I tried like <DateFilter>prevDate and is not working.
previousValueproperty of typeDateFilterinSimpleChanges?SimpleChangesclass is provided by angular, we don't have control over itchanges.dateFilteritself not of typeDateFilter?prevDateandcurrentValueget their type from the destructured propertiespreviousValueandcurrentValuebelonging tochanges.dateFilter.changesis of typeSimpleChangessochanges.dateFilterbecomes of typeSimpleChangewhich has propertiespreviousValueandcurrentValue. Both of them represent angular@Input() dateFilter: DateFilter. But inngOnChanges()when fetched fromchanges.dateFilter.previousValue, the type is not set, we have explicitly set it. Which I can do in multi-line, but wanted to know if possible while de-structuring