エンジニアとしての市場価値を測りませんか?PR

企業からあなたに合ったオリジナルのスカウトを受け取って、市場価値を測りましょう

2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[React + Typescript] Property 'type' is missing in type but required in type 'AnyAction'

Posted at

#課題
今日もTypeScriptから怒られた。

something.tsx
export default lifecycle({
  async componentDidMount() {
    store.dispatch(getPackages)
  }
})
エラー
> Property 'type' is missing in type '(dispatch: Dispatch) => Promise<void>' but required in type 'AnyAction'.

#結論
今日も型だった

something.tsx
export default lifecycle({
  async componentDidMount() {
    store.dispatch<any>(getPackages)
  }
})

TypeScript素人故怒られまくる。
エラー解決するたびに只管メモします。

#参考情報
Typescript error when dispatching a thunk: Argument of type 'ThunkAction>' is not assignable to parameter of type 'AnyAction'.
https://github.com/reduxjs/redux-toolkit/issues/587

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

Qiita Advent Calendar is held!

Qiita Advent Calendar is an article posting event where you post articles by filling a calendar 🎅

Some calendars come with gifts and some gifts are drawn from all calendars 👀

Please tie the article to your calendar and let's enjoy Christmas together!

2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?