简体   繁体   English

打字稿:如何使用bowser打字?

[英]Typescript: How to use bowser typings?

I'm updating an AngularJS project to Typescript using Webpack. 我正在使用Webpack将AngularJS项目更新为Typescript。

Because we are using bowser in our codebase I installed and referenced the related typings. 因为我们在代码库中使用bowser ,所以我安装并引用了相关的类型。

But still after done this the compiler keeps complaining that the bowser name is unknown. 但是在完成此操作之后,编译器仍然抱怨说bowser名称是未知的。

Does someone know how to effectively use the bowser typings? 有人知道如何有效地使用bowser typings吗? It worked out of the box for the other libraries. 它开箱即用于其他图书馆。

In a separate *.d.ts file (I have one for miscellaneous shims since so many typings are terrible), you need to add this line: 在一个单独的* .d.ts文件中(我有一个用于杂项填充程序,因为很多类型很糟糕),你需要添加这一行:

declare var bowser: BowserModule.IBowser;

For some reason the typing currently doesn't include the actual instantiated object. 由于某种原因,键入当前不包括实际的实例化对象。

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

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