You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by OK <po...@olafkrueger.net> on 2017/03/24 09:06:51 UTC
[FlexJS] How typedefs working? (was Accessing the DOM)
Hi,
to be cleaner I've just created this new thread regarding typedefs:
>No. No Adobe involved in that. It’s built by externc.
Ok, maybe I'm confused about how flex-typedef is working:
For instance, each lib inside the TS pendant DefinitelyTyped [1] contains a
file called index.d.ts which contain all the definitions. Without knowledge
of TS I could get an idea of the provided API for each lib.
It's very transparent for me.
Browsing through the flex-typedefs repo I didn't find any AS3 file that is
doing similar things to a index.d.ts file. Moreover, I've no idea how can I
get an information about the provided API of a particular lib.
So reading Alex "BatchScanner" Article again I understand that in FlexJS we
could create typedefs by using externc with externs-formatted JavaScript
files or by creating AS3 files and cross-compile it.
Is that right?
So for the moment, two questions are left for me:
- How could I get an information about the provided API of a collared lib or
where are the externs-formatted JavaScript files located?
- Why does nobody use the AS3 approach for building typedefs?
Thanks,
Olaf
[1] https://github.com/DefinitelyTyped/DefinitelyTyped
[2]
https://git1-us-west.apache.org/repos/asf?p=flex-tourjs.git;a=blob_plain;f=cordova/BatchScanner/BatchScanner/src/main/resources/top.html;hb=b80d
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-How-typedefs-working-was-Accessing-the-DOM-tp60735.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.
Re: [FlexJS] How typedefs working? (was Accessing the DOM)
Posted by Alex Harui <ah...@adobe.com>.
Here's my understanding of this topic.
TypeScript needed strong typing, and DefinitelyTyped become the home for
TypeScript definitions for a library. Those definitions are not directly
usable by FlexJS. Josh has a dts2as utility that can do the conversion.
Google doesn't need TypeScript definitions. They want plain JS
definitions. So they created the externs JSDoc annotations and file
format, which looks a lot like original JS source code, but isn't. For
example, Externs JS files can't have method bodies that do more than just
return null.
Third-parties do not always write their code in a Google Closure
compatible way. The actual CreateJS source, for example, uses objects
with functions instead of the Google Closure "className.prototype" format.
So sometimes, a Google Closure Externs (and a DefinitelyTyped offering)
needs to be manually generated. And many times, the externs and d.ts
files are generated by a community member who wants to use the library and
not by the library developers themselves.
We've recently provided a way to, instead of using Externs JSDoc or d.ts
files, write AS class definitions and generate a typedefs SWC from that.
It is so recent, that no library in flex-typedefs uses that, especially
since externs files already exist for the libraries in flex-typedefs.
A typedefs SWC contains a library.swf with the compiled AS definitions,
and a pile of JS files that are the Externs JSDoc-formatted JS files for
the Google Closure Compiler.
FlexJS has an ExternsCompiler (externc) that takes Externs JSDoc and
generates AS files. Compc can then create a typedefs SWC from those AS
files. And recently we taught CompC to annotate the pile of JS files with
Externs JSDoc and package them the right way.
HTH,
-Alex
On 3/24/17, 2:49 AM, "OK" <po...@olafkrueger.net> wrote:
>harbs wrote
>> The compiler knows how to read Google Complier extern files. Most of the
>> typedefs are created from those.
>>
>> There’s actually a two-step process for generating the typedefs. It
>>first
>> creates ActionScript stubs, and then generates the swc from that. It
>> download the extern files as part of the build process.
>>
>> If you are starting from scratch, it’s definitely possible to generate
>>the
>> swcs from ActionScript stubs, but since most of the typedefs we need
>>have
>> Google extern files, that’s not necessary.
>>
>> HTH,
>> Harbs
>
>Ok, I got it! Thanks, Harbs!
>But I still wonder why the Angular guys don't follow this path? Instead of
>extending their own externs lib they introduced the DefinitelyTyped lib?
>It seems to me that the closure lib just contains a handful externs while
>DefinitelyTyped covers nearly anything.
>But isn't it a very tough work to create all the DefinitelyTyped stuff
>manually even if it's done by thousands of contributors?
>I understand that if the origin JS code uses the "externs JSDoc
>annotations"
>then you get the typedefs for free?
>
>
>Thanks,
>Olaf
>
>
>
>
>
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-development.2333347.n4.nabble.com%2FFlexJS-How-typedefs-working-was-Acce
>ssing-the-DOM-tp60735p60738.html&data=02%7C01%7C%7Cf4274a33335b4224127f08d
>4729c2f56%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636259462518631945&
>sdata=Stj4D7rNGd36bqe5m6Yv2LJIDq2NnCJWFhP31SV6lw8%3D&reserved=0
>Sent from the Apache Flex Development mailing list archive at Nabble.com.
Re: [FlexJS] How typedefs working? (was Accessing the DOM)
Posted by OK <po...@olafkrueger.net>.
harbs wrote
> The compiler knows how to read Google Complier extern files. Most of the
> typedefs are created from those.
>
> There’s actually a two-step process for generating the typedefs. It first
> creates ActionScript stubs, and then generates the swc from that. It
> download the extern files as part of the build process.
>
> If you are starting from scratch, it’s definitely possible to generate the
> swcs from ActionScript stubs, but since most of the typedefs we need have
> Google extern files, that’s not necessary.
>
> HTH,
> Harbs
Ok, I got it! Thanks, Harbs!
But I still wonder why the Angular guys don't follow this path? Instead of
extending their own externs lib they introduced the DefinitelyTyped lib?
It seems to me that the closure lib just contains a handful externs while
DefinitelyTyped covers nearly anything.
But isn't it a very tough work to create all the DefinitelyTyped stuff
manually even if it's done by thousands of contributors?
I understand that if the origin JS code uses the "externs JSDoc annotations"
then you get the typedefs for free?
Thanks,
Olaf
--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/FlexJS-How-typedefs-working-was-Accessing-the-DOM-tp60735p60738.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.