From 5ffec37d37c27fe56071f7e165c46dffdab6bbac Mon Sep 17 00:00:00 2001 From: atu Date: Wed, 5 Aug 2020 13:44:19 -0700 Subject: [PATCH] convert base.js to ts --- client/src/components/{base.js => base.tsx} | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) rename client/src/components/{base.js => base.tsx} (78%) 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];