kibana/packages/kbn-utility-types
Spencer 4385ac4d83
[eslint] enable type-specific lint rules (#114184)
* [eslint] enable type-specific lint rules

* autofix violations

* duplicate eslint-disable to new export statement

Co-authored-by: spalger <spalger@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-11-03 16:56:17 -06:00
..
jest chore(NA): moving @kbn/utility-types to babel transpiler (#107159) 2021-07-30 18:43:50 +01:00
src [eslint] enable type-specific lint rules (#114184) 2021-11-03 16:56:17 -06:00
BUILD.bazel [build_ts_refs] improve caches, allow building a subset of projects (#107981) 2021-08-10 22:12:45 -07:00
package.json chore(NA): moving @kbn/utility-types to babel transpiler (#107159) 2021-07-30 18:43:50 +01:00
README.md
tsconfig.json [build_ts_refs] improve caches, allow building a subset of projects (#107981) 2021-08-10 22:12:45 -07: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.