SVG externs

152 views
Skip to first unread message

pablo platt

unread,
Aug 18, 2016, 1:38:57 PM8/18/16
to closure-comp...@googlegroups.com

Tyler Breisacher

unread,
Aug 18, 2016, 1:42:20 PM8/18/16
to closure-compiler
We have one in Google's internal repo that appears to be similar to the "closureidl" one you linked to; maybe we can open-source it.

What warnings are you seeing?

--

---
You received this message because you are subscribed to the Google Groups "Closure Compiler Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-compiler-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/closure-compiler-discuss/CANdLC8Vif8bB3KktqcMEu%3DL7S8JzT5ahoR%3D5rhbbkwbFRHZgUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

pablo platt

unread,
Aug 18, 2016, 2:18:19 PM8/18/16
to closure-comp...@googlegroups.com
svg is common. It'll be great if you could open-source the externs.

The original version has many warnings for window.prototype.X redefined:
https://closureidl.googlecode.com/files/svg.js

js/externs/svg.js:6817: WARNING - variable Window.prototype.SVGSVGElement redefined with type function (new:SVGSVGElement): ?, original definition at js/externs/svg.js:10842 with type function (new:SVGSVGElement): ?
function SVGSVGElement(){}

The updated version has the following two warnings:
https://github.com/Hunga1/closure-compiler/commit/93aebbe5103b5aeb4d0b8361e7f9a80ae0ea1f56

js/externs/svg.js:421: WARNING - mismatch of the addEventListener property type and the type of the property it overrides from interface EventTarget
original: function (this:EventTarget, string, (EventListener|function (Event): (boolean|undefined)|null), boolean): undefined
override: function (this:SVGElementInstance, string, (EventListener|function ((Event|null)): (boolean|undefined)|null), boolean=): undefined
SVGElementInstance.prototype.addEventListener = function(type, listener, opt_useCapture){};
^
Code:
https://github.com/Hunga1/closure-compiler/blob/93aebbe5103b5aeb4d0b8361e7f9a80ae0ea1f56/contrib/externs/svg.js#L421

js/externs/svg.js:429: WARNING - mismatch of the removeEventListener property type and the type of the property it overrides from interface EventTarget
original: function (this:EventTarget, string, (EventListener|function (Event): (boolean|undefined)|null), boolean): undefined
override: function (this:SVGElementInstance, string, (EventListener|function ((Event|null)): (boolean|undefined)|null), boolean=): undefined
SVGElementInstance.prototype.removeEventListener = function(type, listener, opt_useCapture){};

Code:
https://github.com/Hunga1/closure-compiler/blob/93aebbe5103b5aeb4d0b8361e7f9a80ae0ea1f56/contrib/externs/svg.js#L429

Thanks

On Thu, Aug 18, 2016 at 8:41 PM, 'Tyler Breisacher' via Closure Compiler Discuss <closure-comp...@googlegroups.com> wrote:
We have one in Google's internal repo that appears to be similar to the "closureidl" one you linked to; maybe we can open-source it.

What warnings are you seeing?
On Thu, Aug 18, 2016 at 10:38 AM, pablo platt <pablo...@gmail.com> wrote:

--

---
You received this message because you are subscribed to the Google Groups "Closure Compiler Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-compiler-discuss+unsubscr...@googlegroups.com.

--

---
You received this message because you are subscribed to the Google Groups "Closure Compiler Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-compiler-discuss+unsub...@googlegroups.com.

Can Kutlu Kınay

unread,
Oct 31, 2016, 12:10:07 AM10/31/16
to Closure Compiler Discuss
It's an old topic but I encountered this now. I also needed to use SVG Elements in my Closure project and I could get over this warnings (we have set compiler settings more strict so it was a blocker for me) by just replacing jsdoc of addEventListener and removeEventListener methods to plain @override directives.


/**
* @override
*/
SVGElementInstance.prototype.addEventListener = function(type, listener, opt_useCapture){};


/**
* @override
*/
SVGElementInstance.prototype.removeEventListener = function(type, listener, opt_useCapture){};

This seems to be a common way to document classes implements EventTarget. See usages in Closure Compiler externs:

Hope this helps.
To unsubscribe from this group and stop receiving emails from it, send an email to closure-compiler-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/closure-compiler-discuss/CANdLC8Vif8bB3KktqcMEu%3DL7S8JzT5ahoR%3D5rhbbkwbFRHZgUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

dpa...@chromium.org

unread,
Jun 8, 2017, 8:32:28 PM6/8/17
to Closure Compiler Discuss
Reviving this old thread. I am also looking for open source SVG externs, for the purposes of addressing a TODO in Chromium's codebase, at https://cs.chromium.org/chromium/src/ui/webui/resources/js/util.js?l=20-33. The link to  https://closureidl.googlecode.com/files/svg.js from the Closure compiler's docs does not work anymore.

Can Kutlu Kınay

unread,
Jun 9, 2017, 8:42:10 AM6/9/17
to Closure Compiler Discuss
SVG externs can still be accessible under Google Code archive here:
https://code.google.com/archive/p/closureidl/downloads

Not sure If its up to date anymore though.
Reply all
Reply to author
Forward
0 new messages