chargebee js react wrapper is not working in typescript

413 views Asked by At

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.

2

There are 2 answers

1
Wasif Ali On

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

1
Deblina Pattanayak On

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.