2
流量是告诉我,一个明确的传入的字符串是空不相容519,似乎有什么东西做的分解对象也被传递。flowtype-字符串是空
我有按照我的反应引导库接口定义文件:
declare export type FormControlProps = {|
componentClass?: ?componentClass,
// componentClass is an enum of strings 'select' | 'div' etc
// There are other params here, too.
|}
,且在组件如下:
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>
这似乎是罚款,对不对? ...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
,它可以工作。 (虽然这不是正确的定义。)有没有更简单的方法来处理这个问题?谢谢!