typescript 类型报错, 请求支援

新手上路,请多包涵

报错信息

Argument of type 'typeof BottomBar' is not assignable to parameter of type 
'ComponentClass<{ posts: any; key: any; message: any; isLogin: any; user: any; } 
& { 
praiseAction(type: any): (dispatch: any) => Promise<any>; 
favaAction(type: any): (dispatch: any) => Promise<any>; 
addToPraisePanel(key: any, data: any): void; 
removeFromPraisePanel(key: any, uid: any): void; }, any>'.

Types of parameters 'props' and 'props' are incompatible.
    
Type '{ posts: any; key: any; message: any; isLogin: any; user: any; } 
& { praiseAction(type: any): (dispatch: any) => Promise<any>; 
favaAction(type: any): (dispatch: any) => Promise<any>; 
addToPraisePanel(key: any, data: any): void; 
removeFromPraisePanel(key: any, uid: any): void; }' is not assignable to type 'BottomBarProps | undefined'.

Type '{ posts: any; key: any; message: any; isLogin: any; user: any; } 
& { praiseAction(type: any): (dispatch: any) => Promise<any>; 
favaAction(type: any): (dispatch: any) => Promise<any>; 
addToPraisePanel(key: any, data: any): void; 
removeFromPraisePanel(key: any, uid: any): void; }' is not assignable to type 'BottomBarProps'.

Type '{ posts: any; key: any; message: any; isLogin: any; user: any; } 
& { praiseAction(type: any): (dispatch: any) => Promise<any>; 
favaAction(type: any): (dispatch: any) => Promise<any>; 
addToPraisePanel(key: any, data: any): void; 
removeFromPraisePanel(key: any, uid: any): void; }' is missing the following properties from type 'pageOwnProps': favaNum, isFavorite, isLike, likeNum

这是自己写的类型

type pageOwnProps = {
  favaNum: number
  isFavorite: boolean
  isLike: boolean
  likeNum: number
}
type reduxProps = {
  posts: any[] 
  key: string 
  message: string
  isLogin: number
  user: any
}
type reduxAction = {
  praiseAction(type: any): Promise<any>
  favaAction(type: any): Promise<any>
  addToPraisePanel(key: any, data: any): void
  removeFromPraisePanel(key: any, uid: any): void
}
type BottomBarProps = pageOwnProps & reduxProps & reduxAction

redux connect函数

@connect(
  ({ posts, user }) => ({
    posts: posts.postlists,
    key: posts.currentKey,
    message: posts.message,
    isLogin: user.status,
    user: user.userinfo
  }),
  dispatch => ({
    praiseAction(type: any) {
      let data = this.key.split('/')
      return type
        ? dispatch(praiseAdd(data[0], data[1]))
        : dispatch(praiseCancel(data[0], data[1]))
    },
    favaAction(type: any) {
      let data = this.key.split('/')
      return type
        ? dispatch(favaAdd(data[0], data[1]))
        : dispatch(favaCancel(data[0], data[1]))
    },
    addToPraisePanel(key: any, data: any) {
      dispatch(addToPraisePanel(key, data))
    },
    removeFromPraisePanel(key: any, uid: any) {
      dispatch(removeFromPraisePanel(key, uid))
    }
  })
)

类函数

class BottomBar extends Component<BottomBarProps, {}> {
  render() {
    let { favaNum, isFavorite, isLike, likeNum } = this.props
    return (...)
}

报错信息我做了断行,大神请问哪里的问题

阅读 4.7k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进