TSRuntimeConverter
Hierarchy
- TSRuntimeConverter
Implements
- Converter
- Converter
Index
Constructors
Properties
Methods
Constructors
constructor
+ new TSRuntimeConverter(typeConverters?
: Map‹string, TypeConverter›): TSRuntimeConverter
Creates an instance of TSRuntimeConverter. Creates an instance of TSRuntimeConverter.
Parameters:
Name | Type | Description |
---|---|---|
typeConverters? | Map‹string, TypeConverter› | Optional 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:
Name | Type | Description |
---|---|---|
reflectedType | tsruntimeTypes.ReflectedType | Reflected 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:
Name | Type |
---|---|
type | string |
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:
Name | Type |
---|---|
type | string |
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:
Name | Type | Description |
---|---|---|
kind | string | Kind for which type converter mapping is registered or overridden. |
converter | TypeConverter | TypeConverter 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:
Name | Type | Description |
---|---|---|
reflectedType | tsruntimeTypes.ReflectedType | Reflected 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:
Name | Type | Description |
---|---|---|
kind | string | Kind for which type converter mapping is registered. |
typeConverter | TypeConverter | TypeConverter instance for registration. |
shouldOverride? | boolean | Optional 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:
Name | Type |
---|---|
type | string |
Returns: void