无法让 flowtype 与 babel 一起工作。意外的标记
Can't get flowtype to work with babel. Unexpected token
ERROR in ./$Store.js
Module build failed: SyntaxError: ./$Store.js: Unexpected token, expected "{"
(24:39)
import Notification from '../$Notification'
export class ERStore extends StoreBase implements _Store {
^
与 "type" 和另一个流程注释相同。我试过:
1) 添加@babel/preset-flow
2) 添加插件转换流条类型
3) 添加“@babel/plugin-syntax-flow”
4) 将所有部门更新为可用的最新版本
5) 不同的预设顺序
.babelrc
{
"presets": [
["@babel/preset-env", {
"useBuiltIns": "entry",
"modules": "auto"
}],
"@babel/preset-react",
"@babel/preset-flow"
],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }],
"lodash"
]
}
部门:
"webpack": "3.12.0",
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.3.0",
"@babel/plugin-proposal-decorators": "^7.3.0",
"@babel/plugin-syntax-flow": "^7.2.0",
"@babel/plugin-transform-flow-strip-types": "^7.2.3",
"@babel/preset-env": "^7.3.1",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-stage-3": "^7.0.0",
"babel-loader": "^8.0.5",
更新:
有趣,但 jest 与 babel-jest 配合得很好。
加载程序使用:
{
test: /.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
babelrc: true
}
},
},
我必须在 webpack.conf 文件中明确设置 babel 配置。
.babelrc 只工作了一部分。
ERROR in ./$Store.js
Module build failed: SyntaxError: ./$Store.js: Unexpected token, expected "{"
(24:39)
import Notification from '../$Notification'
export class ERStore extends StoreBase implements _Store {
^
与 "type" 和另一个流程注释相同。我试过:
1) 添加@babel/preset-flow
2) 添加插件转换流条类型
3) 添加“@babel/plugin-syntax-flow”
4) 将所有部门更新为可用的最新版本
5) 不同的预设顺序
.babelrc
{
"presets": [
["@babel/preset-env", {
"useBuiltIns": "entry",
"modules": "auto"
}],
"@babel/preset-react",
"@babel/preset-flow"
],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }],
"lodash"
]
}
部门:
"webpack": "3.12.0",
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.3.0",
"@babel/plugin-proposal-decorators": "^7.3.0",
"@babel/plugin-syntax-flow": "^7.2.0",
"@babel/plugin-transform-flow-strip-types": "^7.2.3",
"@babel/preset-env": "^7.3.1",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-stage-3": "^7.0.0",
"babel-loader": "^8.0.5",
更新: 有趣,但 jest 与 babel-jest 配合得很好。 加载程序使用:
{
test: /.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
babelrc: true
}
},
},
我必须在 webpack.conf 文件中明确设置 babel 配置。 .babelrc 只工作了一部分。