UNPKG

@aedart/contracts

Version:

The Ion contracts package. Contains types, interfaces and unique identifiers

145 lines (140 loc) 5.14 kB
/** * @aedart/contracts * * BSD-3-Clause, Copyright (c) 2023-present Alin Eugen Deac <aedart@gmail.com>. */ /** * Class Decorator Result * * @see https://github.com/tc39/proposal-decorators */ type ClassDecoratorResult<T extends Function = any> = T | void; /** * Class Decorator * * @see https://github.com/tc39/proposal-decorators */ type ClassDecorator<T extends Function = any> = (target: T, context: ClassDecoratorContext) => ClassDecoratorResult<T>; /** * Class Method Decorator Result * * @see https://github.com/tc39/proposal-decorators */ type ClassMethodDecoratorResult<T extends Function = any> = T | void; /** * Class Method Decorator * * @see https://github.com/tc39/proposal-decorators */ type ClassMethodDecorator<T extends Function = any> = (target: T, context: ClassMethodDecoratorContext) => ClassMethodDecoratorResult<T>; /** * Class Getter Decorator Result * * @see https://github.com/tc39/proposal-decorators */ type ClassGetterDecoratorResult<T extends Function = any> = T | void; /** * Class Getter Decorator * * @see https://github.com/tc39/proposal-decorators */ type ClassGetterDecorator<T extends Function = any> = (target: T, context: ClassGetterDecoratorContext) => ClassGetterDecoratorResult<T>; /** * Class Setter Decorator Result * * @see https://github.com/tc39/proposal-decorators */ type ClassSetterDecoratorResult<T extends Function = any> = T | void; /** * Class Setter Decorator * * @see https://github.com/tc39/proposal-decorators */ type ClassSetterDecorator<T extends Function = any> = (target: T, context: ClassSetterDecoratorContext) => ClassSetterDecoratorResult<T>; /** * Class Field Decorator Result * * @see https://github.com/tc39/proposal-decorators */ type ClassFieldDecoratorResult<Value = any> = (initialValue: Value) => Value | void; /** * Class Field Decorator * * @see https://github.com/tc39/proposal-decorators */ type ClassFieldDecorator<Value = any> = (value: undefined, context: ClassFieldDecoratorContext) => ClassFieldDecoratorResult<Value>; /** * Class Auto-Accessor Decorator Result * * @see https://github.com/tc39/proposal-decorators */ type ClassAutoAccessorDecoratorResult<This extends object = object, Value = any> = ClassAccessorDecoratorResult<This, Value> | void; /** * Class Auto-Accessor Decorator * * @see https://github.com/tc39/proposal-decorators */ type ClassAutoAccessorDecorator<This extends object = object, Value = any> = (value: ClassAccessorDecoratorTarget<This, Value>, context: ClassAccessorDecoratorContext) => ClassAutoAccessorDecoratorResult<This, Value>; /** * Decorator Result * * @see https://github.com/tc39/proposal-decorators */ type DecoratorResult = ClassDecoratorResult | ClassMethodDecoratorResult | ClassGetterDecoratorResult | ClassSetterDecoratorResult | ClassFieldDecoratorResult | ClassAutoAccessorDecoratorResult; /** * Decorator * * @see https://github.com/tc39/proposal-decorators */ type Decorator = ClassDecorator | ClassMethodDecorator | ClassGetterDecorator | ClassSetterDecorator | ClassFieldDecorator | ClassAutoAccessorDecorator; /** * Primitive value * * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#primitive_values */ type Primitive = null | undefined | boolean | number | bigint | string | symbol; /** * Callback type */ type Callback = (...args: any[]) => any; /** * Constructor type */ type Constructor<T = object> = new (...args: any[]) => T; /** * Abstract constructor type */ type AbstractConstructor<T = object> = abstract new (...args: any[]) => T; /** * @deprecated Since version 0.11 - Use {@link ConstructorLike} instead * * Constructor or Abstract Constructor type */ type ConstructorOrAbstractConstructor<T = object> = Constructor<T> | AbstractConstructor<T>; /** * Constructor Like * * In this context, a "constructor like" type is either a class constructor, * or an abstract class constructor. */ type ConstructorLike<T = object> = Constructor<T> | AbstractConstructor<T>; /** * Class method name */ type ClassMethodName<T = object> = { [Name in keyof T]: T[Name] extends Function ? Name : never; }[keyof T]; /** * Class Method Reference * * Array that contains either a class constructor or class instance, and the method name * that must be processed at some point. E.g. the method to be invoked. */ type ClassMethodReference<T = object> = [Constructor<T> | T, ClassMethodName<T>]; /** * Contracts identifier * * @type {Symbol} */ declare const CONTRACTS: unique symbol; export { type AbstractConstructor, CONTRACTS, type Callback, type ClassAutoAccessorDecorator, type ClassAutoAccessorDecoratorResult, type ClassDecorator, type ClassDecoratorResult, type ClassFieldDecorator, type ClassFieldDecoratorResult, type ClassGetterDecorator, type ClassGetterDecoratorResult, type ClassMethodDecorator, type ClassMethodDecoratorResult, type ClassMethodName, type ClassMethodReference, type ClassSetterDecorator, type ClassSetterDecoratorResult, type Constructor, type ConstructorLike, type ConstructorOrAbstractConstructor, type Decorator, type DecoratorResult, type Primitive };