当尝试将 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
另一个项目中组件的作者。
我可以想到两种方法来解决这个问题:
我可以
bit eject
从最初编写它的作者项目(以及当前使用它的位置)中获取它,并将 a 添加d.ts
到组件中。我可以
bit import
在我的消费项目中修改组件并对其进行修改,但感觉有点矫枉过正。
有没有更好的方法来实现这一目标?