Reputation: 8655
I'm trying to convert my JavaScript code into TypeScript (1.8.9) and I am wondering what is the correct way declare or cast the data attached to event.
self.onmessage = function(e: Event){
if(e.data.schedules) processSchedules(e.data.schedules)
};
The data
portion gets marked red by PHPStorm. Should I cast it to some interface or any
in order to dismiss TS error?
Upvotes: 6
Views: 7777
Reputation: 52133
Your event should be a MessageEvent
, not Event
:
self.onmessage = (e:MessageEvent) => {
if (e.data.schedules)
// ...
}
Upvotes: 7