0

I have installed chargebee react wrapper and when i create any tsx file and try to include

import { CardComponent, CardNumber, CardExpiry, CardCVV, Provider } from "@chargebee/chargebee-js-react-wrapper";

i am getting the error that

  Could not find a declaration file for module 
'@chargebee/chargebee-js-react-wrapper'. '/Users/sites/project/node_modules/@chargebee/chargebee-js-react-wrapper/dist/chargebee-js-react-wrapper.common.js' implicitly has an 'any' type.
      Try `npm i --save-dev @types/chargebee__chargebee-js-react-wrapper` if it exists or add a new declaration (.d.ts) file containing `declare module '@chargebee/chargebee-js-react-wrapper';`ts(7016)

I am not able to find any types file for chargebee react wrapper.

Bilal Rabbi
  • 1,602
  • 2
  • 18
  • 39
  • What version of the library are you using? TypeScript support was added [just last week](https://github.com/chargebee/chargebee-js-wrappers/pull/110) so you may need to update. – Zac Anger Dec 18 '22 at 20:53
  • I have installed latest version of chargebee react wrapper – Bilal Rabbi Dec 18 '22 at 21:06
  • 1
    Oh, I see the problem... they rewrote the library in TypeScript but [aren't bundling the types](https://github.com/chargebee/chargebee-js-wrappers/pull/110/files#diff-a705d25a41d9cff862f7ea64c2111b8069636ef03119ee23cdb95fb26cee3aa3R6). I suggest [opening an issue](https://github.com/chargebee/chargebee-js-wrappers/issues/new/choose) so they can fix that. – Zac Anger Dec 18 '22 at 22:01

2 Answers2

0

The declaration file is where the types and declarations for library are defined you need to yarn its declaration type. Try something like this

npm install --save @types/chargebee

you can find exact yarn command from google

Wasif Ali
  • 204
  • 1
  • 10
  • tried yarn add @types/chargebee but it is not working. i have installed latest version of chargebee react wrapper – Bilal Rabbi Dec 18 '22 at 21:06
0

I am not aware of any typed packages for chargebee. Try creating a file @chargebee/chargebee-js-react-wrapper.d.ts in the root of your project and add declare module "@chargebee/chargebee-js-react-wrapper"; to the file. Restart and you should be able to use chargebee, although you won't get any type recommendations.

You can choose to add declarations to the file to make further development smoother or you can just add their api help page, that has all details about the components, as a comment.