// Type definitions for regenerator-runtime 0.13 // Project: https://github.com/facebook/regenerator // Definitions by: ExE Boss // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Minimum TypeScript Version: 3.6 export as namespace regeneratorRuntime; declare global { var regeneratorRuntime: typeof import('.'); } /** * The implementation of the generator. */ export type InnerFunction = ( this: T, context: Context, ) => unknown; export type ContextLocation = number | 'end'; export type CompletionType = 'normal' | 'return' | 'throw' | 'break' | 'continue'; // prettier-ignore export type TryLocationsList = ReadonlyArray< | readonly [number, number] | readonly [number, number | undefined, number, ContextLocation] >; export interface CompletionRecord { type: CompletionType; arg: unknown; } export interface TryEntry { readonly tryLoc: number; readonly catchLoc?: number; readonly finallyLoc?: number; readonly afterLoc?: ContextLocation; completion?: CompletionRecord; } export interface DelegatedIterator { iterator: Iterator; } export interface Context { readonly tryEntries: readonly [ { readonly tryLoc: 'root' } & Omit, ...TryEntry[] ]; /** * The value passed to `next()`. */ sent: TNext; /** * The label of the previous location, needs to be set to `next` at the start of user code. */ prev: unknown; /** * The label of the next location, is set to `'end'` when the generator needs to close abruptly. */ next: number | 'end'; /** * Whether the generator has finished. */ done: boolean; /** * The return value, set by `abrupt("return")`. */ rval: TReturn; /** * If truthy, then it contains information about the currently `yield*` delegated iterator. */ delegate: DelegatedIterator | undefined; /** * The generator method. */ method: 'next' | 'return' | 'throw'; /** * The argument passed to the generator method. */ arg: unknown; reset(skipTempReset?: boolean): void; /** * Ends the iteration. */ stop(): TReturn; /** * Dispatches an exception to `innerFn` * * @param exception The exception to dispatch. */ dispatchException(exception: unknown): boolean; /** * @param type The completion type. * @param rval The return value. */ abrupt(type: 'return', rval?: TReturn): unknown; /** * @param type The completion type. * @param exception The exception to throw. */ abrupt(type: 'throw', exception?: unknown): never; /** * @param type The completion type. * @param nextLoc The location label to resume iteration at. */ abrupt(type: 'break' | 'continue', nextLoc: number): unknown; /** * @param type The completion type. * @param arg The [[Value]] or [[Target]] of the completion record. */ abrupt(type: CompletionType, arg?: unknown): unknown; /** * @param record The completion record. * @param afterLoc The location to resume the generator at, only used by normal completions. */ complete(record: Readonly, afterLoc?: ContextLocation): unknown; /** * Used to signify the end of a finally block. * * @param finallyLoc The label of the beginning of the finally block. */ finish(finallyLoc: number): unknown; /** * Used to obtain the exception that was thrown in the associated try block. * * @param tryLoc The label of the beginning of the try block. */ catch(tryLoc: number): unknown; /** * @param iterable The iterable to delegate to. * @param resultName The name of the property to assign to on this context. * @param nextLoc The label of the location where to resume iteration. */ delegateYield( iterable: { [Symbol.iterator](): Iterator }, resultName: string, nextLoc: ContextLocation, ): unknown; [ /** * Expects properties to match `/^t[+-]?\d*(?:(?<=\d)\.\d*|\.\d+)?(?:e[+-]?\d+)?$/`. */ temp: string ]: any; } export function wrap( innerFn: InnerFunction, // tslint:disable-next-line: ban-types outerFn?: Function | null, self?: T, tryLocsList?: TryLocationsList, ): Generator; export interface ResolvablePromiseConstructorLike extends PromiseConstructorLike { resolve(value?: T): PromiseLike; } export class AsyncIterator implements AsyncGenerator { constructor( generator: Generator< TYield | PromiseLike | awrap, TReturn | PromiseLike | awrap >, PromiseImpl: ResolvablePromiseConstructorLike, ); // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. next(...args: [] | [TNext]): Promise>; return(value: TReturn | PromiseLike): Promise>; throw(e: any): Promise>; [Symbol.asyncIterator](): this; } export function async( innerFn: InnerFunction, outerFn: GeneratorFunction, self?: T, tryLocsList?: TryLocationsList, PromiseImpl?: ResolvablePromiseConstructorLike, ): AsyncIterator< TYield extends PromiseLike ? Await : Exclude>, TReturn extends PromiseLike ? Await : Exclude> >; export function async( innerFn: InnerFunction, // tslint:disable-next-line: ban-types outerFn?: Function | null, self?: T, tryLocsList?: TryLocationsList, PromiseImpl?: ResolvablePromiseConstructorLike, ): Promise ? Await : TReturn>; export function awrap(arg: V): awrap; export class awrap { constructor(arg: V); // Used to tell TypeScript that this class is to be treated as a nominal type: private readonly '#private'; readonly __await: V; } export function isGeneratorFunction(func: unknown): func is GeneratorFunction; export function keys(object: {}): () => IteratorResult; // tslint:disable-next-line: ban-types export function mark(genFun: F): F & GeneratorFunction; export function values>(iterable: { [Symbol.iterator](): I }): I; export function values(iterableOrArrayLike: Iterable | ArrayLike): Iterator;