API reference / @evolu/common / Type / ObjectType

Interface: ObjectType<Props>

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

ObjectType extends Type with an additional props property for reflection.

Extends

  • Type<"Object", Readonly<ObjectT<Props>>, Readonly<ObjectInput<Props>>, ObjectError<{ [K in keyof Props]: InferError<Props[K]> }>, Readonly<ObjectParent<Props>>, ObjectError<{ [K in keyof Props]: InferParentError<Props[K]> }>>

Type Parameters

Type Parameter
Props extends Record<string, AnyType>

Properties

| Property | Modifier | Type | Description | Inherited from | Defined in | | ------------------------------------------------ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | | [EvoluTypeSymbol] | readonly | true | - | Type.[EvoluTypeSymbol] | packages/common/src/Type.ts:169 | | Error | public | ObjectError<{ [K in string | number | symbol]: InferError<Props[K]> }> | The specific error introduced by this Type. ### Example type StringError = typeof String.Error; | Type.Error | packages/common/src/Type.ts:94 | | Errors | readonly | | ObjectError<{ [K in string | number | symbol]: InferError<Props[K]> }> | ObjectError<{ [K in string | number | symbol]: InferParentError<Props[K]> }> | Error | ParentError ### Example type StringParentErrors = typeof String.Errors; | Type.Errors | packages/common/src/Type.ts:235 | | from | readonly | (value) => Result<Readonly<DrainOuterGeneric<{ [K in string | number | symbol]: ({ [K in string | number | symbol]: InferType<Props[K]> } & { [K in string | number | symbol]?: (...)[(...)] extends OptionalType<(...)> ? InferType<(...)> : never })[K] }>>, | ObjectError<{ [K in string | number | symbol]: InferError<Props[K]> }> | ObjectError<{ [K in string | number | symbol]: InferParentError<Props[K]> }>> | 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:109 | | fromParent | readonly | (value) => Result<Readonly<DrainOuterGeneric<{ [K in string | number | symbol]: ({ [K in string | number | symbol]: InferType<Props[K]> } & { [K in string | number | symbol]?: (...)[(...)] extends OptionalType<(...)> ? InferType<(...)> : never })[K] }>>, ObjectError<{ [K in string | number | symbol]: InferError<Props[K]> }>> | 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:143 | | fromUnknown | readonly | (value) => Result<Readonly<DrainOuterGeneric<{ [K in string | number | symbol]: ({ [K in string | number | symbol]: InferType<Props[K]> } & { [K in string | number | symbol]?: (...)[(...)] extends OptionalType<(...)> ? InferType<(...)> : never })[K] }>>, | ObjectError<{ [K in string | number | symbol]: InferError<Props[K]> }> | ObjectError<{ [K in string | number | symbol]: InferParentError<Props[K]> }>> | Creates T from an unknown value. This is useful when a value is unknown. | Type.fromUnknown | packages/common/src/Type.ts:116 | | Input | public | Readonly<DrainOuterGeneric<{ [K in string | number | symbol]: ({ [K in string | number | symbol]: InferInput<Props[K]> } & { [K in string | number | symbol]?: Props[K] extends OptionalType<U> ? InferInput<U> : never })[K] }>> | The type expected by from and fromUnknown. ### Example type StringInput = typeof String.Input; | Type.Input | packages/common/src/Type.ts:92 | | is | readonly | (value) => value is Readonly<DrainOuterGeneric<{ [K in string | number | symbol]: ({ [K in string | number | symbol]: InferType<Props[K]> } & { [K in string | number | symbol]?: Props[K] extends OptionalType<U> ? InferType<U> : never })[K] }>> | 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.is | packages/common/src/Type.ts:167 | | name | readonly | "Object" | - | Type.name | packages/common/src/Type.ts:100 | | Parent | public | Readonly<DrainOuterGeneric<{ [K in string | number | symbol]: ({ [K in string | number | symbol]: InferParent<Props[K]> } & { [K in string | number | symbol]?: Props[K] extends OptionalType<U> ? InferParent<U> : never })[K] }>> | The parent type. ### Example type StringParent = typeof String.Parent; | Type.Parent | packages/common/src/Type.ts:96 | | ParentError | public | ObjectError<{ [K in string | number | symbol]: InferParentError<Props[K]> }> | The parent's error. ### Example type StringParentError = typeof String.ParentError; | Type.ParentError | packages/common/src/Type.ts:98 | | props | readonly | Props | - | - | packages/common/src/Type.ts:2753 | | 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:125 | | toParent | readonly | (value) => Parent | The opposite of fromParent. | Type.toParent | packages/common/src/Type.ts:146 | | Type | readonly | T | The type this Type resolves to. ### Example type String = typeof String.Type; | Type.Type | packages/common/src/Type.ts:180 |

Was this page helpful?