kibana/packages/kbn-utility-types
Kibana Machine c635144ebe
chore(NA): correctly setup dep order on js_library to fix windows build (#100420) (#100428)
Co-authored-by: Tiago Costa <tiagoffcc@hotmail.com>
2021-05-20 20:57:21 -04:00
..
jest [7.x] Elastic License 2.0 (#90192) 2021-02-03 18:39:13 -08:00
tsd_tests chore(NA): moving @kbn/utility-types into bazel (#97151) (#97199) 2021-04-14 23:38:45 -04:00
BUILD.bazel chore(NA): correctly setup dep order on js_library to fix windows build (#100420) (#100428) 2021-05-20 20:57:21 -04:00
index.ts [7.x] Elastic License 2.0 (#90192) 2021-02-03 18:39:13 -08:00
package.json chore(NA): moving @kbn/utility-types into bazel (#97151) (#97199) 2021-04-14 23:38:45 -04:00
README.md [resubmit] Prep agg types for new platform (#58893) (#58922) 2020-02-28 15:31:18 -07:00
tsconfig.json chore(NA): moving @kbn/utility-types into bazel (#97151) (#97199) 2021-04-14 23:38:45 -04: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.