6

Closed

lib.d.ts provides incorrect constructor for MutationObserver

description

lib.d.ts contains an incorrect constructor:

declare var MutationObserver: {
prototype: MutationObserver;
new(): MutationObserver;
}

I think it should be:

declare var MutationObserver: {
prototype: MutationObserver;
new(callback:(records:MutationRecord[])=>any): MutationObserver;
}

See https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver?redirectlocale=en-US&redirectslug=DOM%2FMutationObserver#MutationObserverInit

Editing my local copy of lib.d.ts fixed the intellisense check, but produced the same error on compiling:

"Could not select overload for 'new' expression."
Closed Jul 21, 2014 at 6:44 PM by RyanCavanaugh
See mhegazy's comment

comments

j15r wrote Oct 3, 2013 at 1:57 AM

I just noticed this as well. It appears to be fixed in tip, but hasn't made it to a formal release yet.

j15r wrote Oct 3, 2013 at 2:16 AM

Scratch that. I was reading the wrong line. Definitely still an issue.

DRubino wrote Nov 6, 2013 at 2:32 AM

This is a problem for me too

RyanCavanaugh wrote Dec 9, 2013 at 7:18 PM

ENikS wrote Apr 12, 2014 at 9:14 PM

It is still an issue in 1.0

ENikS wrote Apr 12, 2014 at 10:36 PM

Please change it to be:
declare var MutationObserver: {
prototype: MutationObserver;
new(callback:(records:MutationRecord[])=>any): MutationObserver;
}

mhegazy wrote Apr 14, 2014 at 7:32 PM

This has been fixed in develop. check lib.dom.d.ts, it is defined as:

interface MutationObserver {
    observe(target: Node, options: MutationObserverInit): void;
    takeRecords(): MutationRecord[];
    disconnect(): void;
}
declare var MutationObserver: {
    prototype: MutationObserver;
    new (callback: (arr: MutationRecord[], observer: MutationObserver)=>any): MutationObserver;
}

ENikS wrote Apr 15, 2014 at 12:58 AM

If it is defined as new (callback: (arr: MutationRecord[], observer: MutationObserver)=>any): MutationObs - it is incorrect.
According to w3 is should be defined as "new MutationObserver(mutations: MutationRecord[])=>any)"
(http://www.w3.org/TR/dom/#mutation-observers)

ENikS wrote Apr 15, 2014 at 1:00 AM

new (callback: (mutations: MutationRecord[])=>any): MutationObs

mhegazy wrote Apr 15, 2014 at 6:01 PM

These typings have been auto-generated from the IE11 DOM definitions. We do not usually make manual changes to these parts of lib.d.ts, as the change will be overwritten once we update the file again. If IE changes that in their next version we will pick up the change as well. Sorry for the inconvenience.