Options
All
  • Public
  • Public/Protected
  • All
Menu

Type aliases

AccessorDecorator

AccessorDecorator<TPropType, TPropNameLimit>: function

Defines a static or instance get/set property accessor decorator function type.

Type parameters

  • TPropType

    Decorated property accessor type.

  • TPropNameLimit: string | symbol

    Defines the type that the decorated accessor property name extends.

param

Decorated accessor property class' prototype (for instance accessor) or constructor function (for static accessor).

param

Name of the decorated property accessor.

param

Descriptor of the decorated property accessor.

remarks

If the accessor decorator returns a value, it will be used as the Property Descriptor for the member.

When targeting versions less than ES5 propDescriptor will be undefined and the return value is ignored.

See https://www.typescriptlang.org/docs/handbook/decorators.html#accessor-decorators

AreSame

AreSame<T1, T2>:

Defines true if T1 is exactly T2, false otherwise. Even AreSame<unknown, any> expands to false. Only the same types expand to true. Beware that this type works as vanilla extends clause with function types, so comparing functions is not that strict.

Type parameters

  • T1

    Type to strictly compare to T2.

  • T2

    Type to strictly compare to T1.

AsyncFunc

AsyncFunc<TArgs, TRet, TThis>: Func<TArgs, Promise<TRet>, TThis>

Defines an asyncronous function, which is typically marked with async modifier, with arguments specified as a tuple type TArgs and return type as Promise<TRet>.

Type parameters

  • TArgs: Tuple<any>

    Tuple type of arguments that defined async function accepts.

  • TRet

    Type this function returns Promise for.

  • TThis

    Type of this function context.

AsyncFuncReturnType

AsyncFuncReturnType<TAsyncFunc>:

Defines the unpacked result type of the Promise returned by the specified AsyncFunc.

Type parameters

  • TAsyncFunc: AsyncFunc

    AsyncFunc to unpack Promise return type from.

AsyncRoutine

AsyncRoutine<TArgs, TThis>: Func<TArgs, Promise<unknown>, TThis>

Defines an asyncronous function, which is typically marked with async modifier, with arguments specified as a tuple type TArgs and return type as Promise<unknown>.

Type parameters

  • TArgs: Tuple<any>

    Tuple type of arguments that defined async function accepts.

  • TThis

    Type this function context.

BoolOp

BoolOp: false | true | If<any, any, any> | Not<any> | Or<any> | Nor<any> | And<any> | Nand<any> | Xor<any, any> | Equiv<any, any> | UnionIncludes<unknown> | Extends<unknown>

Defines boolean type opeartor tree type. E.g.

import { Op } from 'ts-typedefs';
type ExampleBoolOp = Op.Or<
    Op.If< Op.UnionIncludes<number | string>,
        Not<Op.Extends<boolean>>,
        false
    >,
    Op.Extends<null>
>;

CanBeNull

CanBeNull<TSuspect>: Or<[IsUnknown<TSuspect>, UnionIncludes<TSuspect, null>]>

Defines true if TSuspect contains null, false otherwise. As a special case, defines true when TSuspect is unknown or any, false if TSuspect is never.

Type parameters

  • TSuspect

CanBeUndef

CanBeUndef<TSuspect>: Or<[IsUnknown<TSuspect>, UnionIncludes<TSuspect, undefined>]>

Defines true if TSuspect contains undefined, false otherwise. As a special case, defines true when TSuspect is unknown or any, false if TSuspect is never.

Type parameters

  • TSuspect

Class

Class<TInstance, TArgs>: object

Defines constructor function type.

Type parameters

  • TInstance

    Type of instances produced by this constructor.

  • TArgs: any []

    Tuple type of arguments, this constructor accepts.

ClassDecorator

ClassDecorator: function

Defines a class decorator generic function type.

param

Target class constructor function type.

param

Decorated class constructor function.

remarks

If the class decorator returns a value, it will replace the class declaration with the provided constructor function.

See https://www.typescriptlang.org/docs/handbook/decorators.html#-decorators

ClassPrototype

