Use "typings" TypeScript definitions

I've just begun with Typescript in IntelliJ (current EAP). Current Node, TSC, and Typings are installed globally. I have this tsconfig.json:

  "compilerOptions": {
    "module": "commonjs",
    "sourceMap": true,
    "target": "es5",
    "experimentalDecorators": true
  "files": [

in the web project's root. ts files in the root or a lower directory show evidence that the IDE has some knowledge about jQuery types. For example, this snippet:

let el = $('li');

provokes the IDE to provide hover help while the mouse is within the () telling me a jQuery selector is expected. But the $ identifier is red. Similarly, spelling out jQuery is also red. In both cases the IDE claims the file's broken with errors.

Now, if I add this bit to the top of the ts file:

/// <reference path="../../typings/index.d.ts" />

I get a better experience. IDE info is this:

IntelliJ IDEA 2016.2 EAP
Build #IU-162.844.8, built on June 7, 2016
IntelliJ IDEA EAP User
Expiration date: July 7, 2016
JRE: 1.8.0_76-release-b216 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Thanks for your suggestions.

Comment actions Permalink

What does your index.d.ts looks like? Also, do you have TypeScript compiler enabled for your project (Preferences | Languages & Frameworks | TypeScript, Enable TypeScript Compiler)? Sample project that shows up your issue would be helpful

Comment actions Permalink

Yes, the internal TS compiler is enabled. Node is 6.2, if that matters.

typings/index.d.ts contains one line:

/// <reference path="globals/jquery/index.d.ts" />

I will see about making a sample project -- I admit, time is short. But when isn't it? ;-)  The jquery type definition was installed at the CLI with:

typings install dt~jquery --save --global
Comment actions Permalink


typings install dt~jquery --save --global

results in 404 errors to me:

typings ERR! message Unable to find "dt~jquery" for "npm" in the registry. Did you want to install ambient typings with the ambient flag? If you can contribu
te these typings, please help us:
typings ERR! caused by responded with 404, expected it to equal 200


So I created globals/jquery/index.d.ts manually and pasted jquery Definitely Typed typescript definition in it.

Now '$' in test.ts placed in project root folder is correctly resolved to me.

File can't be compiled, as it's not included in tsconfig.json, but WebStorm still can correctly resolve JQuery, with or without TypeScript compiler



So it seems that I need your project to see what is wrong


Please sign in to leave a comment.