API reference / @evolu/common / Type / RecursiveType

Interface: RecursiveType<ParentType>

Defined in: packages/common/src/Type.ts:3126

Extends

Type Parameters

Type Parameter
ParentType extends AnyType

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
[EvoluTypeSymbol]readonlytrue-Type.[EvoluTypeSymbol]packages/common/src/Type.ts:167
ErrorpublicInferError<ParentType>The specific error introduced by this Type. ### Example type StringError = typeof String.Error;Type.Errorpackages/common/src/Type.ts:92
Errorsreadonly| InferError<ParentType> | InferParentError<ParentType>ErrorParentError ### Example type StringParentErrors = typeof String.Errors;Type.Errors
fromreadonly(value) => Result<InferType<ParentType>, | InferError<ParentType> | InferParentError<ParentType>>Creates T from an Input value. This is useful when we have a typed value. from is a typed alias of fromUnknown.Type.frompackages/common/src/Type.ts:107
fromParentreadonly(value) => Result<InferType<ParentType>, InferError<ParentType>>Creates T from Parent type. This function skips parent Types validations/transformations when we have already partially validated/transformed value. For example, TrimString.from checks whether a value is a string and trims it. If we only want to trim a string, we can use fromParent. ### Example // string & Brand<"Trimmed"> const value = TrimString.fromParent("a ").value; // as efficient as foo.trim()Type.fromParentpackages/common/src/Type.ts:141
fromUnknownreadonly(value) => Result<InferType<ParentType>, | InferError<ParentType> | InferParentError<ParentType>>Creates T from an unknown value. This is useful when a value is unknown.Type.fromUnknownpackages/common/src/Type.ts:114
InputpublicInferInput<ParentType>The type expected by from and fromUnknown. ### Example type StringInput = typeof String.Input;Type.Inputpackages/common/src/Type.ts:90
isreadonly(value) => value is InferType<ParentType>A type guard that checks whether an unknown value satisfies the Type. ### Example const value: unknown = "hello"; if (String.is(value)) { // TypeScript now knows valueis astring here. console.log("This is a valid string!"); } const strings: unknown[] = [1, "hello", true, "world"]; const filteredStrings = strings.filter(String.is); console.log(filteredStrings); // ["hello", "world"]Type.ispackages/common/src/Type.ts:165
namereadonly"Recursive"-Type.namepackages/common/src/Type.ts:98
ParentpublicInferParent<ParentType>The parent type. ### Example type StringParent = typeof String.Parent;Type.Parentpackages/common/src/Type.ts:94
ParentErrorpublicInferParentError<ParentType>The parent's error. ### Example type StringParentError = typeof String.ParentError;Type.ParentErrorpackages/common/src/Type.ts:96
toreadonly(value) => InferInputThe opposite of from and fromUnknown. This is useful to transform T back to its Input representation. For refine, it only removes the brand. For transform, it changes value.Type.topackages/common/src/Type.ts:123
toParentreadonly(value) => InferParentThe opposite of fromParent.Type.toParentpackages/common/src/Type.ts:144
TypereadonlyInferTypeThe type this Type resolves to. ### Example type String = typeof String.Type;Type.Typepackages/common/src/Type.ts:178

Methods

getParentType()

getParentType(): ParentType;

Defined in: packages/common/src/Type.ts:3135

Returns

ParentType

Was this page helpful?