Skip to content

Latest commit

 

History

History
31 lines (20 loc) · 1.91 KB

types.createtype.md

File metadata and controls

31 lines (20 loc) · 1.91 KB

Home > @skunkteam/types > createType

createType() function

Create a Type from the given type-implementation.

Signature:

declare function createType<Impl extends BaseTypeImpl<any, any>>(
    impl: Impl,
    override?: Partial<Record<keyof BaseTypeImpl<any, any> | 'typeValidator' | 'typeParser', PropertyDescriptor>>,
): TypeImpl<Impl>;

Parameters

Parameter Type Description
impl Impl the type-implementation
override Partial<Record<keyof BaseTypeImpl<any, any> | 'typeValidator' | 'typeParser', PropertyDescriptor>> (Optional) override certain settings of the created type

Returns:

TypeImpl<Impl>

Remarks

Type-implementations (i.e. subclasses of BaseTypeImpl) provide all the necessary logic and information regarding validation and parsing, but they do not satisfy the Type contract yet. This method takes the construct method of the given type-impl and uses that function as the base of the Type. It then retrofits all properties of the given implementation onto that constructor function.