kibana/packages/kbn-utility-types
Brandon Kobel 57af8462e4
[7.x] Elastic License 2.0 (#90192)
* Updating everything except the license headers themselves

* Applying ESLint rules

* Manually replacing the stragglers
2021-02-03 18:39:13 -08:00
..
jest [7.x] Elastic License 2.0 (#90192) 2021-02-03 18:39:13 -08:00
test-d [7.x] Elastic License 2.0 (#90192) 2021-02-03 18:39:13 -08:00
index.ts [7.x] Elastic License 2.0 (#90192) 2021-02-03 18:39:13 -08:00
package.json [7.x] Elastic License 2.0 (#90192) 2021-02-03 18:39:13 -08:00
README.md [resubmit] Prep agg types for new platform (#58893) (#58922) 2020-02-28 15:31:18 -07:00
tsconfig.json Get rid of global types (#81739) (#81884) 2020-10-28 16:16:27 +03:00

@kbn/utility-types

TypeScript utility types for usage in Kibana.

  • This package re-exports a subset of the items in utility-types
  • You can also add more utility types here.

Usage

import { UnwrapPromise } from '@kbn/utility-types';

type A = Promise<string>;
type B = UnwrapPromise<A>; // string

Reference

  • Assign<T, U> — From U assign properties to T (just like object assign).
  • Ensure<T, X> — Makes sure T is of type X.
  • ObservableLike<T> — Minimal interface for an object resembling an Observable.
  • PublicContract<T> — Returns an object with public keys only.
  • PublicKeys<T> — Returns public keys of an object.
  • RecursiveReadonly<T> — Like Readonly<T>, but freezes object recursively.
  • ShallowPromise<T> — Same as Promise type, but it flat maps the wrapped type.
  • UnionToIntersection<T> — Converts a union of types into an intersection.
  • UnwrapObservable<T> — Returns wrapped type of an observable.
  • UnwrapPromise<T> — Returns wrapped type of a promise.
  • UnwrapPromiseOrReturn<T> — Returns wrapped type of a promise or the type itself, if it isn't a promise.
  • Values<T> — Returns object or array value types.