Home > @skunkteam/types > createType
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>;
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>
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.