Skip to content

semi-colons in react classes #6

Description

@laem

Hi,

It appears that sweetjs cannot compile react classes whose functions are written without semi-colons.

E.g. the following code

var React = require('react')

var CommentBox = React.createClass({
    hey: function(){
        var how = 0 //no semicolon here
        if (are){
            console.log('you');
        }
    },
    render: function() {
      return (
        <div className="commentBox">
          Hello, world! I am a CommentBox.
        </div>
      );
    }
});

will throw the following error :

Error: Line 4: Unexpected token if
[... how = 0 if ( are ...]
    at throwError (/home/mael/.node/lib/node_modules/sweet.js/lib/parser.js:1887:21)
    at throwUnexpected (/home/mael/.node/lib/node_modules/sweet.js/lib/parser.js:1933:13)
    at consumeSemicolon (/home/mael/.node/lib/node_modules/sweet.js/lib/parser.js:1994:13)

Is this unavoidable ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions