使用'bool'而不是'Boolean'的JQuery Typescript定义

[英]JQuery Typescript definitions using 'bool' instead of 'Boolean'


I got the "Definitely Typed" typescript definition file for JQuery and it uses bool instead of 'Boolean'.

我得到了JQuery的“Definitely Typed”打字稿定义文件,它使用bool而不是'Boolean'。

This is giving me errors in my typescript project: Cannot find name 'bool'

这在我的打字稿项目中给了我错误:找不到名字'bool'

I changed my version to use Boolean and it works, but it has me confused.

我将我的版本更改为使用布尔值,但它确实有效,但令我感到困惑。

Is Definitely Typed still the place to get typescript definitions? If so, why is it not breaking for everyone else?

绝对键入仍然是获取打字稿定义的地方吗?如果是这样,为什么不打破其他人呢?

Is there a better place to get typescript definitions?

有没有更好的地方获得打字稿定义?

3 个解决方案

#1


15  

The correct name to use is boolean, not Boolean.

要使用的正确名称是boolean,而不是Boolean。

Definitely Typed is still the correct place to get definitions from.

绝对Typed仍然是从中获取定义的正确位置。

Where did you get this file? The current version (https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/jquery/jquery.d.ts) does not use bool anywhere.

你从哪里得到这个文件?当前版本(https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/jquery/jquery.d.ts)不会在任何地方使用bool。

#2


10  

This happened to me as well when I first setup Typescript for an AngularJS project.

当我第一次为AngularJS项目设置Typescript时,这也发生在我身上。

  1. Go to Manage NuGet Packages for Solution
  2. 转到管理解决方案的NuGet包
  3. View the Updates section, you should see jquery.TypeScript.DefinitelyTyped in the list.
  4. 查看Updates部分,您应该在列表中看到jquery.TypeScript.DefinitelyTyped。
  5. Update the package and the compilation errors will go away.
  6. 更新包,编译错误将消失。

Hope this helps.

希望这可以帮助。

#3


0  

I got the same problem - a jquery.d.ts file with bool everywhere rather than boolean.

我遇到了同样的问题 - 一个jquery.d.ts文件,其中包含bool,而不是boolean。

In my case, the jquery.d.ts file came from a Pluralsight course.

在我的例子中,jquery.d.ts文件来自Pluralsight课程。

The fix for me was to stop using that version, and instead install the nuget package. From the VS Package Manager Console:

我的修复是停止使用该版本,而是安装nuget包。从VS程序包管理器控制台:

install-package jquery.TypeScript.DefinitelyTyped

At time of writing, that's version 3.1.2 which correctly uses boolean, not bool.

在撰写本文时,版本3.1.2正确使用布尔值,而不是bool。

(Also, regarding the Pluralsight course, I didn't use their supplied knockout files, but instead, installed knockout.TypeScript.DefinitelyTyped.)

(另外,关于Pluralsight课程,我没有使用他们提供的淘汰文件,而是安装了knockout.TypeScript.DefinitelyTyped。)

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2015/12/03/72045896e58a198f123fac9c169b43e2.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告