ClassPrototype<TClass>: TClass["prototype"]

Defines constructor function prototype property type.

Type parameters

DeepMapValues

DeepMapValues<TSrcObj, TMappedValue>: object

Defines the same object type as TSrcObj, but all values types replaced with TMappedValue type recursively.

Type parameters

  • TSrcObj: Obj

    Type of object to take keys from.

  • TMappedValue

    Type of values in the created object type.

DeepMutable

DeepMutable<TObj>: object

Defines the same type as TObj but with readonly modifier removed from its properties recursively.

Type parameters

  • TObj: Obj

    Target object type to make its properties recursively mutable.

DeepNonNullable

DeepNonNullable<TObj>: object

Defines the same type as TObj but with all properties made NonNullable<> recursively.

Type parameters

  • TObj: Obj

    Target object type to make its properties recursively non-nullable.

DeepNullable

DeepNullable<TObj>: object

Defines the same type as TObj but with all properties made Nullable<> recursively.

Type parameters

  • TObj: Obj

    Target object type to make its properties recursively nullable.

DeepPartial

DeepPartial<TObj>: object

Defines the same type as TObj but all properties are made recursively Partial<>.

Type parameters

  • TObj: Obj

    Object type to make all properties optional.

DeepReadonly

DeepReadonly<TObj>: object

Defines the same type as TObj but with readonly modifier added to its properties recursively.

Type parameters

  • TObj: Obj

    Target object type to make its properties recursively readonly.

DeepRequired

DeepRequired<TObj>: object

Defines the same type as TObj but all properties are made recursively Required<>.

Type parameters

  • TObj: Obj

    Object type to remove optional ? flag from.

DeepWiden

DeepWiden<TObj>: DeepWidenImpl<TObj extends Tuple ? TupleToArray<TObj> : TObj>

Defines a Widen<>ed version of TObj with all its values widened recursively. See Widen

Type parameters

  • TObj: Obj

    Target object (including tuple) type to widen recursively.

Eval

Eval<TOp, TParam>: Eval_0<TOp, TParam>

Defines true or false by applying the given TOp operator object tree to the given TParam.

Type parameters

  • TOp: Op.BoolOp

    BoolOp operator tree to apply to TParam.

  • TParam

    Value of any type to pipe through BoolOp.

remarks

