Latest version of jQuery for TypeScript is throwin

2020-04-06 02:38发布

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.

1条回答
唯我独甜
2楼-- · 2020-04-06 03:39

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

查看更多
登录 后发表回答