JavaScript Intellisense in TypeScript File

intellisense, javascript, typescript

Solution

You are able to get IntelliSense for other TypeScript files by using an external script reference directive at the top of your script:

///<reference path="someOtherScript.ts" />

As a side note, the TypeScript IntelliSense reference directive doesn't support the tilde operator like the JavaScript reference directive does. For example, if your script is located in "~/Scripts/foo/", in JavaScript you can reference:

///<reference path="~/Scripts/otherScriptFile.js" />

whereas in TypeScript you have to reference relative to the current file:

///<reference path="../otherScriptFile.ts" />

More info about this can be found in section 11.1.1 Source Files Dependencies of the TypeScript Spec.

With regard to JavaScript IntelliSense in a TypeScript file, it currently appears to be not possible to get JavaScript reference IntelliSense.

Problem

Is it only possible to get intellisense in TypeScript files by referencing `.ts` files with own coded interfaces? Is there a solution for existing JavaScript libraries?

Original source