Because of some TypeScript limitations and bugs (https://stackoverflow.com/questions/55192212/typescript-circular-type-alias-produces-no-error-and-instead-widens-unit-types) BoolOp tree must be not more than 4 levels deep.

FilterProps

FilterProps<TObj, TApproveCond>: Pick<TObj, FindKeys<TObj, TApproveCond>>

Defines the same type as TObj but with particular properties filtered out according to TApproveCond.

Type parameters

  • TObj: Obj

    Target object type to filter properties from.

  • TApproveCond: Op.BoolOp

    Op.BoolOp type that gets evaluated for each property of TObj. If Eval<TApproveCond, TObj[TKey]> === false TKey will be filtered out.

FindKeys

FindKeys<TObj, TApproveCond>: ValueOf<object>

Defines a union of property names taken from TObj according to the given TApproveCond.

Type parameters

  • TObj: Obj

    Target object type to filter properties from.

  • TApproveCond: Op.BoolOp

    Op.BoolOp type that gets evaluated for each property of TObj. If Eval<TApproveCond, TObj[TKey]> === true TKey will be present in the resulting union .

Func

Func<TArgs, TRet, TThis>: function

Defines a function type with the given arguments, return value and this context.

Type parameters

  • TArgs: Tuple<any>

    Tuple of argument types that defined function accepts.

  • TRet

    Type of value this function returns.

  • TThis

    Type of this function context.

FuncContext

FuncContext<TFunc>: TFunc extends Func<any, any, infer TThis> ? TThis : never

Defines typeof this that the given TFunc must be run with.

Type parameters

  • TFunc: Func

    Function type to infer this context type from.

InstanceType

InstanceType<TClass>: TClass extends Class<infer TInstance> ? TInstance : ClassPrototype<TClass>

Defines an instance type of the given class or the type of prototype property of the given Prototypeful object. TClass may even be an abstract class, though those ones are not newable, but the type of their instances can be obtained through their prototype property.

Type parameters

  • TClass: Prototypeful | Class

    Abstract or plain class/interface to unpack instance type from.

IsAny

IsAny<TSuspect>: Extends<boolean, TSuspect extends never ? true : false>

Defines true if TSuspect is exactly of any type, false otherwise.

Type parameters

  • TSuspect

    Target type to check.

IsAsyncFunc

IsAsyncFunc<TSuspect>: Extends<TSuspect, AsyncFunc>

Shorthand for Extends<TSuspect, AsyncFunc>.

Type parameters

  • TSuspect

    Target type to check.

IsFunc

IsFunc<TSuspect>: Extends<TSuspect, Func>

Shorthand for Extends<TSuspect, Func>.

Type parameters

  • TSuspect

    Target type to check.

IsNever

IsNever<TSuspect>: Extends<TSuspect, never>

Defines true if TSuspect is exactly of never type, false otherwise.

Type parameters

  • TSuspect

    Target type to check.

IsNotAny

IsNotAny<TSuspect>: Not<IsAny<TSuspect>>

Defines false if TSuspect is exactly of any type, true otherwise.

Type parameters

  • TSuspect

    Target type to check.

IsNotNever

IsNotNever<TSuspect>: Not<IsNever<TSuspect>>

Defines false if TSuspect is exactly of never type, true otherwise.

Type parameters

  • TSuspect

    Target type to check.

IsNotUnknown

IsNotUnknown<TSuspect>: Not<IsUnknown<TSuspect>>

Defines false if TSuspect is exactly of unknown type, true otherwise.

Type parameters

  • TSuspect

    Target type to check.

IsNullable

IsNullable<TSuspect>: Or<[IsUnknown<TSuspect>, UnionIncludes<TSuspect, null | undefined>]>

Defines true if TSuspect contains both undefined and null types, false otherwise. As a special case, defines true when TSuspect is unknown or any, false if TSuspect is never.

Type parameters

  • TSuspect

    Target type to check

IsUnknown

IsUnknown<TSuspect>: And<[IsNotAny<TSuspect>, Extends<unknown, TSuspect>]>

Defines true if TSuspect is exactly of unknown type, false otherwise.

Type parameters

  • TSuspect

    Target type to check.

MapValues

MapValues<TSrcObj, TMappedValue>: Obj<TMappedValue, keyof TSrcObj>

Defines the same object type as TSrcObj, but all values types replaced with TMappedValue type.

Type parameters

  • TSrcObj: Obj

    Type of object to take keys from.

  • TMappedValue

    Type of values in the created object type.

Merge

Merge<TObj1, TObj2>: Pick<TObj1, Exclude<keyof TObj1, keyof TObj2>> & TObj2

Merge objects TObj1 and TObj2. Properties types from TObj2 override the ones defined on TObj1. This type is analogous to the return type of Object.assign()

Type parameters

Method

Method<TClass, TMethodName>: function

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.

Type parameters

  • TClass: Obj<Func, TMethodName>

    Class instance type to take method from (also becomes this type).

  • TMethodName: keyof TClass

    Keyof TClass that defines the method name to take from TClass.

MethodDecorator

MethodDecorator<TArgs, TRetval, TMethNameLimit>: function

Defines a static or instance method decorator function type.

Type parameters

  • TArgs: any []

    Tuple type that defines arguments decorated method accepts.

  • TRetval

    Return type of the decorated method.

  • TMethNameLimit: string | symbol

    Defines the type that the decorated method name extends.

param

Prototype of the decorated method's class (for instance method) or constructor function (for static method).

param

Name of the property, that contains decorated method.

param

Descriptor of the decorated method property.

remarks

Decorated function this context is of typeof protoOrClass type.

If the method decorator returns a value, it will be used as the Property Descriptor for the method.

When targeting versions less than ES5 methodDescriptor will be undefined and the return value is ignored.

See https://www.typescriptlang.org/docs/handbook/decorators.html#method-decorators

Mutable

Mutable<TObj, TKeys>: Merge<TObj, PickAsMutable<TObj, TKeys>>

Defines the same type as TObj but with readonly modifier removed from its TKeys.

Type parameters

  • TObj: Obj

    Object type to make TKeys mutable in.

  • TKeys: keyof TObj

    Union type of keys that will be defined as mutable in the resulting type.

MutuallyExclusive

MutuallyExclusive<A, B>: A & object | B & object

Defines a discriminated union of two object types. This simply means that when properties of A are present in the value shape all the properties of B must be undefined and vice versa.

Type parameters

remarks

The resulting type ensures that the properties of only one object type (A or B) are present in the resulting object shape with all other properties of the second object type being undefined via the special handling of unit type properties in TypeScript object unions.

In this case the discriminator of the union is the unit type undefined.

// Properties "a" and "c" on foo may not coexist, one of them must be undefined.
// Type of property "b" depends on the active object shape (it may be either
// number or string)
type Foo = MutuallyExclusive<{ a: string, b: string }, { b: number, c: boolean }>;

declare const val: Foo;

if (val.a == null) {
    val; // { a?: undefined, b: number, c: boolean }
} else {
    val; // { a: string, b: string, c?: undefined }
}

NonNullableProps

NonNullableProps<TObj, TKeys>: Merge<TObj, PickAsNonNullableProps<TObj, TKeys>>

Defines the same type as TObj but with TKeys made non-nullable (and required).

Type parameters

  • TObj: Obj

    Object type to make TKeys non-nullable in.

  • TKeys: keyof TObj

    Union type of keys that will be defined as non-nullable in the resulting type.

NotExtends

NotExtends<TExtendee, TExtender, TExtendee>: Not<Extends<TExtender, TExtendee>>

Shorthand for Op.Not<Op.Extends<TExtendee>>. Shorthand for Not<Extends<>>.

Type parameters

  • TExtendee
  • TExtender
  • TExtendee

Nullable

Nullable<T>: T | null | undefined

Defines type T that may also be null or undefined.

Type parameters

  • T

    Target type to make "nullable".

NullableProps

NullableProps<TObj, TKeys>: Merge<TObj, PickAsNullableProps<TObj, TKeys>>

Defines the same type as TObj but with TKeys made nullable (and optional).

Type parameters

  • TObj: Obj

    Object type to make TKeys nullable in.

  • TKeys: keyof TObj

    Union type of keys that will be defined as nullable in the resulting type.

Obj

Obj<TValue, TKeys>: Record<TKeys, TValue>

Defines an object with keys of type TKey, and all values of TValue type.

Type parameters

  • TValue

    Type of values, stored in object's properties.

  • TKeys: PropertyKey

    Union type of keys stored in defined object type. It is any by default, if you use this parameter, most probably you will specify a union of some string or number unit types.

OptionalLikelyUndefProps

OptionalLikelyUndefProps<TObj>: Merge<TObj, PickLikelyUndefPropsAsOptional<TObj>>

Defines the same type as TObj, but adds 'optional' modifier ? to all properties that allow undefined as their value type (this includes unknown and any).

Type parameters

  • TObj: Obj

    Target object type to take properties from.

ParameterDecorator

ParameterDecorator<TParamType>: function

Defines a static or instance method parameter decorator function type. Type parameter TParamType is an experimental feature and it won't work untill the following issue is solved https://github.com/Microsoft/TypeScript/issues/30102

Type parameters

  • TParamType

    Type of the parameter this decorator may be applied to.

param

Decorated method parameter class' prototype (for instance method) or constructor function (for static method).

param

Name of the decorated parameter's method.

param

The ordinal index of the parameter in the function’s parameter list.

remarks

Return value is totally ignored.

See https://www.typescriptlang.org/docs/handbook/decorators.html#parameter-decorators

Partial

Partial<TObj, TKeys>: Merge<TObj, PickAsOptional<TObj, TKeys>>

Defines the same type as TObj but with TKeys made optional.

Type parameters

  • TObj: Obj

    Object type to make TKeys optional in.

  • TKeys: keyof TObj

    Union type of keys that will be defined as optional in the resulting type.

PickAsMutable

PickAsMutable<TObj, TKeys>: object

Shorthand for Mutable<Pick<TObj, TKeys>>, but better optimized (into one mapped object type).

Type parameters

  • TObj: Obj

    Object type to pick properties from.

  • TKeys: keyof TObj

    Union type of keys to pick.

PickAsNonNullableProps

PickAsNonNullableProps<TObj, TKeys>: object

Shorthand for NonNullableProps<Pick<TObj, TKeys>>, but better optimized (into one mapped object type).

Type parameters

  • TObj: Obj

    Object type to pick properties from.

  • TKeys: keyof TObj

    Union type of keys to pick.

PickAsNullableProps

PickAsNullableProps<TObj, TKeys>: object

Shorthand for NullableProps<Pick<TObj, TKeys>>, but better optimized (into one mapped object type).

Type parameters

  • TObj: Obj

    Object type to pick properties from.

  • TKeys: keyof TObj

    Union type of keys to pick.

PickAsOptional

PickAsOptional<TObj, TKeys>: object

Shorthand for Partial<Pick<TObj, TKeys>>, but better optimized (into one mapped object type).

Type parameters

  • TObj: Obj

    Object type to pick properties from.

  • TKeys: keyof TObj

    Union type of keys to pick.

PickAsReadonly

PickAsReadonly<TObj, TKeys>: object

Shorthand for Readonly<Pick<TObj, TKeys>>, but better optimized (into one mapped object type).

Type parameters

  • TObj: Obj

    Object type to pick properties from.

  • TKeys: keyof TObj

    Union type of keys to pick.

PickAsRequired

PickAsRequired<TObj, TKeys>: object

Shorthand for Required<Pick<TObj, TKeys>>, but better optimized (into one mapped object type).

Type parameters

  • TObj: Obj

    Object type to pick properties from.

  • TKeys: keyof TObj

    Union type of keys to pick.

Primitive

Primitive: undefined | null | string | number | bigint | false | true | symbol

Defines a union of all possible value types defined in the language.

remarks

null and undefined are considered to be primitive types.

PropertyDecorator

PropertyDecorator<TPropType, TPropNameLimit>: function

Defines a static or instance property decorator function type.

Type parameters

  • TPropType

    Decorated property type.

  • TPropNameLimit: string | symbol

    Defines the type that the decorated property name extends.

param

Decorated property class' prototype (for instance property) or constructor function (for static property).

param

Name of the decorated property.

remarks

Return value is totally ignored.

See https://www.typescriptlang.org/docs/handbook/decorators.html#property-decorators

Readonly

Readonly<TObj, TKeys>: Merge<TObj, PickAsReadonly<TObj, TKeys>>

Defines the same type as TObj but with TKeys made readonly.

Type parameters

  • TObj: Obj

    Object type to make TKeys readonly in.

  • TKeys: keyof TObj

    Union type of keys that will be defined as readonly in the resulting type.

ReadonlyObj

ReadonlyObj<TValue, TKey>: Readonly<Obj<TValue, TKey>>

Same as BasicObject<>, but defines all properties as readonly.

Type parameters

  • TValue

    Type of values, stored in object's readonly properties.

  • TKey: PropertyKey

RemoveKeys

RemoveKeys<TSrcObj, TKeysUnion>: Pick<TSrcObj, Exclude<keyof TSrcObj, TKeysUnion>>

Defines the same object type as TSrcObj, but without TKeysUnion keys.

Type parameters

  • TSrcObj: Obj

    Type of object to remove keys from.

  • TKeysUnion: keyof TSrcObj

    A single or union type of keys to remove from TSrcObj.

RenameKey

RenameKey<TObj, TPrevKey, TNewKey>: Merge<RemoveKeys<TObj, TPrevKey>, Obj<TObj[TPrevKey], TNewKey>>

Defines the same object type as TObj, but with TPrevKey key renamed to TNewKey.

Type parameters

  • TObj: Obj

    Object type to rename key in.

  • TPrevKey: keyof TObj

    Target property key to rename.

  • TNewKey: PropertyKey

    New name (or symbol) for the TObj[TPrevKey] property.

ReplaceValues

ReplaceValues<TSrcObj, TKeys, TNewValue>: Merge<TSrcObj, Obj<TNewValue, TKeys>>

Defines the same object type as TSrcObj, but with TKeys keys having the value of type TNewValue.

Type parameters

  • TSrcObj: Obj

    Type of object to replace property type of.

  • TKeys: keyof TSrcObj

    Union type of keys to change value types of (often just a string literal).

  • TNewValue

    Type of values stored at TKeys keys in the returned type.

Required

Required<TObj, TKeys>: Merge<TObj, PickAsRequired<TObj, TKeys>>

Defines the same type as TObj but with TKeys made required.

Type parameters

  • TObj: Obj

    Object type to make TKeys required in.

  • TKeys: keyof TObj

    Union type of keys that will be defined as required in the resulting type.

Routine

Routine<TArgs, TThis>: Func<TArgs, void, TThis>

Defines a function type with the given arguments, and this context. Return value of the defined function type is void.

Type parameters

  • TArgs: Tuple<any>

    Tuple of argument types that this function accepts.

  • TThis

    Type this function context.

StrKeyOf

StrKeyOf<TObj>: Extract<keyof TObj, string>

Shorthand for Extract<keyof TObj, string>, i.e. it gets only those keys that are assignable to string (without number | symbol)

Type parameters

  • TObj: Obj

    Objet type to get string keys from.

SyncOrAsyncFunc

SyncOrAsyncFunc<TArgs, TRet, TThis>: function

Defines a function type with the given arguments and this context. Defined function may return TRet synchronously or asynchronously i.e. Promise<TRet>.

Type parameters

  • TArgs: Tuple<any>

    Tuple of argument types that defined function accepts.

  • TRet

    Type of value this function returns.

  • TThis

    Type of this function context.

SyncOrAsyncRoutine

SyncOrAsyncRoutine<TArgs, TThis>: function

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<unknown>).

