How to write the store of mobx under typescript?

< H2 > Plan A: < / H2 >

directory structure:

store
  |--Auth
       |--index.ts
       |--interface.ts
  |--Bank
       |--index.ts
       |--interface.ts

Auth/interface.ts :

import {observable, action} from "mobx";
import {post} from "../../util/fetch";
import {IResponse} from "../../util/fetch";

class Auth {
  @observable
  isLogin:string = false;

  async loginWithNameAndPw({username, password}: {username: string, password: string}): Promise<IResponse> {
    try {
      const response = await post(`${userServer}/authz/oauth/token`);
      return response;
    } catch (e) {
      console.log(e);
      return e;
    }
  }

  async sendMsgCode({mobile}: {mobile: string}): Promise<IResponse> {
    try {
      const response = await post(`${userServer}/authz/sms/send`);
      return response;
    } catch (e) {
      console.log(e);
      return e;
    }
  }

}

const authStore = new Auth();
export default authStore;

should the type of members of class be separate from class (scheme A), or written with class (scheme B), or should I write both correctly?

Jun.27,2022

Plan B is fine. It is not recommended to separate


. I will choose option A

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b2ba86-2ba96.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b2ba86-2ba96.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?