Collection of common TS utility types, interfaces and utils.
npm install @luolapeikko/ts-common
Loadable
type to handle loadable value (e.g. value, value Promise, callback function returning value).NonEmptyArray
and NonEmptyReadonlyArray
.RecordHaveReadonlyKeys
and RecordHaveWritableKeys
.OneOf
type to handle one of types (non-union way).objectEntries
, objectKeys
, objectValues
and objectMap
to handle better return types.toError(value: unknown): Error | UnknownError
, errorAs(err, TypeError): TypeError
or errorWith(err, (msg) => new TypeError(msg)): TypeError
IToString
, IToJSON
.See more features on Package documentation