AbstractBigInt extensible (also via wrapper) (#4965)

* AbstractBigInt extensible (also via wrapper)

* Add missing package
This commit is contained in:
Jaco
2022-06-20 14:17:24 +03:00
committed by GitHub
parent 4640939908
commit a7c54d704b
3 changed files with 20 additions and 2 deletions
@@ -0,0 +1,16 @@
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { BigInt } from '@polkadot/x-bigint';
// @ts-expect-error not extensible, we make it extensible here
export abstract class AbstractBigInt extends BigInt {
// @ts-expect-error super() not required, the self magic does that
constructor (value: string | number | bigint | boolean) {
const self = Object(BigInt(value)) as typeof AbstractBigInt;
Object.setPrototypeOf(self, AbstractBigInt.prototype);
return self;
}
}