Skip to content

WithStatusBooleans<T>

type WithStatusBooleans<T> = T & { readonly [K in T["status"] as `is${Capitalize<SnakeToCamel<K>>}`]: boolean };

Defined in: utils/status.ts:19

Intersects a type that has a status string field with boolean helpers of the form is{Status} for every status value in the union.

Snake_case status values are converted to camelCase: 'not_connected'isNotConnected

Type Parameter
T extends { status: string; }
type MyResult = WithStatusBooleans<
| { status: 'success'; data: string }
| { status: 'not_found' }
>
// Result has: isSuccess, isNotFound