Can't enable experimental features using traceur.options.experimental=true;

229 views
Skip to first unread message

Si

unread,
Feb 13, 2015, 5:33:57 PM2/13/15
to traceur-comp...@googlegroups.com
Hi

I'm using the in-browser on-the-fly compilaton example shown here https://github.com/google/traceur-compiler/wiki/Getting-Started#a-touch-of-class

This works great as-is, but I'd like to use the experimental features e.g.

   class Greeter {
        constructor(message:string) {
          this.message = message;
        }
    .......


If I try to switch on experimental features as discussed in various postings, I find traceur.options is undefined. I also tried creatiing the options object:



    <script>
        traceur.options.experimental = true; // Uncaught TypeError: Cannot set property 'experimental' of undefined

        traceur.options = { experimental:true }; // has no effect e.g. "constructor(message:string)" is a syntax error    
    </script>


If I switch to the (deprecated?) files at traceur-compiler.googlecode.com/git, everything works beautifully

    <script src="https://traceur-compiler.googlecode.com/git/bin/traceur.js"></script>
    <script src="https://traceur-compiler.googlecode.com/git/src/bootstrap.js"></script>

    <script>
        traceur.options.experimental = true; // "constructor(message:string)" is now accepted     
    </script>


I'm serving locally, on win7 w/ chrome 40.0.2214.111 m

I wasn't able to find anything to suggest an alternate syntax etc when doing on-the-fly comilation - What am I doing wrong?

Thanks - Si

johnjbarton johnjbarton

unread,
Feb 13, 2015, 5:48:25 PM2/13/15
to traceur-comp...@googlegroups.com


On Friday, February 13, 2015 at 2:33:57 PM UTC-8, Si wrote:
Hi

I'm using the in-browser on-the-fly compilaton example shown here https://github.com/google/traceur-compiler/wiki/Getting-Started#a-touch-of-class

This works great as-is, but I'd like to use the experimental features e.g.

   class Greeter {
        constructor(message:string) {
          this.message = message;
        }
    .......


If I try to switch on experimental features as discussed in various postings, I find traceur.options is undefined. I also tried creatiing the options object:



    <script>
        traceur.options.experimental = true; // Uncaught TypeError: Cannot set property 'experimental' of undefined

        traceur.options = { experimental:true }; // has no effect e.g. "constructor(message:string)" is a syntax error    
    </script>

Please point out that this does not work now on https://github.com/google/traceur-compiler/issues/1649.

And you can workaround this by setting $traceurRuntime.options until I remove that "feature" as well. Let me know if that works for now.  

Si

unread,
Feb 13, 2015, 6:07:26 PM2/13/15
to traceur-comp...@googlegroups.com
Hi John

Thanks for the quick reply - will update 1649 shortly 

I tried setting $traceurRuntime.options  both after bootstrap.js and (as shown below) before but "constructor(message:string)" was still rejected in both cases

    <script type="text/javascript">
         // $traceurRuntime.options is an empty object here
         $traceurRuntime.options.experimental = true; // executed without error but doesn't have desired effect
    </script>




John J Barton

unread,
Feb 13, 2015, 6:32:24 PM2/13/15
to traceur-comp...@googlegroups.com
Try
$traceurRuntime.options = traceur.util.Options.experimental();

--
You received this message because you are subscribed to the Google Groups "traceur-compiler-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to traceur-compiler-d...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Si

unread,
Feb 13, 2015, 7:01:10 PM2/13/15
to traceur-comp...@googlegroups.com

That works great - thanks! 

Si

unread,
Feb 16, 2015, 4:56:58 PM2/16/15
to traceur-comp...@googlegroups.com
 
FYI: By experimentation, the following also seems to work:

 
      $traceurRuntime.options = new traceur.util.Options({
         types: true,
         typeAssertions: true,
         typeAssertionModule: 'assert.js' // See https://github.com/angular/assert
       });
Reply all
Reply to author
Forward
0 new messages