Sorry to interject but how do I get a link to this thread? I've seen them
in footers before but not this one.

On Wed, Dec 2, 2015 at 3:29 PM, Josh Tynjala <joshtynj...@gmail.com> wrote:

> Got it. So if I were trying to hide a require() call, @flexjsignorecoercion
> could be used in my code without requiring users to do anything. I think I
> may be able to work with that. I'll play around with it, when I have a
> moment.
>
> - Josh
>
> On Wed, Dec 2, 2015 at 3:10 PM, Alex Harui <aha...@adobe.com> wrote:
>
> > Currently it works at the method's ASDoc, not at the class level.
> >
> > Here's an excerpt:
> >
> >
> > /**
> >          * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
> >          * @flexjsignorecoercion HTMLBodyElement
> >          */
> >         COMPILE::JS
> >                 override public function start():void
> >         {
> >             var body:HTMLBodyElement;
> >
> >             // For createjs, the application is the same as the canvas
> >             // and it provides convenient access to the stage.
> >
> >             element = document.createElement('canvas') as
> > WrappedHTMLElement;
> >             element.id = 'flexjsCanvas';
> >             element.width = 700;
> >             element.height = 500;
> >
> >             body = document.getElementsByTagName('body')[0] as
> > HTMLBodyElement;
> >             body.appendChild(this.element);
> >
> > ...
> >
> >
> >
> >
> >
> > On 12/2/15, 3:07 PM, "Josh Tynjala" <joshtynj...@gmail.com> wrote:
> >
> > >Interesting... I didn't know about that. How would @flexjsignorecoercion
> > >be
> > >used? In the asdocs for a class, like this?
> > >
> > >/**
> > > * @flexjsignorecoercion
> > > */
> > >public class MyClass {}
> > >
> > >If I'm understanding your correctly, when using this tag, the JS output
> > >would not pass the value to Language.as()?
> > >
> > >//as
> > >var test = something as MyClass;
> > >
> > >//js
> > >var test = something; //instead of Language.as(something)
> > >
> > >If that's how it works, I think it might be good enough for my needs.
> > >
> > >- Josh
> > >
> > >
> > >On Wed, Dec 2, 2015 at 2:51 PM, Alex Harui <aha...@adobe.com> wrote:
> > >
> > >>
> > >>
> > >> On 12/2/15, 2:37 PM, "Josh Tynjala" <joshtynj...@gmail.com> wrote:
> > >>
> > >> >Oh, I see. I didn't realize that you were thinking that users would
> > >>import
> > >> >something and also manually call require(). In that case, yes, you
> > >>could
> > >> >still potentially have proper type checking.
> > >> >
> > >> >I like the idea of using some kind of wrapper class to hide the
> > >>require()
> > >> >call. It's kind of messy to both import and call require(), so I
> really
> > >> >would prefer to hide one or the other, if possible.
> > >>
> > >> It's up to you or whoever writes this code.  A wrapper adds a layer of
> > >> function calls but does let you hide some ugliness.
> > >>
> > >> >
> > >> >There's one thing that seems like an issue to me, though. Using an as
> > >>cast
> > >> >with require() will probably result in a null result because what is
> > >> >returned by require("fs") doesn't actually extend an FS class (or
> > >> >implement
> > >> >an FS interface).
> > >> >
> > >> >var fs:FS = require("fs") as FS;
> > >>
> > >> We have this problem already.  There is a special ASDoc tag called
> > >> @flexjsignorecoercion that suppresses "as" code in the cross-compiled
> > >> output.  I've considered trying to get the compiler to automatically
> > >> suppress the "as" code for any "as" usage that references a class in
> an
> > >> external-library-path SWC.  That seems like it could fail you in some
> > >> distributed development cases where you have other code that does
> > >>support
> > >> AS in an external-library-path SWC.  We could add file-level
> suppression
> > >> as well, or have a config option that lists certain coercions to
> always
> > >> suppress.  Definitely open to ideas on this, but the fact is, the
> > >>compiler
> > >> will not let you have type-checking without using "as" so you sort of
> > >>have
> > >> to have a scheme to deal with it.
> > >>
> > >> -Alex
> > >>
> > >>
> >
> >
>

Reply via email to