TSRuntimeConverter

Hierarchy

  • TSRuntimeConverter

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

+ new TSRuntimeConverter(typeConverters?: Map‹string, TypeConverter›): TSRuntimeConverter

Creates an instance of TSRuntimeConverter. Creates an instance of TSRuntimeConverter.

Parameters:

NameTypeDescription
typeConverters?Map‹string, TypeConverterOptional mappings of TypeConverter(s) as a Map instance.

Returns: TSRuntimeConverter

Properties

typeConverters

typeConverters: Map‹string, TypeConverter›

Implementation of Converter.typeConverters

Methods

convert

convert(reflectedType: tsruntimeTypes.ReflectedType): Type

Converts reflected by tsruntime Typescript's type declaration to native type or Pattern instance for easy runtime-validation. [!] Prior to conversion: Classes must have @define decorator applied.

link https://github.com/goloveychuk/tsruntime|tsruntime

Parameters:

NameTypeDescription
reflectedTypetsruntimeTypes.ReflectedTypeReflected type that will be converted.

Returns: Type

Converted type as native type or Pattern instance.


getConverter

getConverter(type: string): TypeConverter | undefined

Implementation of Converter

Returns type converter.

Parameters:

NameType
typestring

Returns: TypeConverter | undefined

TypeConverter instance if found, else undefined.


hasConverter

hasConverter(type: string): boolean

Implementation of Converter

Evaluates if converter for type is already registered by mapping id.

Parameters:

NameType
typestring

Returns: boolean

Returns true if type is registered, else false.


overrideConverter

overrideConverter(kind: string, converter: TypeConverter): void

Implementation of Converter

Overrides already existing type converter by kind mapping on converter.

Parameters:

NameTypeDescription
kindstringKind for which type converter mapping is registered or overridden.
converterTypeConverterTypeConverter instance for registration.

Returns: void


reflect

reflect(reflectedType: tsruntimeTypes.ReflectedType): Type

Reflects with tsruntime Typescript's type declaration to native type or Pattern instance(when native type representation is unavailable) for easier processing. [!] Prior to reflection: Classes must have @define decorator applied.

link https://github.com/goloveychuk/tsruntime|tsruntime

Parameters:

NameTypeDescription
reflectedTypetsruntimeTypes.ReflectedTypeReflected type that will be reflected.

Returns: Type

Reflected type as native type or Pattern instance.


registerConverter

registerConverter(kind: string, typeConverter: TypeConverter, shouldOverride?: boolean): void

Implementation of Converter

Registers type converter on converter.

throws {TypeConverterExists} Thrown if mapping would overridden on existing type converter without explicit call.

Parameters:

NameTypeDescription
kindstringKind for which type converter mapping is registered.
typeConverterTypeConverterTypeConverter instance for registration.
shouldOverride?booleanOptional flag indicating that type mapping should be overridden if exist.

Returns: void


removeConverter

removeConverter(type: string): void

Implementation of Converter

Removes converter by mapping type.

Parameters:

NameType
typestring

Returns: void