jquery - Typescript 编译器错误。当前作用域中不存在名称 'boolean'
我正在尝试搭建一个使用 Typescript 的环境。
我已经使用 npm 在我的 OS X 上安装了 TypeScript,并从 https://github.com/borisyankov/DefinitelyTyped 下载了最新的 jquery/jquery.d.ts
在命令行中运行 tsc(使用集成提供的结果相同)最终出现了以下错误:
The name 'boolean' does not exist in the current scope
问题也出现了(类似,但未找到的类型是“_element”)与 lib.d.ts 类型注释文件。
我正在使用 TypeScript 编译器版本 0.9.0.0。
后续编辑:
我肯定迷路了,尝试从那里获取 jquery.d.ts
http://typescript.codeplex.com/SourceControl/changeset/view/fe3bc0bfce1f#bin/jquery.d.ts
现在我在编译它时又遇到了一个不同的问题:
jquery.d.ts(37,18): error TS1023: Index signature parameter type must be 'string' or 'number'
我的 ts 文件和我使用的编译器之间是否存在版本不匹配,如果有,我该如何解决?谢谢。
答案#1
你应该尝试这个版本:https://github.com/borisyankov/DefinitelyTyped/blob/master/jquery/jquery.d.ts
也可以尝试卸载/安装 TypeScript。
npm uninstall typescript
npm uninstall -g typescript
npm install typescript
在做那个之前,我也很好奇 tsc -version 显示的是什么。在执行上述步骤后,它有变化吗?