Type parameters

  • TArgs: Tuple<any>

    Tuple of argument types that defined function accepts.

  • TThis

    Type of this function context.

Tag

Tag<TTarget, TTagName>: TTarget & object

Defines nominal type by adding a property with TTagName value to TTarget. TTagName must be unique across your application, treat it like the name of your nominal type.

Type parameters

  • TTarget

    Target type to put a tag on.

  • TTagName

    Unique name of the defined nominal type.

    With this type, you may pick particular subclass of values from the given type and force your clients to filter other values that are assignable to TTarget but don't obey to your prerequisites, thus making them pay more attention to them.

remarks

import { Tag } from 'ts-typedefs';

// Number value that is strictly grater than zero.
type PositiveInt = Tag<number, 'PositiveInt'>;

// Represents valid csv string.
type CsvString = Tag<string, 'CsvString'>;


async function getUser(userId: PositiveInt) {
     return userRepository.findById(userId);
}

function parseCsv(csvString: CsvString) {
     // Here you may be sure that client payed attention to checking the input

     const lines = csvString.split('\n').map(line => line.split(','));
}

getUser(-2);                // compile error
getUser(58);                // compile error
getUser(58 as PositiveInt); // fine (explicit cast pays your attention to prerequisites)

parseCsv('\nbla bla');      // compile error
parseCsv('a,b,c\nd,e,f' as CsvString); // fine

Tuple

Tuple<TItems>: [TItems] | TItems []

Defines tuple type of TItems union type values.

Type parameters

  • TItems

    Union type of items of the defined tuple.

TupleFirstItem

TupleFirstItem<TTuple>: TTuple[0]

Shorthand for TTuple[0].

Type parameters

  • TTuple: any []

    Target tuple to get first item from.

TupleLastItem

TupleLastItem<TTuple>: TTuple[TupleShift<TTuple>["length"]]

Defines the type of the last item in TTuple. If TTuple is empty, then expands to undefined.

Type parameters

  • TTuple: any []

    Target tuple to get last item from.

TuplePop

TuplePop<TTuple>: Overwrite<TupleShift<TTuple>, TTuple>

Removes the last item from TTuple. Does nothing if tuple is empty.

Type parameters

  • TTuple: any []

    Tuple to remove last item from.

TuplePush

TuplePush<TTuple, TNewLastItem>: Overwrite<TupleUnshift<TTuple, any>, TTuple & Obj<TNewLastItem>>

Pushes TNewLastItem item to the back of TTuple.

Type parameters

  • TTuple: any []

    Tuple to push TNewLastItem to the back.

  • TNewLastItem

    Item type to push to the back of TTuple.

TupleShift

TupleShift<TTuple>: function extends function ? TRet : never

