简体   繁体   English

TypeScript jQuery类型定义

[英]TypeScript jQuery type definition

I am converting a sample app from TypeScript 2.3 to 2.4, and from jQuery 3.1.1 to 3.2.1 (clearly using the latest type definition). 我正在将示例应用程序从TypeScript 2.3转换为2.4,从jQuery 3.1.1转换为3.2.1(显然使用最新的类型定义)。

Here is my tsconfig.json: 这是我的tsconfig.json:

{
    "compilerOptions": {
        "noImplicitAny": false,
        "noEmitOnError": true,
        "removeComments": false,
        "sourceMap": true,
        "target": "es5",
        "lib": [
            "dom",
            "es5",
            "scripthost",
            "es2015.iterable"
        ],
        "strict": true
    },
    "exclude": [
        "node_modules",
        "wwwroot"
    ]
}

(I have added the lib as described in https://github.com/DefinitelyTyped/DefinitelyTyped/issues/17239 ) (我添加了如https://github.com/DefinitelyTyped/DefinitelyTyped/issues/17239中所述的库)

And here is my packages.json: 这是我的packages.json:

{
    "version": "1.0.0",
    "name": "asp.net",
    "private": true,
    "dependencies": {
        "jquery": "3.2.1"
    },
    "devDependencies": {
        "@types/jquery": "*"
    }
}

Now: I expect that in a TypeScript file, if I use $, I should get Intellisense and so on. 现在:我希望在TypeScript文件中,如果使用$,则应该获得Intellisense等等。 But instead I get a compile error. 但是我得到了一个编译错误。

Please note: - I'm using VS2017 15.2 with the latest TypeScript 2.4.1.0 plugin - I don't want to use ES6 yet 请注意:-我正在将VS2017 15.2与最新的TypeScript 2.4.1.0插件一起使用-我现在还不想使用ES6

What should I change? 我应该改变什么?

The problem is in the new Visual Studio plugin (version 2.4.1.0). 问题出在新的Visual Studio插件(版本2.4.1.0)中。 The solution compiles ok from command line. 该解决方案可以从命令行编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM