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 5 years have passed since last update.

flow type 書き方の雑メモ

Posted at

react routerのpathから貰ったパラメータ値の型

文字列として貰っているので、その辺のパラメータの型定義もstringにする。

Objectキーが変数の場合の型定義

let var1 = 'key1';
let var2 = 'key2';
let myMap: { [string | void]: string } = {};
myMap[key1] = 'value1';
myMap[key2] = 'value2';

react componentのインスタンス変数の型

export default class MyComp extends Component {
    hoge: string;

    constructor() {
        this.hoge = null;
    }

  componentWillMount() {
    this.hoge = 'abc';
  }
}

setIntervalとsetTimeoutの戻り値の型

const foo: TimeoutID = setTimeout(() => {}, 300);
const bar: IntervalID = setInterval(() => {}, 300);
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?