Skip to content

semi-colons in react classes #6

@laem

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 ?

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