传播时的typeAnnotation错误

时间:2017-08-26 05:01:55

标签: flowtype

我的代码如下:

import type { Shape as BrowserActionShape } from '../../../flow-control/browser-action'

type Props = {
    // redux
    ...BrowserActionShape
}

const rawr:Props= { title:'blah' } // this works

BrowserShape的定义在这里:

export type Shape = {
    badgeColor?: string,
    badgeText?: string,
    title?: string
}

Flow工作正常,但是使用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 - 我不记得以前版本的流程中的这个错误。

1 个答案:

答案 0 :(得分:1)

嗯,很难说。类似的代码似乎对我有用。您能否检查一下最新版本的babel,Babel Flow预设和babel-eslint?如果升级它们无法修复,您能提供当前使用的版本以及有关babel / webpack配置的详细信息吗?