import type { Any } from '@web-io/common/es/types'; import type { IAbortablePromise } from '../types/http'; /** * 扩展Promise增加abort方法,用于取消操作,比如取消网络请求. * 由于Promise必须通过new创建,extends语法糖采用apply形式实现类继承,会报错TypeError: undefined is not a promise(https://www.zhihu.com/question/415605538),采用代理形式实现Promise. */ declare class AbortablePromise implements IAbortablePromise { private promise; [Symbol.toStringTag]: 'AbortablePromise'; constructor(executor: ((resolve: (value: T | PromiseLike) => void, reject: (reason?: Any) => void) => void) | Promise); then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: Any) => TResult2 | PromiseLike) | undefined | null): AbortablePromise; catch(onrejected?: ((reason: Any) => TResult | PromiseLike) | undefined | null): AbortablePromise; finally(onfinally?: (() => void) | undefined | null): AbortablePromise; abort?(): void; } export default AbortablePromise;