BigNumber ^4.1.0 now has own type declaration, overrides @types/
sfkiwi opened this issue · 1 comments
This issue seems to be appearing due to a module pulling in bignumber.js v4.1.0
. It looks like GDAX is specifically including v4.0.2
so the dependency may be coming from another module in my project.
The problem I am seeing is that typescript compiler throws an error when bignumber.js v4.1.0
or greater is included in node_modules/.
As of v4.1.0
bignumber.js includes its own type declaration, which does not include the BigNumberStatic, NumberLike etc declarations. This causes a typescript error "bignumber has no exported member 'Numberlike'"
as typescript is using the local index.d.ts v4.1.0
in the node_modules/bignumber.js folder rather than the node_modules/@types version v4.0.2
index.d.ts. These types are used in LiveOrderBook, Triggers, BookBuilder.
//node_modules/gdax-trading-toolkit/build/src/lib/types.d.ts
1. import * as BigNumber from 'bignumber.js';
*2*. -> import { NumberLike } from 'bignumber.js';
*3*. -> export declare const big: BigNumber.BigNumberStatic;
*4*. -> export declare const Big: (x: BigNumber.NumberLike) => BigNumber.BigNumber;
5. export declare const ZERO: BigNumber.BigNumber;
6. export declare const ONE: BigNumber.BigNumber;
*7*. -> export declare type Biglike = *NumberLike*;
8. export declare type BigJS = BigNumber.BigNumber;
const big: BigNumber.BigNumberStatic
and const Big: (x: BigNumber.NumberLike) => BigNumber.BigNumber
never appear to be used anywhere in the code, however Biglike is used in multiple places like LiveOrderBook, Triggers, BookBuilder.
As a temporary fix I have copied the declaration for NumberLike from the old v4.0.1
index.d.ts
file so that line 7 now looks like:
export declare type Biglike = number | string | BigNumber.BigNumber;