hildjj / node-cbor

Encode and decode CBOR documents, with both easy mode, streaming mode, and SAX-style evented mode.
MIT License
357 stars 73 forks source link

Cannot find module 'bignumber.js' or its corresponding type declarations. #140

Closed everhardt closed 3 years ago

everhardt commented 3 years ago

I get the following errors when compiling my TypeScript code that includes the cbor package:

node_modules/cbor/types/lib/cbor.d.ts:1:37 - error TS2307: Cannot find module 'bignumber.js' or its corresponding type declarations.

1 export var BigNumber: typeof import("bignumber.js").default;
                                      ~~~~~~~~~~~~~~

node_modules/cbor/types/lib/constants.d.ts:78:27 - error TS2307: Cannot find module 'bignumber.js' or its corresponding type declarations.

78 import { BigNumber } from "bignumber.js";
                             ~~~~~~~~~~~~~~

Could the problem be that bignumber.js is now not installed by default, while is still referred to in the two TypeScript declaration files above? If I add bignumer.js to my package, all is well again..

hildjj commented 3 years ago

Yes, that's probably it. Making bignumber.js optional has been pretty complicated. If your protocol isn't using big decimals or big floats, I can understand why you wouldn't want to take a bignumber.js dependency. I think you should be able to use it as a devDependency for now, but I'll see if I can figure out some way around this.

Since I'm not a TypeScript person, I'm open to suggestions. The only thing that comes to mind at the moment is to completely remove bignumber.js, turn the cbor integration for it into another parallel package, and rev the major version number -- but that's a pretty big change.

everhardt commented 3 years ago

The only thing that comes to mind at the moment is to completely remove bignumber.js, turn the cbor integration for it into another parallel package, and rev the major version number -- but that's a pretty big change.

Yeah, that or just providing example code on how to add them yourself as a new Encoder and Decoder. But in any case it would be breaking.

hildjj commented 3 years ago

Please retest with v8.0.0 and reopen if this isn't fixed.

everhardt commented 3 years ago

Works like a charm!