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

ReactJS Flow stateless component: "Parsing error: Unexpected token :" #850

Closed
will-stone opened this issue Apr 9, 2017 · 4 comments

Comments

@will-stone
Copy link

commented Apr 9, 2017

const Component = ({ something }: { something:string }) => {

Causes Parsing error: Unexpected token : on the colon. The latest update adds better support for Flow but looks like it's not quite there. Any chance this could be fixed?

@feross

This comment has been minimized.

Copy link
Member

commented Apr 10, 2017

Are you using eslint-plugin-flowtype as recommended in the readme?
https://standardjs.com/#can-i-use-a-javascript-language-variant-like-flow

@feross feross added the question label Apr 10, 2017

@will-stone

This comment has been minimized.

Copy link
Author

commented Apr 10, 2017

I installed the plugin but the error still appears on that colon. I'm using Create React App, an excerpt from my package.json:

"devDependencies": {
    "eslint-plugin-flowtype": "^2.30.4",
    "react-scripts": "0.9.5",
    "standard": "^10.0.1"
},
"standard": {
    "plugins": [ "flowtype" ]
},

Using VSCode and vscode-standardjs extension.

Running ./node_modules/standard/bin/cmd.js --plugin flowtype gives the same error.

@feross

This comment has been minimized.

Copy link
Member

commented Apr 13, 2017

Aha. This is happening because babel-eslint is not specified as the parser.

You also need to npm install babel-eslint --save-dev and set the "parser" option to "babel-eslint".

"standard": {
    "plugins": [ "flowtype" ],
    "parser": "babel-eslint"
}

@feross feross closed this Apr 13, 2017

feross added a commit that referenced this issue Apr 13, 2017

readme: Add more specific Flow instructions
To address the confusion in this issue:
#850 (comment)
@will-stone

This comment has been minimized.

Copy link
Author

commented Apr 19, 2017

Thanks. That fixed it.

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
2 participants
You can’t perform that action at this time.