2
フローとの互換性がありません明示的に渡された文字列がnullと互換性がありません、また、渡される爆発物とは何かを持っているようだと私に語っている。flowtype-文字列がnull
私が持っています私の中で次のブートストラップライブラリインタフェース定義ファイル反応:これは右、罰金のようです
import { FormControl, type FormControlProps } from 'react-bootstrap';
type EnumSelectProps = {|
defaultText: string,
...FormControlProps,
|};
// and in the render method:
const { defaultText, ...other: FormControlProps } = this.props;
<FormControl
{...other}
componentClass="select"
value={this.state.value}
onChange={event => this.onChange(event.target.value)}
>
{ children }
</FormControl>
:
declare export type FormControlProps = {|
componentClass?: ?componentClass,
// componentClass is an enum of strings 'select' | 'div' etc
// There are other params here, too.
|}
とコンポーネントに次のように? ...other
のタイプはFormControlProps
です。しかし、私は苦情を受け取ります:
v-----------
43: <FormControl
44: {...other}
45: componentClass="select"
...:
48: >
^props of React element `FormControl`
45: componentClass="select"
^^^^^^^^ string. This type is incompatible with
463: componentClass?: ?componentClass,
^^^^^^^^^^^^^^^ null. See lib: flow-typed/npm/react-bootstrap_v0.x.x.js:463
何がありますか? other
をany
(つまり...(other: any)
)と入力すると動作します。また、componentClass
を左側のオプションのcomponentClass?: componentClass
にすると動作します。しかし、これは正しい定義ではありません。これを処理する方法はそれほどハックリではありませんか?ありがとうございました!