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
}
}
}
...
感謝您的幫助!
非常感謝! –