![](/img/trans.png)
[英]cryptic TypeScript error message when not returning the state from a reducer
[英]Typescript cryptic message when declaring function for one of my actions
我正在使用 React、TypeScript 和 Redux。 我似乎在為我的一項操作使用界面時遇到問題。 我得到的神秘信息是:
Duplicate identifier 'number'.ts(2300)
Binding element 'number' implicitly has an 'any' type.ts(7031)
在 VS 代碼中,limit: 和 skip: 上的數字都帶有紅色錯誤波浪線下划線。
剪下我的代碼:
interface TabNavUnitsProps {
unitsToRegister: number,
unit: { status: string, unitsRegisterCount: number },
fetchRegisterAll: ({ limit: number, skip: number }) => Promise<void>
}
export class TabNavUnits extends React.Component<TabNavUnitsProps> {
state = {
unitsRegisterCount: 0
}
componentDidMount() {
this.props.fetchRegisterAll({ limit: 1, skip: 1 })
.then(() => {
if(this.props.unit.status === fetchStates.success) {
this.setState({ unitsRegisterCount: this.props.unit.unitsRegisterCount })
}
})
}
我承認問題的一部分是我對此很陌生,所以感謝任何願意幫助我或為我指明正確方向的人。
只需正確聲明fetchRegisterAll
:
fetchRegisterAll: (options: { limit:number , skip: number }) => Promise<void>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.