Add side effect check workaround (#4994) (#5009)

* Add side effect check workaround (#4994)

* Update packages/api/src/base/Getters.ts

Co-authored-by: Jaco <jacogr@gmail.com>

* Update packages/api/src/base/Getters.ts

Co-authored-by: Jaco <jacogr@gmail.com>

* eslint --fix

* inline isUndefined

Co-authored-by: Jaco <jacogr@gmail.com>
This commit is contained in:
Btwiuse Arch
2022-07-01 14:22:51 +03:00
committed by GitHub
co-authored by Jaco
parent 230cc2c437
commit 50e9e9cb1e
+5 -3
View File
@@ -9,8 +9,6 @@ import type { Metadata } from '@polkadot/types/metadata';
import type { CallFunction, RegistryError } from '@polkadot/types/types';
import type { ApiDecoration, ApiInterfaceRx, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, QueryableCalls, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '../types';
import { assertReturn } from '@polkadot/util';
import { packageInfo } from '../packageInfo';
import { findCall, findError } from './find';
import { Init } from './Init';
@@ -21,7 +19,11 @@ interface PkgJson {
}
function assertResult<T> (value: T | undefined): T {
return assertReturn(value, 'Api needs to be initialized before using, listen on \'ready\'');
if (typeof value === 'undefined') {
throw new Error('Api needs to be initialized before using, listen on \'ready\'');
}
return value;
}
export abstract class Getters<ApiType extends ApiTypes> extends Init<ApiType> implements ApiDecoration<ApiType> {