kibana/packages/kbn-utility-types
Vadim Dalecky 48df3c8893
Utility types (#41246)
* feat: 🎸 add @kbn/utility-types

* feat: 🎸 improve @kbn/utility-types

* chore: 🤖 move @kbn/utility-types to dev deps

* chore: 🤖 change @kbn/utility-types build setup

* fix: 🐛 implement review suggestions

* feat: 🎸 add ShallowPromise type

* Update packages/kbn-utility-types/README.md

Co-Authored-By: Luke Elmers <lukeelmers@gmail.com>

* test: 💍 add tests for utility-types

* chore: 🤖 add utility-types tests to TypeScript config

* test: 💍 remove negative tests to not cause TypeScript fail

* chore: 🤖 remove ref to type defs to try fix CI tests

* Update packages/kbn-utility-types/index.ts

Co-Authored-By: Spencer <email@spalger.com>

* chore: 🤖 add TS types index to fix `grunt run:test_projects`

* chore: 🤖 use similar tsconfig.json as in other packages

* chore: 🤖 add "clean" script

* chore: 🤖 add kbn:bootstrap script
2019-08-12 15:45:32 +02:00
..
test-d Utility types (#41246) 2019-08-12 15:45:32 +02:00
index.ts Utility types (#41246) 2019-08-12 15:45:32 +02:00
package.json Utility types (#41246) 2019-08-12 15:45:32 +02:00
README.md Utility types (#41246) 2019-08-12 15:45:32 +02:00
tsconfig.json Utility types (#41246) 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
  • 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

  • UnwrapPromise<T> — Returns wrapped type of a promise.
  • UnwrapObservable<T> — Returns wrapped type of an observable.
  • ShallowPromise<T> — Same as Promise type, but it flat maps the wrapped type.
  • ObservableLike<T> — Minimal interface for an object resembling an Observable.