0
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.

Chakra UI をアップデートしたら props が補完されなくなった

Last updated at Posted at 2021-12-03

2021/12/14追記
v1.7.3 で修正されたのでこの対応は不要になった


@chakra-ui/react を v1.6.12 から v1.7.2 にアップデートしたら、 widthboxShadow など一部のプロパティが補完されなくなってしまった(新規インストールでも同様)
以下は VSCode で width プロパティを入力しているときの様子

v1.6.8
2.gif

v1.7.2
1.gif

issue にもあがっている
https://github.com/chakra-ui/chakra-ui/issues/5153

型定義を覗く

v1.6.8 ではこうなっているのが

スクリーンショット 2021-11-22 14.53.48.png

v1.7.2 だとこうなっている

スクリーンショット 2021-11-22 14.56.31.png

色々用意されていたリテラル型が全部 string にされてしまっている

解決策

公式ドキュメント を参考にテーマファイルから型定義ファイルを生成する
ポイントは出力先を /node_modules/@chakra-ui/styled-system/dist/declarations/src/theming.types.d.ts に変更すること

$ yarn add -D @chakra-ui/cli
$ yarn chakra-cli tokens /theme/index.ts --out node_modules/@chakra-ui/styled-system/dist/declarations/src/theming.types.d.ts
0
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
0
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?