convert base.js to ts

This commit is contained in:
atu
2020-08-05 13:44:19 -07:00
parent 7cb1956ba8
commit 5ffec37d37
@@ -1,12 +1,18 @@
import {Component} from 'react';
import log from '../utils/log';
export default class Base extends Component {
interface Apis {
[key: string]: any;
}
export default class Base<Props, States> extends Component<Props, States> {
private apis: Apis = {};
async componentWillUnmount() {
await this.clearDisposers();
}
async registerApi(apis) {
async registerApi(apis: Apis) {
if (!this.apis) this.apis = {};
for (const [name, api] of Object.entries(apis)) {
@@ -22,7 +28,7 @@ export default class Base extends Component {
}
}
async clearDisposer(name) {
async clearDisposer(name: string) {
if (!this.apis || !this.apis[name]) return;
const item = this.apis[name];