ts-helpers
Installation#
API#
assertUnreachable#
Invoke this assertion for an unreachable case.
notEmpty#
Filter and array so typescript knows there are no null or undefined values.
typedIncludes#
Assert whether a variable is a member of an array in a type-safe way. This also avoids the "string" is not a member of TYPE errors.
ArrayElement#
Returns the type of an element of the array
ArrayToUnion#
Converts an array of strings into a discriminated type union.
DeepPartial#
Deeply marks attributes as optional
RequireAtLeastOne#
Tell typescript to require at least one of the keys to be present.
RequireOnlyOne#
Tell typescript to require only one (not all) of the keys to be present.
Unpromise#
Returns the result type of a promise.
Can be combined with ReturnType to get the result of a function that returns a promise.
UnreachableCaseError#
Throw this type of error for an unreachable case.
ValuesOf#
Returns a type union of the values of a record/object
Relay#
Helpers for working with Relay Connections
GetConnectionNode
Extracts the Node from a Relay Connection, even if some or all of the Connection is nullable
GetConnectionNodeArray
Helper that just returns an array of the Connection Node, also works if Connection is nullable
makeUnionMemberGuard#
Filter on a discriminated union.