Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript Intellisense in TypeScript File

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?

like image 632
daniel Avatar asked Oct 07 '12 15:10

daniel


People also ask

Does TypeScript have IntelliSense?

IntelliSense shows you intelligent code completion, hover information, and signature help so that you can write code more quickly and correctly. VS Code provides IntelliSense for individual TypeScript files as well as TypeScript tsconfig.

How can I get JavaScript IntelliSense code in Visual Studio?

You can access the IntelliSense page by choosing Tools > Options on the menu bar, and then expanding Text Editor > JavaScript/TypeScript > IntelliSense. Your computer might show different names or locations for some of the Visual Studio user interface elements in this article.

Why is my IntelliSense not working?

If you find IntelliSense has stopped working, the language service may not be running. Try restarting VS Code and this should solve the issue. If you are still missing IntelliSense features after installing a language extension, open an issue in the repository of the language extension.

Is VS Code written in TypeScript?

Visual Studio Code is a cross platform code editor written in TypeScript based on Code OSS with support for extensions and a wide range of programming languages.


1 Answers

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.

like image 190
jkarpilo Avatar answered Sep 29 '22 05:09

jkarpilo