我的代码如下:
import type { Shape as BrowserActionShape } from '../../../flow-control/browser-action'
type Props = {
// redux
...BrowserActionShape
}
const rawr:Props= { title:'blah' } // this worksBrowserShape的定义如下:
export type Shape = {
badgeColor?: string,
badgeText?: string,
title?: string
}流运行得很好,但是与webpack一起构建会导致编译错误和失败:
ERROR in ./src/webext/background/Background/BrowserAction/index.js
Module build failed: TypeError: Cannot read property 'typeAnnotation' of undefined
at Referencer.checkIdentifierOrVisit (C:\Users\Blagoh\Documents\GitHub\My-Cool-App\node_modules\babel-eslint\index.js:206:13)
at Referencer.visitTypeAnnotation (C:\Users\Blagoh\Documents\GitHub\My-Cool-App\node_modules\babel-eslint\index.js:181:38)
at Referencer.referencer.TypeAlias (C:\Users\Blagoh\Documents\GitHub\My-Cool-App\node_modules\babel-eslint\index.js:347:27)
at Referencer.Visitor.visit (C:\Users\Blagoh\Documents\GitHub\My-Cool-App\node_modules\esrecurse\esrecurse.js:122:34)
at Referencer.Visitor.visitChildren (C:\Users\Blagoh\Documents\GitHub\My-Cool-App\node_modules\esrecurse\esrecurse.js:101:38)
at Referencer.Program (C:\Users\Blagoh\Documents\GitHub\My-Cool-App\node_modules\escope\lib\referencer.js:419:18)
at Referencer.Visitor.visit (C:\Users\Blagoh\Documents\GitHub\My-Cool-App\node_modules\esrecurse\esrecurse.js:122:34)
at Object.analyze (C:\Users\Blagoh\Documents\GitHub\My-Cool-App\node_modules\escope\lib\index.js:153:16)
at Object.escope.analyze (C:\Users\Blagoh\Documents\GitHub\My-Cool-App\node_modules\babel-eslint\index.js:90:27)
at EventEmitter.module.exports.api.verify (C:\Users\Blagoh\Documents\GitHub\My-Cool-App\node_modules\eslint\lib\eslint.js:892:35)
at processText (C:\Users\Blagoh\Documents\GitHub\My-Cool-App\node_modules\eslint\lib\cli-engine.js:264:31)
at CLIEngine.executeOnText (C:\Users\Blagoh\Documents\GitHub\My-Cool-App\node_modules\eslint\lib\cli-engine.js:754:26)
at lint (C:\Users\Blagoh\Documents\GitHub\My-Cool-App\node_modules\eslint-loader\index.js:218:17)
at Object.module.exports (C:\Users\Blagoh\Documents\GitHub\My-Cool-App\node_modules\eslint-loader\index.js:213:21)
@ ./src/webext/background/Background/index.js 35:21-47我解决不了这个问题。我使用的是flow-bin 0.53.1 -我不记得以前版本的flow中有这个错误。
发布于 2017-08-26 15:16:11
嗯,很难说。类似的代码似乎适用于我。您能检查一下babel、Babel预置和babel-eslint的最新版本吗?如果升级没有修复,您能提供您目前使用的版本和有关babel/webpack配置的详细信息吗?
https://stackoverflow.com/questions/45892088
复制相似问题