export function withResolvers(): PromiseWithResolvers { if (typeof Promise.withResolvers === 'function') { return Promise.withResolvers(); } let resolve!: (value: T | PromiseLike) => void; let reject!: (reason?: any) => void; const promise = new Promise((_resolve, _reject) => { resolve = _resolve; reject = _reject; }); return { resolve, reject, promise, }; }