带有@types/swiper 的 Angular

标签 angular typescript types swiper.js

我在 Angular 6 项目中使用 @types/swiper 时出现错误(无法将“new”与类型缺少调用或构造签名的表达式一起使用)创建一个新的 Swiper 实例。

StackBlitz

最佳答案

@types/swiper 中的swiper 模块的声明是错误的:声明说该模块有一个名为 export SwiperSwiper 类,但它实际上具有该类的默认导出(或导出分配,具体取决于您的 bundler 是使用 CommonJS 还是 ES6 版本:啊,愚蠢的包装)。我已经提交了 a pull request to DefinitelyTyped尝试修复声明。如果您使用我修改过的声明(请参阅 this answer 了解可能的方法),您的代码应该会成功编译。

关于带有@types/swiper 的 Angular ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52673117/

相关文章:

angular - 无法将脚本文件添加到组件html

vb.net - 有条件地检查 GetType() 容器中的值类型

python - OpenCV Python 特征检测 : how to provide a mask? (SIFT)

Angular - CodeAnywhere - 您似乎不依赖于 "@angular/core"。这是一个错误

angular - .filter 不是 Angular2 的函数

angular - 在生产模式Electron + Angular中找不到sqlite文件

TypeScript:定义可以是 bool 或 null 的类型

angular - 自定义 ngbAccordion

typescript - 推断函数返回类型,了解一个属性的值

javascript - Node typescript 项目中的 Jest 覆盖总是返回空