UNPKG

anux-common

Version:

[![Build Status](https://travis-ci.com/Anupheaus/anux-common.svg?branch=master)](https://travis-ci.com/Anupheaus/anux-common) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/dd0e0bd3a96247a5a78c02a812f949f8)](https://www.codacy.com/app/Anuphea

48 lines (47 loc) 2.18 kB
export interface IMap<T = any> { [key: string]: T; } export interface MapOf<T> { [key: string]: T; } export interface AnyObject { [key: string]: unknown; } export declare type AnyFunction<ReturnType = any> = (...args: any[]) => ReturnType; export interface Record { id: string; } export declare type ConstructorOf<T = {}> = new (...args: any[]) => T; export declare type TypeOf<T> = { new (...args: any[]): T; } | ((...args: any[]) => T) | Function; export declare type Diff<T extends string | number | symbol, U extends string | number | symbol> = ({ [P in T]: P; } & { [P in U]: never; } & { [x: string]: never; })[T]; export declare type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>; export declare type Minus<T, U> = { [P in Diff<keyof T, keyof U>]: T[P]; }; declare type UpsertableObject<T extends Record, TKey extends keyof T = keyof T> = (Pick<T, TKey> | Partial<T>) & Record; declare type IfElsePrimitiveType<T, U> = T extends PrimitiveType ? T : U; export declare type Updatable<T extends Record, TKey extends keyof T = keyof T> = UpsertableObject<T & Record, TKey>; export declare type Upsertable<T extends Record | PrimitiveType, TKey extends keyof T = keyof T> = IfElsePrimitiveType<T, UpsertableObject<T & Record, TKey>>; export declare type EnsureId<T> = T extends Record ? T : never; export declare type PrimitiveType = string | number | boolean; export declare type PrimitiveOrObjectType = PrimitiveType | AnyObject; export declare type PrimitiveOrRecordType = PrimitiveType | Record; export declare type IsPrimitiveType<T> = T extends PrimitiveType ? T : never; export declare type IsPrimitiveOrObjectType<T> = T extends PrimitiveOrObjectType ? T : never; export declare type IsPrimitiveOrRecordType<T> = T extends PrimitiveOrRecordType ? T : never; export declare type PromiseMaybe<T = void> = T | Promise<T>; export declare type DeepPartial<T> = { [P in keyof T]?: T[P] extends (infer U)[] ? DeepPartial<U>[] : T[P] extends readonly (infer U)[] ? readonly DeepPartial<U>[] : DeepPartial<T[P]>; }; export interface Disposable { dispose(): void; } export {};