import { UnpackPromise, Tuple, Obj } from './index'; /** * Defines a function type with the given arguments, return value and `this` context. * * @param TArgs Tuple of argument types that defined function accepts. * @param TRet Type of value this function returns. * @param TThis Type of `this` function context. */ export declare type Func = any, TRet = unknown, TThis = any> = (this: TThis, ...args: TArgs) => TRet; /** * Defines an asyncronous function, which is typically marked with `async` modifier, * with arguments specified as a tuple type `TArgs` and return type as `Promise`. * * @param TArgs Tuple type of arguments that defined async function accepts. * @param TRet Type this function returns `Promise` for. * @param TThis Type of `this` function context. * */ export declare type AsyncFunc = any, TRet = unknown, TThis = any> = Func, TThis>; /** * Defines the unpacked result type of the `Promise` returned by the specified `AsyncFunc`. * * @param TAsyncFunc `AsyncFunc` to unpack `Promise` return type from. */ export declare type AsyncFuncReturnType = (UnpackPromise>); /** * Defines type predicate function, i.e. a function that takes `suspect` of `unknown` type * and returns a boolean that denotes whether `suspect` is of `TTarget` type or not. * * @param TTarget Type that this predicate checks `suspect` to conform to. * @param TThis Type of `this` context of the predicate. */ export declare type TypePredicate = (this: TThis, suspect: unknown) => suspect is TTarget; /** * Defines a type that is the same as `TClass[TMethodName]`, but restricts `this` * context to be of type `TClass`. This is usefull when you want to create proxies * for some methods and have `this` type being automatically set to `TClass` in their bodies, * so that compiler won't `this is implicit any` error and you don't have to type `this` * manually. * * @param TClass Class instance type to take method from (also becomes `this` type). * @param TMethodName Keyof `TClass` that defines the method name to take from `TClass`. */ export declare type Method, TMethodName extends keyof TClass> = (this: TClass, ...args: Parameters) => ReturnType; /** * Defines `typeof this` that the given `TFunc` must be run with. * * @param TFunc Function type to infer `this` context type from. */ export declare type FuncContext = TFunc extends Func ? TThis : never; /** * Defines a function type with the given arguments, and `this` context. * Return value of the defined function type is `void`. * * * @param TArgs Tuple of argument types that this function accepts. * @param TThis Type `this` function context. * */ export declare type Routine = any, TThis = any> = Func; /** * Defines an asyncronous function, which is typically marked with `async` modifier, * with arguments specified as a tuple type `TArgs` and return type as `Promise`. * * @param TArgs Tuple type of arguments that defined async function accepts. * @param TThis Type `this` function context. */ export declare type AsyncRoutine = any, TThis = any> = Func, TThis>; /** * Defines a function type with the given arguments and `this` context. * Defined function may return `TRet` synchronously or asynchronously i.e. * `Promise`. * * @param TArgs Tuple of argument types that defined function accepts. * @param TRet Type of value this function returns. * @param TThis Type of `this` function context. */ export declare type SyncOrAsyncFunc = any, TRet = unknown, TThis = any> = (this: TThis, ...args: TArgs) => (TRet | Promise); /** * Defines a function type with the given arguments and `this` context. * Defined function may return synchronously or asynchronously. Its return value * should be ignored (it is `void | Promise`). * * @param TArgs Tuple of argument types that defined function accepts. * @param TThis Type of `this` function context. */ export declare type SyncOrAsyncRoutine = any, TThis = any> = (this: TThis, ...args: TArgs) => (void | Promise); //# sourceMappingURL=functions.d.ts.map