Repository navigation
Type definition of CustomEvent constructor needs parameter(s). #2029
Description
Activity
- addedDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptBugA bug in TypeScriptA bug in TypeScript
on Feb 13, 2015 - addedRevisitAn issue worth coming back toAn issue worth coming back to
on Mar 24, 2015 It looks like the
Eventconstructor has the same issue--should I file a separate ticket on that?Zhengbo Li (@zhengbli) is working on an updated library typings. I believe this should be handled by his change. so stay tuned.
great--thanks!
- assigned and unassigned
on Apr 7, 2015 - addedFixedA PR has been merged for this issueA PR has been merged for this issueand removedBugA bug in TypeScriptA bug in TypeScript
on Apr 17, 2015 Is it in 1.5 alpha already? Because I cannot instance CustomEvent or even Event, this does not works:
new CustomEvent('test');
This was not in 1.5-alpha but should be in the next release. you can find the updated lib.d.ts in https://github.com/Microsoft/TypeScript/blob/release-1.5/bin/lib.dom.d.ts
Yep, thank you! I just wondered if it was already in alpha.
Hmm.. just updated to beta version now I cannot use
DateViewor invokeinitCustomEventonCustomEventbecause it says what it's justEvent. I know I can download all these .d.ts files manually, but this does not seems right anyway.Arthur Stolyar (@NekR) sorry about that. The issue is fixed in master, but did not make it in time for the beta. see #2953 for more details. it should be fixed in the next release. As a work around for now, you can copy the definitions of DataView from https://github.com/Microsoft/TypeScript/blob/master/src/lib/extensions.d.ts#L48 locally.
Mohamed Hegazy (@mhegazy) I will copy it, thanks! But what about
initCustomEvent, is it fixed in master? I mean, for now of course I will useCustomEventsince it's now exists with correct definition, but there are environments which do not supportsCustomEventit requiresinitCustomEventto be used.I am not sure i understand the issue with CustomEvent, this works file for me:
var c: CustomEvent; c.initCustomEvent("custom", true, false, undefined);
This:
var event = document.createEvent('CustomEvent'); event.initCustomEvent('test', true, true, void 0); this.node.dispatchEvent(event);
produces this error:
error TS2339: Property 'initCustomEvent' does not exist on type 'Event'.This:
var event:CustomEvent = document.createEvent('CustomEvent'); event.initCustomEvent('test', true, true, void 0); this.node.dispatchEvent(event);
produces this error:
error TS2322: Type 'Event' is not assignable to type 'CustomEvent'. Property 'detail' is missing in type 'Event'.And only casting works:
var event = <CustomEvent>document.createEvent('CustomEvent'); event.initCustomEvent('test', true, true, void 0); this.node.dispatchEvent(event);
First case worked just fine
30 mins2 hours ago when I was on TS1.5-Alpha.Reacted by Jørgen KristiansenThanks Arthur Stolyar (@NekR). Zhengbo Li (@zhengbli) is fixing this now. we should have a working lib.d.ts for you to try soon. I have logged a different issue for is under #2975.
- locked and limited conversation to collaborators
on Jun 18, 2018
Type definition of CustomEvent constructor needs at least one parameter.
(The constructor of Event class also needs one parameter, actually.)
Since the current definition has no parameter, I encountered an error when I run a generated JS code by
Jasmine with node.
Following links are about CustomEvent class .
https://dom.spec.whatwg.org/#interface-customevent
https://developer.mozilla.org/en/docs/Web/API/CustomEvent
http://html5index.org/DOM%20-%20EventInit.html
http://html5index.org/DOM%20-%20CustomEventInit.html
I wrongly send a pull request #2007 on this issue.
Sorry about that.