PinataCloud / Pinata-SDK

Official SDK for the Pinata IPFS service
MIT License
273 stars 67 forks source link

Cannot construct `PinataClient` in TypeScript #167

Closed rrthomas closed 5 months ago

rrthomas commented 7 months ago

With latest Pinata-SDK and TypeScript 5.3.3 I get:

import PinataClient from '@pinata/sdk';

const foo = new PinataClient();

Error:

error TS2351: This expression is not constructable.
  Type 'typeof import("…/node_modules/@pinata/sdk/types/index")' has no construct signatures.

3  const foo = new PinataClient();

I can't see why this should fail (since the default export is the PinataClient class), but it does. In any case, a simple fix/workaround is to export the class in its own right, so it can be imported as:

import {PinataClient} from '@pinata/sdk';

Would you consider doing this? (Just need to add export to the class declaration.)

rrthomas commented 7 months ago

For anyone else with this problem, I have published a bug-fix fork as @sc3d/pinata-sdk on npmjs.com.

Khonsort-Metadev3 commented 6 months ago

For anyone else with this problem, I have published a bug-fix fork as @sc3d/pinata-sdk on npmjs.com.

Thanks, You've saved my day :-)

stevedylandev commented 5 months ago

Sorry for the delay here! We are currently rewriting the SDK so hopefully this will not be an issue going forward