API reference / @evolu/common / Type / TableId
Interface: TableId<Table>
Defined in: packages/common/src/Type.ts:1632
Extends
Type<"Id",string&Brand<"Id"> &Brand<Table>,string,TableIdError<Table>,string,StringError>
Type Parameters
| Type Parameter |
|---|
Table extends TypeName |
Properties
| Property | Modifier | Type | Description | Inherited from | Defined in |
| ------------------------------------------------ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| [EvoluTypeSymbol] | readonly | true | - | Type.[EvoluTypeSymbol] | packages/common/src/Type.ts:288 |
| Error | public | TableIdError<Table> | The specific error introduced by this Type. ### Example type StringError = typeof String.Error; | Type.Error | packages/common/src/Type.ts:194 |
| Errors | readonly | | StringError | TableIdError<Table> | Error | ParentError ### Example type StringParentErrors = typeof String.Errors; | Type.Errors | packages/common/src/Type.ts:354 |
| from | readonly | (value) => Result<string & Brand<"Id"> & Brand<Table>, | StringError | TableIdError<Table>> | 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:209 |
| fromParent | readonly | (value) => Result<string & Brand<"Id"> & Brand<Table>, TableIdError<Table>> | Creates T from Parent type. This function skips parent Types validations when we have already partially validated value. | Type.fromParent | packages/common/src/Type.ts:265 |
| fromUnknown | readonly | (value) => Result<string & Brand<"Id"> & Brand<Table>, | StringError | TableIdError<Table>> | Creates T from an unknown value. This is useful when a value is unknown. | Type.fromUnknown | packages/common/src/Type.ts:257 |
| Input | public | string | The type expected by from and fromUnknown. ### Example type StringInput = typeof String.Input; | Type.Input | packages/common/src/Type.ts:192 |
| is | readonly | (value) => value is string & Brand<"Id"> & Brand<Table> | 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:286 |
| name | readonly | "Id" | - | Type.name | packages/common/src/Type.ts:200 |
| orThrow | readonly | (value) => string & Brand<"Id"> & Brand<Table> | Creates T from an Input value, throwing an error if validation fails. This is a convenience method that combines from with getOrThrow. When to use: - Configuration values that are guaranteed to be valid (e.g., hardcoded constants) - Application startup where failure should crash the program - Test code with known valid inputs - Converting from trusted sources where validation failure indicates a programming error When NOT to use: - User input validation - use from and handle errors gracefully - Data from external APIs or files - use from for proper error handling - Library code that should return Results rather than throw ### Example // ✅ Good: Known valid constant const maxRetries = PositiveInt.orThrow(3); // ✅ Good: App configuration that should crash on invalid values const appName = SimpleName.orThrow("MyApp"); // ❌ Avoid: User input (use from instead) const userAge = PositiveInt.orThrow(userInput); // Could crash! // ✅ Better: Handle user input gracefully const ageResult = PositiveInt.from(userInput); if (!ageResult.ok) { // Handle validation error } | Type.orThrow | packages/common/src/Type.ts:250 |
| Parent | public | string | The parent type. ### Example type StringParent = typeof String.Parent; | Type.Parent | packages/common/src/Type.ts:196 |
| ParentError | public | StringError | The parent's error. ### Example type StringParentError = typeof String.ParentError; | Type.ParentError | packages/common/src/Type.ts:198 |
| table | public | Table | - | - | packages/common/src/Type.ts:1641 |
| Type | readonly | string & Brand<"Id"> & Brand<Table> | The type this Type resolves to. ### Example type String = typeof String.Type; | Type.Type | packages/common/src/Type.ts:299 |