Trouble with typedefs

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Trouble with typedefs

Harbs
I have an issue with some typedefs and I can’t figure out why a value is being minimized.

I created some typedefs for hammer.js: https://www.dropbox.com/s/on4cyi02t0tiyue/hammer.swc?dl=0 <https://www.dropbox.com/s/on4cyi02t0tiyue/hammer.swc?dl=0>

In my app I have the following code:

private static function getMouseEventFromHammer(ev:io.github.hammerjs.Event):FakeMouseEvent{
    var mouseEv:FakeMouseEvent = new FakeMouseEvent(ev.type);
    mouseEv.localX = ev.center.x;
    mouseEv.localY = ev.center.y;
    mouseEv.target = ev.target;
    return mouseEv;
}

(FakeMouseEvent is a subclass of MouseEvent which allows setting the target.)

This compiles to:

/**
 * @private
 * @param {io.github.hammerjs.Event} ev
 * @return {com.printui.view.events.FakeMouseEvent}
 */
com.printui.controller.MouseManager.getMouseEventFromHammer = function(ev) {
  var /** @type {com.printui.view.events.FakeMouseEvent} */ mouseEv = new com.printui.view.events.FakeMouseEvent(ev.type);
  mouseEv.localX = ev.center.x;
  mouseEv.localY = ev.center.y;
  mouseEv.target = ev.target;
  return mouseEv;
};

which gets minified to:
function V8(a){var b=new t_(a.type);b.localX=a.YD.x;b.localY=a.YD.y;b.target=a.target;return b}

Why is center being renamed to YD?

I don’t see the externs for io.github.hammerjs.Event or io.github.hammerjs.Center. Isn’t that supposed to be copied somewhere?

Where am I going off?

Harbs
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with typedefs

Alex Harui-2
How did you create the SWC?  I think typedefs JS files have to be an
externs folder not in js/out.  If the typedefs source is AS then make sure
@externs is in the ASDoc for the class.

HTH,
-Alex

On 9/7/17, 4:31 AM, "Harbs" <[hidden email]> wrote:

>I have an issue with some typedefs and I can’t figure out why a value is
>being minimized.
>
>I created some typedefs for hammer.js:
>https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.dropb
>ox.com%2Fs%2Fon4cyi02t0tiyue%2Fhammer.swc%3Fdl%3D0&data=02%7C01%7C%7C0fb9c
>157a58343c9531408d4f5e405db%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C6
>36403807078901922&sdata=5ISCyGEdMfzErAbwNLyxFQmicQwWCOYqLdEkxh9AVrw%3D&res
>erved=0
><https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.drop
>box.com%2Fs%2Fon4cyi02t0tiyue%2Fhammer.swc%3Fdl%3D0&data=02%7C01%7C%7C0fb9
>c157a58343c9531408d4f5e405db%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C
>636403807078901922&sdata=5ISCyGEdMfzErAbwNLyxFQmicQwWCOYqLdEkxh9AVrw%3D&re
>served=0>
>
>In my app I have the following code:
>
>private static function
>getMouseEventFromHammer(ev:io.github.hammerjs.Event):FakeMouseEvent{
>    var mouseEv:FakeMouseEvent = new FakeMouseEvent(ev.type);
>    mouseEv.localX = ev.center.x;
>    mouseEv.localY = ev.center.y;
>    mouseEv.target = ev.target;
>    return mouseEv;
>}
>
>(FakeMouseEvent is a subclass of MouseEvent which allows setting the
>target.)
>
>This compiles to:
>
>/**
> * @private
> * @param {io.github.hammerjs.Event} ev
> * @return {com.printui.view.events.FakeMouseEvent}
> */
>com.printui.controller.MouseManager.getMouseEventFromHammer =
>function(ev) {
>  var /** @type {com.printui.view.events.FakeMouseEvent} */ mouseEv = new
>com.printui.view.events.FakeMouseEvent(ev.type);
>  mouseEv.localX = ev.center.x;
>  mouseEv.localY = ev.center.y;
>  mouseEv.target = ev.target;
>  return mouseEv;
>};
>
>which gets minified to:
>function V8(a){var b=new
>t_(a.type);b.localX=a.YD.x;b.localY=a.YD.y;b.target=a.target;return b}
>
>Why is center being renamed to YD?
>
>I don’t see the externs for io.github.hammerjs.Event or
>io.github.hammerjs.Center. Isn’t that supposed to be copied somewhere?
>
>Where am I going off?
>
>Harbs

Reply | Threaded
Open this post in threaded view
|

Re: Trouble with typedefs

Harbs
Bingo!

Thanks!

Harbs

> On Sep 7, 2017, at 11:22 PM, Alex Harui <[hidden email]> wrote:
>
> If the typedefs source is AS then make sure
> @externs is in the ASDoc for the class.