LoginSignup
2

More than 5 years have passed since last update.

Flow の型警告を消す

Last updated at Posted at 2017-09-04

後からFlowを導入してまだ型が無い時とかに。

any型を付けちゃう

const a: stirng = 1;
// number This type is incompatible with string

const b: any = 2;
// no error

$FlowFixMeコメントを前の行に書く

// $FlowFixMe
const c: string = 3;
// no error

ただこのコメントのパターンは設定で変えれるみたいです。

.flowconfig
[options]
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe

suppress_typeを使う

options.suppress_typeで設定したワードを仮の型で使えるようになる。ちなみに、複数指定できるぽい。

.flowconfig
[options]
suppress_type=$FlowFixMe
suppress_type=$FixByNextMonth

こんな感じで、

const a: $FlowFixme = 1;
function b(): $FixByNextMonth {
  return 'foo';
}

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