简体   繁体   English

chargebee js 反应包装器在 typescript 中不起作用

[英]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我已经安装了 chargebee react wrapper,当我创建任何 tsx 文件并尝试包含

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.我找不到 chargebee 反应包装器的任何类型文件。

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.我不知道有任何类型的 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";尝试在项目的根目录中创建一个文件@chargebee/chargebee-js-react-wrapper.d.ts并添加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.重新启动,您应该可以使用 chargebee,尽管您不会得到任何类型建议。

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.您可以选择向文件添加声明以使进一步的开发更顺利,或者您可以只添加他们的 api 帮助页面,其中包含有关组件的所有详细信息,作为评论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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