rainforestapp / decaf

Coffeescript to ES.next transpiler. Now maintained over at
https://github.com/juliankrispel/decaf
MIT License
106 stars 10 forks source link

Hoist class-private vars above the class; move static class calls to … #159

Closed GoodForOneFare closed 8 years ago

GoodForOneFare commented 8 years ago

…below the class.

This works for Shopify's codebase because we have one class per file, and don't do anything weird with private-static calls. If it'd help to get this PR accepted, I can add a command line flag to enable/disable this behaviour.

juliankrispel commented 8 years ago

Hm. @GoodForOneFare I think a flag would be nice.

Also, how does this deal with naming collisions, I'd like to make sure that these variable names don't collide with any other variable names, since they're mounted in the same scope as the class definition.

GoodForOneFare commented 8 years ago

At the moment it only warns about naming collisions. I can take a look at throwing exceptions.

Any preference for a flag name? transform_class_private_statements=[true|false] with a default of false?

juliankrispel commented 8 years ago

@GoodForOneFare decaf --private-class-statements with a boolean :+1:

thanks dude

juliankrispel commented 8 years ago

@GoodForOneFare no need to throw exceptions, instead you could use the coffeescript helper attached to the meta object, meta.scope.freeVariable >> https://github.com/rainforestapp/decaf/blob/master/src/parser.js#L202 that should ensure integrity

ukd1 commented 8 years ago

@GoodForOneFare @juliankrispel what's the status on this?

GoodForOneFare commented 8 years ago

I have a work in progress that's most of the way there, but other stuff came up. I'll take a look this weekend to pare down what I have and get a PR up.

juliankrispel commented 8 years ago

@GoodForOneFare I'd be up for pairing if you wanna

ukd1 commented 8 years ago

@GoodForOneFare @juliankrispel is this gonna happen?

ukd1 commented 8 years ago

I'm gonna close this. Please re-open @juliankrispel if you get time