我在 ericgio 对这个问题React AsyncTypeahead using Typescript的回答中讨论了(但从未回答)同样的问题
labelKey的类型定义似乎有问题
我从这段代码中得到以下错误:
<Typeahead
id="basic-typeahead-single"
labelKey="name"
onChange={this.changeEdgeName}
options={this.state.streetNames}
placeholder=""
/>
重载 2 of 2, '(props: TypeaheadProps, context?: any): Typeahead',出现以下错误。类型 'string' 不可分配给类型 'undefined'。TS2769
依赖项:
"@types/react-bootstrap-typeahead": "^3.4.6",
"react-bootstrap-typeahead": "^5.1.1",