简体   繁体   English

Reactjs 打字稿使用 JavaScript 包

[英]Reactjs typescript use JavaScript package

I have a ReactJs typescript application.我有一个 ReactJs 打字稿应用程序。 I am new to React development and don't know the configurations yet.我是 React 开发的新手,还不知道配置。 I would like to include a JavaScript package.我想包含一个 JavaScript 包。 There is no @Type variant for this yet or only an old one that doesn't help me.目前还没有 @Type 变体,或者只有一个对我没有帮助的旧变体。 I have read that you can write d.ts or customize the configuration to allow JavaScript.我读到您可以编写 d.ts 或自定义配置以允许 JavaScript。 But it is nowhere explained in detail for beginners and my search results were not helpful so far.但它没有为初学者详细解释,到目前为止我的搜索结果没有帮助。 Is there a more detailed explanation/guide somewhere?某处有更详细的解释/指南吗?

As written, the explanations are not sufficient.正如所写,解释是不够的。 I have found my solution based on this answer: Using JS and TS in a react project我根据这个答案找到了我的解决方案: 在反应项目中使用 JS 和 TS

  1. create a js file which using the js component from package创建一个使用包中的 js 组件的 js 文件
  2. and then create the d.ts file works for me.然后创建适合我的 d.ts 文件。

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

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