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);