使用'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。)

关注微信公众号

注意!

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



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