ts-helpers
#
Installation#
API#
assertUnreachableInvoke this assertion for an unreachable case.
#
notEmptyFilter and array so typescript knows there are no null or undefined values.
#
typedIncludesAssert 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.
#
ArrayElementReturns the type of an element of the array
#
ArrayToUnionConverts an array of strings into a discriminated type union.
#
DeepPartialDeeply marks attributes as optional
#
RequireAtLeastOneTell typescript to require at least one of the keys to be present.
#
RequireOnlyOneTell typescript to require only one (not all) of the keys to be present.
#
UnpromiseReturns the result type of a promise.
Can be combined with ReturnType
to get the result of a function that returns a promise.
#
UnreachableCaseErrorThrow this type of error for an unreachable case.
#
ValuesOfReturns a type union of the values of a record/object
#
RelayHelpers 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
#
makeUnionMemberGuardFilter on a discriminated union.