2019-08-12 15:45:32 +02:00
|
|
|
# `@kbn/utility-types`
|
|
|
|
|
|
|
|
TypeScript utility types for usage in Kibana.
|
|
|
|
|
|
|
|
- This package re-exports a subset of the items in [`utility-types`](https://github.com/piotrwitek/utility-types)
|
|
|
|
- You can also add more utility types here.
|
|
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```ts
|
|
|
|
import { UnwrapPromise } from '@kbn/utility-types';
|
|
|
|
|
|
|
|
type A = Promise<string>;
|
|
|
|
type B = UnwrapPromise<A>; // string
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Reference
|
|
|
|
|
2020-02-28 19:15:43 +01:00
|
|
|
- `Assign<T, U>` — From `U` assign properties to `T` (just like object assign).
|
2019-12-06 19:53:06 +01:00
|
|
|
- `Ensure<T, X>` — Makes sure `T` is of type `X`.
|
2019-08-12 15:45:32 +02:00
|
|
|
- `ObservableLike<T>` — Minimal interface for an object resembling an `Observable`.
|
2020-02-18 20:52:03 +01:00
|
|
|
- `PublicContract<T>` — Returns an object with public keys only.
|
|
|
|
- `PublicKeys<T>` — Returns public keys of an object.
|
2019-12-06 19:53:06 +01:00
|
|
|
- `RecursiveReadonly<T>` — Like `Readonly<T>`, but freezes object recursively.
|
|
|
|
- `ShallowPromise<T>` — Same as `Promise` type, but it flat maps the wrapped type.
|
2020-02-18 20:52:03 +01:00
|
|
|
- `UnionToIntersection<T>` — Converts a union of types into an intersection.
|
2019-12-06 19:53:06 +01:00
|
|
|
- `UnwrapObservable<T>` — Returns wrapped type of an observable.
|
|
|
|
- `UnwrapPromise<T>` — Returns wrapped type of a promise.
|
2020-02-11 19:47:36 +01:00
|
|
|
- `UnwrapPromiseOrReturn<T>` — Returns wrapped type of a promise or the type itself, if it isn't a promise.
|
2020-02-18 20:52:03 +01:00
|
|
|
- `Values<T>` — Returns object or array value types.
|