Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method

后端 未结 4 1229
陌清茗
陌清茗 2021-01-02 04:24

An errors blows up when using the typings for the the Google Auth2 API - @types/gapi.auth2. The compiler throws an error 1062 if I create a promise

4条回答
  •  無奈伤痛
    2021-01-02 04:32

    This is the way I found to circumvent this error

    private async loadGapiAuth() {
      await new Promise((resolve) => gapi.load('client:auth2', resolve));
      await new Promise((resolve) => gapi.auth2.init(GAPI_CONFIG).then(resolve));
    }
    

    then I can do this:

    await this.loadGapiAuth();
    const auth = gapi.auth2.getAuthInstance();
    

提交回复
热议问题