kibana/packages/kbn-utility-types
Spencer 98c57063f7
[7.16] [eslint] enable type-specific lint rules (#114184) (#117451)
* [eslint] enable type-specific lint rules

(cherry picked from commit e824fdc2c8)

* autofix all violations

Co-authored-by: spalger <spalger@users.noreply.github.com>
2021-11-03 23:58:42 -06:00
..
jest chore(NA): moving @kbn/utility-types to babel transpiler (#107159) (#107320) 2021-07-30 17:05:52 -04:00
src [7.16] [eslint] enable type-specific lint rules (#114184) (#117451) 2021-11-03 23:58:42 -06:00
BUILD.bazel [build_ts_refs] improve caches, allow building a subset of projects (#107981) (#108139) 2021-08-11 05:08:54 -04:00
package.json chore(NA): moving @kbn/utility-types to babel transpiler (#107159) (#107320) 2021-07-30 17:05:52 -04:00
README.md [resubmit] Prep agg types for new platform (#58893) (#58922) 2020-02-28 15:31:18 -07:00
tsconfig.json [build_ts_refs] improve caches, allow building a subset of projects (#107981) (#108139) 2021-08-11 05:08:54 -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.