Two functions that are actually compatible, why does TypeScript report that "there is no compatible call signature"?

I have implemented a scaled-down version of EventTarget :

.
function test(foo: MyEventTarget | EventTarget) {
    if (foo instanceof EventTarget) {
        return foo.addEventListener("click", console.log);
    }
    else {
        return foo.addEventListener("click", console.log);
    }
}
// OK

but it"s so ugly.

so let me ask you:

  1. Is it a feature, or a bug?
  2. how should situations like feature or bug, be handled gracefully?
Mar.23,2021

this is a bug , which has not been resolved yet.

separate processing is also a solution, or through inheritance:

interface MyEventTarget extends EventTarget {
    addEventListener(
        type: string,
        listener: EventListener | EventListenerOrEventListenerObject,
        options?: boolean | AddEventListenerOptions
    ): void
}

function test(foo: MyEventTarget) {
    return foo.addEventListener('click', console.log);
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bec55f-31af0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bec55f-31af0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?