TypeScript的jQuery的最新版本是抛出语法错误? [英] Latest version of jQuery for TypeScript is throwing syntax errors?

查看:475
本文介绍了TypeScript的jQuery的最新版本是抛出语法错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我更新的时候,我更新了一个旧的代码库。 jQuery到最新版本当我尝试使用grunt来构建我的项目时,出现以下错误。


/jquery/jquery.d.ts(279,40):
错误TS1005:','预期。



/jquery/jquery.d.ts(279,61):
错误TS1005:'='预期。



/jquery/jquery.d.ts(279,64):
错误TS1003:标识符预期。



/jquery/jquery.d.ts( 279,97):
错误TS1005:','预计。

/jquery/jquery.d.ts(279,118):
错误TS1005 :'='预期。


我已经缩短了路径并且没有给出每一行,但是有很多。 / p>

我正在使用grun来构建它t-ts,它似乎是使用 tsc v1.0.1 - 我不确定这将设置在哪里,我只是在输出时试图构建。 p>

解决方案

新版本的jquery.d.ts文件使用TypeScript 1.4新增的语法。请升级您的编译器或将其降级到早期版本的.d.ts文件[0]。 DefinitelyTyped上有一个1.3分支,专门用于兼容1.4之前的兼容.d.ts文件。



[0] https://github.com/borisyankov/DefinitelyTyped/blob/1.3.0/jquery/jquery.d.ts

I am almost 100% sure I am doing something wrong to cause this as I am incredibly new to TypeScript and have been updating an old codebase.

When I update jQuery to the latest version I get the following errors when I try and build my project using grunt.

/jquery/jquery.d.ts(279,40): error TS1005: ',' expected.

/jquery/jquery.d.ts(279,61): error TS1005: '=' expected.

/jquery/jquery.d.ts(279,64): error TS1003: Identifier expected.

/jquery/jquery.d.ts(279,97): error TS1005: ',' expected.

/jquery/jquery.d.ts(279,118): error TS1005: '=' expected.

I have shortened the paths and not given every single line, but there are a lot of them.

I am building this using grunt-ts and it seems to be using tsc v1.0.1 – I am unsure where this would be set I am just going by the output when it attempts to build.

解决方案

The new version of the jquery.d.ts file uses syntax that is new to TypeScript 1.4. Either upgrade your compiler or downgrade to an earlier version of the .d.ts file[0]. There's a "1.3" branch on DefinitelyTyped specifically for pre-1.4-compatible .d.ts files.

[0] https://github.com/borisyankov/DefinitelyTyped/blob/1.3.0/jquery/jquery.d.ts

这篇关于TypeScript的jQuery的最新版本是抛出语法错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