2016-08-13 72 views
1

所以我尝试将Flow应用到现有的repo中,并在与React.Component一起使用时运行到包版中。 documentation显示您应该通过放置在组件的开头注释组件的状态对象。这样做可以满足Flow,我不再有任何错误。但是代码不会编译。每次编译此组件时,Babel都会出错。我曾尝试使用内置到babel react预设中的Flow支持以及包括babel transform-flow-strip-types插件。每一个其他的注释都没有问题,但由于某种原因,这个不是。这是插件中的错误还是我做错了什么?React.Component状态的FlowType注释在编译时不会被删除

class MyComponent extends React.Component { 
    state: {someKey: {withSomeMoreKeys: string}}; 

    constructor(props: void): void{ 
     super(props); 

     this.state = { 
      someKey: { 
       withSomeMoreKeys: string 
      } 
     } 
    } 
    ... 

感谢您的帮助!

回答