1

当尝试将 javascript 组件 npm 安装到打字稿项目中时,我收到打字稿错误,因为缺少d.ts文件或@types组件:

TypeScript error in /Users/oded/code/base-components/src/App.tsx(3,33):
Could not find a declaration file for module '@bit/bit.web.components.comment-carousel'. '/Users/oded/code/base-components/node_modules/@bit/bit.web.components.comment-carousel/dist/src/components/comment-carousel/index.js' implicitly has an 'any' type.
  Try `npm install @types/bit.web.components.comment-carousel` if it exists or add a new declaration (.d.ts) file containing `declare module '@bit/bit.web.components.comment-carousel';

我是@bit/bit.web.components.comment-carousel另一个项目中组件的作者。

我可以想到两种方法来解决这个问题:

  1. 我可以bit eject从最初编写它的作者项目(以及当前使用它的位置)中获取它,并将 a 添加d.ts到组件中。

  2. 我可以bit import在我的消费项目中修改组件并对其进行修改,但感觉有点矫枉过正。

有没有更好的方法来实现这一目标?

4

0 回答 0