Removes the first item from TTuple. Does nothing if tuple is empty.

Type parameters

  • TTuple: any []

    Tuple to remove first item from.

TupleToArray

TupleToArray<TTuple>:

Widens [T1, T2, T3, ...] tuple type into an array type (T1 | T2 | T3 | ...)[]

Type parameters

  • TTuple: Tuple

    Tuple type to widen to array.

TupleUnshift

TupleUnshift<TTuple, TNewFirstItem>: function extends function ? TRet : never

Pushes TNewFirstItem item to the front of TTuple.

Type parameters

  • TTuple: any []

    Tuple to push TNewFirstItem to the front.

  • TNewFirstItem

    Item type to push to the front of TTuple.

TypeName

TypeName: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"

Defines a union of all possible strings retuned by applying typeof operator.

TypePredicate

TypePredicate<TTarget, TThis>: function

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.

Type parameters

  • TTarget

    Type that this predicate checks suspect to conform to.

  • TThis

    Type of this context of the predicate.

UnionExcludes

UnionExcludes<TNeedle, TUnion, TValue>: IsNever<Extract<TUnion, TValue>>

Shorthand for Op.Not<Op.UnionIncludes<TNeedle>>. Defines false if the given TUnion includes TValue. This type is opposite to UnionIncludes<>.

