diff --git a/client/src/components/base.js b/client/src/components/base.tsx similarity index 78% rename from client/src/components/base.js rename to client/src/components/base.tsx index 0e7da78..511204f 100644 --- a/client/src/components/base.js +++ b/client/src/components/base.tsx @@ -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 extends Component { + 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];