2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Jest × Chakra UI】Type '{ children: (false | Element)[]; ref: ForwardedRef<HTMLButtonElement>; }' is not assignable to typeとProperty 'children' does not exist on type の解決方法

Posted at

はじめに

Chakra UIがv3にアップデートされた後、発生したエラーについて解決方法を紹介します。

この記事は個人的なアウトプットを目的として作成したものです。そのため、誤った情報や不足している内容が含まれている可能性があります。もし間違いや気になる点がございましたら、ぜひご指摘いただけますと幸いです

問題

Chakra UI v3を使用しているプロジェクトで、Jestを使ったテストを実行した際に、以下のような型エラーが複数のコンポーネントで発生しました。

Property 'children' does not exist on type
Type '{ children: (false | Element)[]; ref: ForwardedRef<HTMLButtonElement>; }' is not assignable to type 

解決方法

tsconfig.jsonmoduleResolutionNodeからbundlerに変更することで解決しました。

変更前

"moduleResolution": "Node",

変更後

"moduleResolution": "bundler",

終わりに

引き続き学びを深め、ReactやChakra UIの新しいバージョンに適応しながら、学習を進めたいと思います。

参考

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?