Type parameters

  • TNeedle
  • TUnion

    Union type to search for TValue in.

  • TValue

    Type to match with TUnion members.

UnpackArray

UnpackArray<TArray>:

Defines the type of values of the given TArray

Type parameters

  • TArray: any []

    Type of array to infer items type from.

UnpackPromise

UnpackPromise<TPromise>:

Defines the type of value, which is passed to TPromise.then(cb) cb callback.

Type parameters

  • TPromise: Promise<any>

    Target Promise to unpack result from.

UnpackTypePredicate

UnpackTypePredicate<TTypePred>:

Defines a type that the given TTypePred checks its suspect to conform to.

Type parameters

  • TTypePred: TypePredicate

    Target TypePredicate function to unpack.

ValueOf

ValueOf<TObj>: TObj[keyof TObj]

Defines a union type of all the values stored in TObj.

Type parameters

  • TObj: Obj

    Object type to get values from.

Widen

Widen<T>:

Defines string or number or boolean or Array<T[number]> that represents a widened contravariant version of the given unit type T.

Type parameters

  • T

    Unit type to widen.

remarks

  • If T is a tuple type it is widened to Array<> type.
  • If T is string or number literal or true or false it gets widened to string or number or boolean respectivelly.
  • If T is not a unit type, it is left as it is.

Functions

reinterpret

  • reinterpret<T>(value: any): T

C++ style operator, a syntactic sugar for writing casts like value as any as T when a simple value as T cast cannot be performed. Use it with caution!

Type parameters

  • T

Parameters

  • value: any

Returns T

  • Inherited
  • Protected
  • Private
  • Static
  • Module
  • Object
  • Property
  • Function
  • Variable
  • Index
  • Type
  • Class
  • Interface
  • Enum
  • Constructor
  • Getter/Setter
Made with ❤️ by pirix-gh. Documentation generated by TypeDoc.