Cleanups in API typing (& overrides) (#2362)

* Cleanups in API typing (& overrides)

* Less magic "as" overrides
This commit is contained in:
Jaco Greeff
2020-06-18 09:52:39 +02:00
committed by GitHub
parent 64827a6114
commit a1655508ba
6 changed files with 38 additions and 33 deletions
+5 -1
View File
@@ -2,6 +2,8 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { Codec } from './codec';
import BN from 'bn.js';
// We cannot inline this into CodecArg, TS thrws up when building docs
@@ -26,4 +28,6 @@ export type ArrayElementType<T extends ReadonlyArray<unknown>> = T extends Reado
export type BareOpts = boolean | Record<string, boolean>;
export type Callback<T> = (result: T) => void | Promise<void>;
export type Callback<T, E = undefined> = E extends Codec
? (result: T, extra: E) => void | Promise<void>
: (result: T) => void | Promise<void>;