API reference / @evolu/common / Type / RecordType
Interface: RecordType<KeyName, KeyT, KeyInput, KeyError, KeyParent, KeyParentError, Value>
Defined in: packages/common/src/Type.ts:2348
RecordType extends Type with additional key
and value
properties
for reflection.
Extends
Type
<"Record"
,Readonly
<Record
<KeyT
,InferType
<Value
>>>,Readonly
<Record
<KeyInput
,InferInput
<Value
>>>,RecordError
<KeyError
,InferError
<Value
>>,Readonly
<Record
<KeyParent
,InferParent
<Value
>>>,RecordError
<KeyParentError
,InferParentError
<Value
>>>
Type Parameters
Type Parameter | Default type |
---|---|
KeyName extends TypeName | - |
KeyT extends string | - |
KeyInput extends string | - |
KeyError extends TypeError | - |
KeyParent extends string | - |
KeyParentError extends TypeError | - |
Value extends AnyType | AnyType |
Properties
Property | Modifier | Type | Description | Inherited from | Defined in |
---|---|---|---|---|---|
[EvoluTypeSymbol] | readonly | true | - | Type .[EvoluTypeSymbol] | packages/common/src/Type.ts:168 |
Error | public | RecordError <KeyError , InferError <Value >> | The specific error introduced by this Type. ### Example type StringError = typeof String.Error; | Type .Error | packages/common/src/Type.ts:93 |
Errors | readonly | | RecordError <KeyError , InferError <Value >> | RecordError <KeyParentError , InferParentError <Value >> | Error | ParentError ### Example type StringParentErrors = typeof String.Errors; | Type .Errors |
from | readonly | (value ) => Result <Readonly <Record <KeyT , InferType <Value >>>, | RecordError <KeyError , InferError <Value >> | RecordError <KeyParentError , InferParentError <Value >>> | Creates T from an Input value. This is useful when we have a typed value. from is a typed alias of fromUnknown . | Type .from | packages/common/src/Type.ts:108 |
fromParent | readonly | (value ) => Result <Readonly <Record <KeyT , InferType <Value >>>, RecordError <KeyError , InferError <Value >>> | 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 .fromParent | packages/common/src/Type.ts:142 |
fromUnknown | readonly | (value ) => Result <Readonly <Record <KeyT , InferType <Value >>>, | RecordError <KeyError , InferError <Value >> | RecordError <KeyParentError , InferParentError <Value >>> | Creates T from an unknown value. This is useful when a value is unknown. | Type .fromUnknown | packages/common/src/Type.ts:115 |
Input | public | Readonly <Record <KeyInput , InferInput <Value >>> | The type expected by from and fromUnknown . ### Example type StringInput = typeof String.Input; | Type .Input | packages/common/src/Type.ts:91 |
is | readonly | (value ) => value is Readonly<Record<KeyT, InferType<Value>>> | 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 a string 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 .is | packages/common/src/Type.ts:166 |
key | readonly | Type <KeyName , KeyT , KeyInput , KeyError , KeyParent , KeyParentError > | - | - | packages/common/src/Type.ts:2364 |
name | readonly | "Record" | - | Type .name | packages/common/src/Type.ts:99 |
Parent | public | Readonly <Record <KeyParent , InferParent <Value >>> | The parent type. ### Example type StringParent = typeof String.Parent; | Type .Parent | packages/common/src/Type.ts:95 |
ParentError | public | RecordError <KeyParentError , InferParentError <Value >> | The parent's error. ### Example type StringParentError = typeof String.ParentError; | Type .ParentError | packages/common/src/Type.ts:97 |
to | readonly | (value ) => Input | The 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 .to | packages/common/src/Type.ts:124 |
toParent | readonly | (value ) => Parent | The opposite of fromParent . | Type .toParent | packages/common/src/Type.ts:145 |
Type | readonly | T | The type this Type resolves to. ### Example type String = typeof String.Type; | Type .Type | packages/common/src/Type.ts:179 |
value | readonly | Value | - | - | packages/common/src/Type.ts:2372 |