You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Harbs <ha...@gmail.com> on 2017/03/18 19:12:00 UTC
[FlexJS Typedefs]FileReader
I found what looks like a bug in the FileReader typedefs:
The following in fileapi.js:
/**
* @param {boolean=} opt_useCapture
* @override
* @return {undefined}
*/
FileReader.prototype.addEventListener = function(type, listener, opt_useCapture)
{};
/**
* @param {boolean=} opt_useCapture
* @override
* @return {undefined}
*/
FileReader.prototype.removeEventListener = function(type, listener,
opt_useCapture) {};
compiles to this in FileReader.as:
/**
* @param opt_useCapture [(boolean|undefined)]
* @see [fileapi]
* @returns {undefined}
*/
public function addEventListener(type:String, listener:Object, useCapture:Boolean):Object /* undefined */ { return null; }
/**
* @param opt_useCapture [(boolean|undefined)]
* @see [fileapi]
* @returns {undefined}
*/
public function removeEventListener(type:String, listener:Object, useCapture:Boolean):Object /* undefined */ { return null; }
The result is wrong because the third parameter is supposed to be optional. The thing is, I don’t understand how we ended up with the output we did. The parameter was renames and retyped…
Harbs
Re: [FlexJS Typedefs]FileReader
Posted by Josh Tynjala <jo...@gmail.com>.
I'd be cool with that! I don't like adding that extra argument to
addEventListener() calls.
- Josh
On Sat, Mar 18, 2017 at 1:45 PM, Harbs <ha...@gmail.com> wrote:
> Thanks.
>
> I noticed that it was a general problem after I posted this question.
>
> Maybe we should patch the extern file?
>
> > On Mar 18, 2017, at 10:24 PM, Josh Tynjala <jo...@gmail.com>
> wrote:
> >
> > It's not optional on the base interface where addEventListener() and
> > removeEventListener() are defined. I think it's EventTarget. Since
> > subclasses and implementers of interfaces aren't allowed to change the
> > signature of a method in ActionScript, externc uses the original
> signature
> > and ignores the overload on FileReader.
> >
> > I opened a pull request for Closure Compiler to make that parameter
> > optional on EventTarget in the official externs (it was non-optional
> > because some old browsers required it, I think). Google seemed open to
> the
> > idea, but I don't think they ever merged it.
> >
> > - Josh
> >
> > On Mar 18, 2017 12:12 PM, "Harbs" <ha...@gmail.com> wrote:
> >
> >> I found what looks like a bug in the FileReader typedefs:
> >>
> >> The following in fileapi.js:
> >>
> >> /**
> >> * @param {boolean=} opt_useCapture
> >> * @override
> >> * @return {undefined}
> >> */
> >> FileReader.prototype.addEventListener = function(type, listener,
> >> opt_useCapture)
> >> {};
> >>
> >> /**
> >> * @param {boolean=} opt_useCapture
> >> * @override
> >> * @return {undefined}
> >> */
> >> FileReader.prototype.removeEventListener = function(type, listener,
> >> opt_useCapture) {};
> >>
> >> compiles to this in FileReader.as:
> >>
> >> /**
> >> * @param opt_useCapture [(boolean|undefined)]
> >> * @see [fileapi]
> >> * @returns {undefined}
> >> */
> >> public function addEventListener(type:String, listener:Object,
> >> useCapture:Boolean):Object /* undefined */ { return null; }
> >>
> >> /**
> >> * @param opt_useCapture [(boolean|undefined)]
> >> * @see [fileapi]
> >> * @returns {undefined}
> >> */
> >> public function removeEventListener(type:String, listener:Object,
> >> useCapture:Boolean):Object /* undefined */ { return null; }
> >>
> >> The result is wrong because the third parameter is supposed to be
> >> optional. The thing is, I don’t understand how we ended up with the
> output
> >> we did. The parameter was renames and retyped…
> >>
> >> Harbs
>
>
Re: [FlexJS Typedefs]FileReader
Posted by Harbs <ha...@gmail.com>.
Thanks.
I noticed that it was a general problem after I posted this question.
Maybe we should patch the extern file?
> On Mar 18, 2017, at 10:24 PM, Josh Tynjala <jo...@gmail.com> wrote:
>
> It's not optional on the base interface where addEventListener() and
> removeEventListener() are defined. I think it's EventTarget. Since
> subclasses and implementers of interfaces aren't allowed to change the
> signature of a method in ActionScript, externc uses the original signature
> and ignores the overload on FileReader.
>
> I opened a pull request for Closure Compiler to make that parameter
> optional on EventTarget in the official externs (it was non-optional
> because some old browsers required it, I think). Google seemed open to the
> idea, but I don't think they ever merged it.
>
> - Josh
>
> On Mar 18, 2017 12:12 PM, "Harbs" <ha...@gmail.com> wrote:
>
>> I found what looks like a bug in the FileReader typedefs:
>>
>> The following in fileapi.js:
>>
>> /**
>> * @param {boolean=} opt_useCapture
>> * @override
>> * @return {undefined}
>> */
>> FileReader.prototype.addEventListener = function(type, listener,
>> opt_useCapture)
>> {};
>>
>> /**
>> * @param {boolean=} opt_useCapture
>> * @override
>> * @return {undefined}
>> */
>> FileReader.prototype.removeEventListener = function(type, listener,
>> opt_useCapture) {};
>>
>> compiles to this in FileReader.as:
>>
>> /**
>> * @param opt_useCapture [(boolean|undefined)]
>> * @see [fileapi]
>> * @returns {undefined}
>> */
>> public function addEventListener(type:String, listener:Object,
>> useCapture:Boolean):Object /* undefined */ { return null; }
>>
>> /**
>> * @param opt_useCapture [(boolean|undefined)]
>> * @see [fileapi]
>> * @returns {undefined}
>> */
>> public function removeEventListener(type:String, listener:Object,
>> useCapture:Boolean):Object /* undefined */ { return null; }
>>
>> The result is wrong because the third parameter is supposed to be
>> optional. The thing is, I don’t understand how we ended up with the output
>> we did. The parameter was renames and retyped…
>>
>> Harbs
Re: [FlexJS Typedefs]FileReader
Posted by Josh Tynjala <jo...@gmail.com>.
It's not optional on the base interface where addEventListener() and
removeEventListener() are defined. I think it's EventTarget. Since
subclasses and implementers of interfaces aren't allowed to change the
signature of a method in ActionScript, externc uses the original signature
and ignores the overload on FileReader.
I opened a pull request for Closure Compiler to make that parameter
optional on EventTarget in the official externs (it was non-optional
because some old browsers required it, I think). Google seemed open to the
idea, but I don't think they ever merged it.
- Josh
On Mar 18, 2017 12:12 PM, "Harbs" <ha...@gmail.com> wrote:
> I found what looks like a bug in the FileReader typedefs:
>
> The following in fileapi.js:
>
> /**
> * @param {boolean=} opt_useCapture
> * @override
> * @return {undefined}
> */
> FileReader.prototype.addEventListener = function(type, listener,
> opt_useCapture)
> {};
>
> /**
> * @param {boolean=} opt_useCapture
> * @override
> * @return {undefined}
> */
> FileReader.prototype.removeEventListener = function(type, listener,
> opt_useCapture) {};
>
> compiles to this in FileReader.as:
>
> /**
> * @param opt_useCapture [(boolean|undefined)]
> * @see [fileapi]
> * @returns {undefined}
> */
> public function addEventListener(type:String, listener:Object,
> useCapture:Boolean):Object /* undefined */ { return null; }
>
> /**
> * @param opt_useCapture [(boolean|undefined)]
> * @see [fileapi]
> * @returns {undefined}
> */
> public function removeEventListener(type:String, listener:Object,
> useCapture:Boolean):Object /* undefined */ { return null; }
>
> The result is wrong because the third parameter is supposed to be
> optional. The thing is, I don’t understand how we ended up with the output
> we did. The parameter was renames and retyped…
>
> Harbs