LoginSignup
1
0

More than 5 years have passed since last update.

utility-typesの$ShapeとFlowの$Shapeとの違い

Posted at

utility-typesはTSの便利な型集(Omitなど常用するものが入っている)であるが、この$Shapeの定義はflow v0.90以前とは異なっているの注意が必要。

export type $Shape<T extends object> = Partial<T>;

で、nullを許容しないが、v0.90までのFlowはnullableなのでflow→tsからの一時しのぎにutils-typesを導入すると型エラーが起きうる。
まあ、一瞬で$ShapeからPartialにできるので現状とくにutils-typesの$Shapeを使う意味はない。

flow v0.90以後はPartialと同等なので、こちらも純粋にPartialを使えばいい。

Changed $Shape<> types to reject null and void as subtypes
https://github.com/facebook/flow/releases/tag/v0.90.0

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