Home > scrubbr > useType

useType() function

Override the type that's being serialized. The return value from this function should be used by custom serializers.

Signature:

export declare function useType(typeName: string, serializedData?: unknown): UseType;

Parameters

Parameter Type Description
typeName string The type that this node should be serialized with.
serializedData unknown Serialized/transformed data for this node.

Returns:

UseType

Example

 // Convert all User types to PublicUser
 scrubbr.typeSerializer('User', (data, state) =\> useType('PublicUser'));