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

Unexpected semicolon #62

Closed
tomasbruckner opened this issue Nov 24, 2020 · 2 comments · Fixed by #81
Closed

Unexpected semicolon #62

tomasbruckner opened this issue Nov 24, 2020 · 2 comments · Fixed by #81
Labels
bug Something isn't working

Comments

@tomasbruckner
Copy link

tomasbruckner commented Nov 24, 2020

Hi, this fails in explicit-any phase

version 0.1.10

simplified version of code. I think props are the problem

const InfoPanel = props => {
  const { foo } = props;

  return (
    <div>{foo? 'bar' : 'bar2'}</bar>
  );
};

InfoPanel.propTypes = {
  foo: PropTypes.bool,
};

InfoPanel.defaultProps = {
  foo: false,
};

export default InfoPanel;

Stacktrace (from original code)

Error: [explicit-any][src\InfoPanel.tsx] Error:
 SyntaxError: Unexpected token, expected ";" (23:22)
    at Object.raise (C:\path\project\node_modules\@babel\parser\lib\index.js:6325:17)
    at Object.unexpected (C:\path\project\node_modules\@babel\parser\lib\index.js:7642:16)
    at Object.semicolon (C:\path\project\node_modules\@babel\parser\lib\index.js:7624:40)
    at Object.parseVarStatement (C:\path\project\node_modules\@babel\parser\lib\index.js:10300:10)
    at Object.parseStatementContent (C:\path\project\node_modules\@babel\parser\lib\index.js:9896:21)
    at Object.parseStatementContent (C:\path\project\node_modules\@babel\parser\lib\index.js:5372:18)
    at Object.parseStatement (C:\path\project\node_modules\@babel\parser\lib\index.js:9829:17)
    at Object.parseBlockOrModuleBlockBody (C:\path\project\node_modules\@babel\parser\lib\index.js:10405:25)
    at Object.parseBlockBody (C:\path\project\node_modules\@babel\parser\lib\index.js:10392:10)
    at Object.parseTopLevel (C:\path\project\node_modules\@babel\parser\lib\index.js:9758:10) {
  pos: 667,
  loc: Position { line: 23, column: 22 }
}
@Rudeg Rudeg added the bug Something isn't working label Nov 24, 2020
@oleghind
Copy link

Is there any workaround? Happens a lot

@edsrzf
Copy link
Collaborator

edsrzf commented Dec 20, 2020

The react-props plugin is not dealing well with the arrow function without parentheses. I've created a fix in #81.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants