简体   繁体   中英

chargebee js react wrapper is not working in typescript

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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM