flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: [FlexJS]Promises
Date Thu, 17 Nov 2016 16:37:57 GMT
I just looked at:

 flex-typedefs/target/generated-sources/externc/classes/Promise.as
 flex-typedefs/target/generated-sources/externc/interfaces/IThenable.as

It looks like Promise does implement Ithenable.

I don't think we are currently using es6.

-Alex

On 11/16/16, 3:04 PM, "Harbs" <harbs.lists@gmail.com> wrote:

>It seems to me that the extern is wrong. According to MDC, the return
>type for all Promise methods should be of type Promise.[1]
>
>Maybe Promise should implement IThenable (and possibly ICatchable), but I
>think Promise should return Promise.
>
>How do we patch the js files?
>
>I could also try to make a pull request and/or open an issue on their
>extern. My last pull request for node externs was accepted.
>
>Thoughts?
>
>[1]https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Globa
>l_Objects/Promise/then
>On Nov 17, 2016, at 12:42 AM, Josh Tynjala <joshtynjala@gmail.com> wrote:
>
>> Based on that really strange @template tag, Object is definitely the
>> correct response from externc. Google seems to be doing something
>>advanced
>> there that I'm not even sure is documented.
>> 
>> I also don't think we want to try to parse that mess. If we want it to
>> return IThenable or something, then we need to apply a patch file,
>>similar
>> to other changes that we make.
>> 
>> - Josh
>> 
>> On Wed, Nov 16, 2016 at 2:26 PM, Harbs <harbs.lists@gmail.com> wrote:
>> 
>>> 
>>> On Nov 16, 2016, at 11:20 PM, Alex Harui <aharui@adobe.com> wrote:
>>> 
>>>> 
>>>> 
>>>> On 11/16/16, 11:07 AM, "Harbs" <harbs.lists@gmail.com> wrote:
>>>> 
>>>>> 
>>>>> So you are suggesting to make it a top-level class. Right? Otherwise
>>>>> we’re not good to go.
>>>>> 
>>>>> Another problem with the definition in js.swc is that then() returns
>>>>>an
>>>>> Object, while it should really return a Thenable. I don’t think
>>>>>Thenable
>>>>> is defined as an interface in JS.
>>>> 
>>>> You can use patch files and missing.js to tweak the API if you need
>>>>to.
>>> 
>>> I’m a bit confused by where the types are being picked up from. js.swc
>>> definitely gets them, and it looks like it’s getting them from es6.js.
>>>I
>>> see that there actually is an IThenable which is a defined type,
>>>although
>>> IThenable only has a then() method and not a catch() method.
>>> 
>>> One thing which is throwing me off is the fact that es6.as defines
>>> Promise.resolve() like this:
>>> /**
>>> * @param {VALUE=} opt_value
>>> * @return {RESULT}
>>> * @template VALUE
>>> * @template RESULT := type('Promise',
>>> *     cond(isUnknown(VALUE), unknown(),
>>> *       mapunion(VALUE, (V) =>
>>> *         cond(isTemplatized(V) && sub(rawTypeOf(V), 'IThenable'),
>>> *           templateTypeOf(V, 0),
>>> *           cond(sub(V, 'Thenable'),
>>> *              unknown(),
>>> *              V)))))
>>> * =:
>>> */
>>> Promise.resolve = function(opt_value) {};
>>> 
>>> I have no clue what all this template stuff means, but the js.swc is
>>> expecting an Object as the return type.
>>> 
>>> Promise.reject() has a return type of Promise which seems more correct
>>>to
>>> me. Is Promise.resolve() broken, and if yes, how do we fix it?
>>> 
>>>> 
>>>>> 
>>>>>> IMO, polyfills should be beads you add to your Application beads
if
>>>>>>you
>>>>>> need them.
>>>>> 
>>>>> Makes sense, although I’m not sure what the bead would look like.
>>>>> I think manually adding a polyfill for I.E. in the HTML is a
>>>>>reasonable
>>>>> work-around as well.
>>>> 
>>>> The bead would use <inject_html>
>>>> 
>>>> -Alex
>>>> 
>>> 
>>> 
>

Mime
View raw message