CoffeeScript and React incompatibilities? Classes?


#1

Hi React folks,

I’m the guy who wrote the code that brought import and export support to CoffeeScript in its version 1.11. I did it primarily because Meteor adopted modules so thoroughly, and I’m a huge fan of both Meteor and of CoffeeScript, and I didn’t want CoffeeScript to be unable to be used with Meteor.

Along those lines, I don’t want CoffeeScript to be unusable with React. I haven’t used React myself yet, but I hope to in a project I’ll be starting soon; and of course I want to keep using CoffeeScript. I know that React presents its own issues with JSX, though people have already created converters for that; leaving that aside, are there any specific interoperability issues with using CoffeeScript with React?

In particular, I’m wondering about extending classes. Currently, CoffeeScript’s class is basically a gussied-up function, and it cannot extend an ES2015 class. We’re working on adding support for ES2015 classes to CoffeeScript; I want to make sure though that whatever solution we come up with truly solves whatever problems people are having with React and ES2015 classes in CoffeeScript. Can anyone very clearly lay out the issue and what CoffeeScript would need to do to interoperate smoothly?

I ask because CoffeeScript classes have several features that ES2015 classes don’t, and we’re trying to preserve backward compatibility wherever possible; so we want to change things as minimally as necessary to address interoperability while preserving as many features as we can. The current implementation does things like define methods via prototype and so on, and I want to preserve those behaviors unless there’s some reason we can’t.