小编gwi*_*llz的帖子

类型在其自己的“ then”方法的实现回调中直接或间接引用

使用Google Auth2 API键入错误时会出错@types/gapi.auth21062如果我创建一个使用gapi.auth2.GoogleAuth类型解析的承诺,则编译器将引发错误。

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

打字有个小怪癖:

class GoogleAuth {
    ...
    /**
     * Calls the onInit function when the GoogleAuth object is fully initialized, or calls the onFailure function if
     * initialization fails.
     */
    then(onInit: (googleAuth: GoogleAuth) => any, onFailure?: (reason: {error: string, details: string}) => any): any;
    ...
}
Run Code Online (Sandbox Code Playgroud)

使用的代码是这样的:

async function getGapi() {
    return new Promise<gapi.auth2.GoogleAuth>(resolve => {
        ...
    }); …
Run Code Online (Sandbox Code Playgroud)

typescript

6
推荐指数
1
解决办法
244
查看次数

标签 统计

typescript ×1