Argument type __Event is not assignable to parameter type Event

41 Views Asked by At

This is my JavaScript code:

class Dispatcher extends EventTarget {}

const dsp = new Dispatcher();
dsp.addEventListener('SOME_EVENT', function (event) {
    console.log(event);
});

const evt = new Event('SOME_EVENT');
dsp.dispatchEvent(evt);

My IDE (PhpStorm) display this warning:

Argument type __Event is not assignable to parameter type Event 

IDE screenshot

But the code runs perfectly:

/usr/bin/node /home/alex/.../main.js
Event {
  type: 'SOME_EVENT',
  defaultPrevented: false,
  cancelable: false,
  timeStamp: 33.53751400113106
}

Process finished with exit code 0

Why the Event constructor returns the __Event object?

1

There are 1 best solutions below

0
Alex Gusev On

All you need to do is delete the ./.idea/ folder from the root directory. The warning message will disappear.