Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSX Parse errors always five lines off #118

Closed
arbrown opened this issue Apr 24, 2015 · 1 comment
Closed

JSX Parse errors always five lines off #118

arbrown opened this issue Apr 24, 2015 · 1 comment
Labels

Comments

@arbrown
Copy link
Contributor

arbrown commented Apr 24, 2015

Whenever there is an error parsing a jsx file, the server will throw an exception and return a yellow screen (standard error page) with some information about the parse error. Unfortunately, the error page seems to reference line and column numbers referencing the .js file that would have been produced, including the standard 5-line header, rather than the jsx source file.

The 5-line header included at the top of a compiled jsx file looks like:

// @hash v2-3CD45365F295AFAAAAC483D5FEFB3B72
// Automatically generated by ReactJS.NET. Do not edit, your changes will be overridden.
// Version: 1.5.0 (build 90661fe)
// Generated at: 4/24/2015 2:59:12 PM
///////////////////////////////////////////////////////////////////////////////

This header pushes any errors to different line numbers. For instance, in the following jsx snippet, the error is the missing comma on line 4 which leads to an unexpected identifier on line 5 columns 3.

var parseError = React.createClass({
  render: function(){
    return (<p>{this.state.message}</p>);
  }
  getInitialState: function(){
    return {message: "Parse Error!"};
  }
});

However, when trying to view the compiled result in the browser, the server returns the following error:
Error: Parse Error: Line 10: Unexpected identifier (at line 10 column 3) at ReactNET_transform_sourcemap (Script Document:113:9) -> throw new Error(ex.message + " (at line " + ex.lineNumber + " column " + ex.

The error is right, the location is just 5 lines off.

@Daniel15 Daniel15 added the Bug label Apr 24, 2015
@Daniel15
Copy link
Member

Good catch, thanks for reporting it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants