'"Expected an arrow function after this type parameter declaration" error
I got this error while running yarn start:
$ yarn start
yarn run v1.22.17
$ run-s build exec
$ babel src/ -d lib/
SyntaxError: .../src/App.js: Expected an arrow function after this type parameter declaration. (8:9)
6 |
7 | export default function App(): React$MixedElement {
> 8 | return <p>Hello, React!</p>;
| ^
9 | }
10 |
Below are the configs:
package.json
"scripts": {
"flow": "flow",
"start": "run-s build exec",
"exec": "node lib/index.js",
"build": "babel src/ -d lib/",
},
babel.config.json:
{
"presets": ["@babel/preset-flow"],
"plugins": ["babel-plugin-transform-flow-enums"],
"targets": {
"esmodules": true
}
}
App.js:
// @flow
import "./App.css";
import React from "react";
export default function App(): React$MixedElement {
return <p>Hello, React!</p>;
}
What the issue with my configs and react file?
Solution 1:[1]
It seems to be a typo on React.MixedElement, replace the $ by a .:
export default function App(): React.MixedElement {...}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Quentin Grisel |
