4

I have been playing around with Visual Studio Code today, and have been having a problem getting intellisense to work with some of the code in a JavaScript project. I had read this post http://www.johnpapa.net/intellisense-witha-visual-studio-code/ which talks about this issue, demonstrating how you can use intellisense with angular. I've been looking at some sample projects using a JavaScript library, PlaygroundJS, and it would be very useful to use intellisense within these projects, as they are usually broken into multiple files, and it would be nice to be able to look at the definitions, rather than tracking them down manually. However, when I looked at the options available under the quick actions, I do not see anything like, which was in the example I found:

Add /// reference to angularjs/angular.d.ts

just the option to mark the variable as global. So I was wondering, is it possible to add intellisense to this library, and the other files in a project?

I did find that it was possible to add references to them at the top of each file:

/// <reference path="Global.js" />
/// <reference path="engine/Score.js"/>
/// <reference path="engine/Camera.js"/>
/// <reference path="engine/Engine.js"/>
/// <reference path="engine/EnemyManager.js"/>
/// <reference path="engine/EntityManager.js"/>

but this manual process is time consuming and unwieldy. Is there no way for it to find these references automatically?

The options available when looking at the library

2 Answers 2

2

Yes, for now you can create a tsd.d.ts file for all of your d.ts file references. Put that in your project once, then each file can refer to that.

Or use a tsconfig.json with no files (leave it undefined).

This story will get better

Sign up to request clarification or add additional context in comments.

1 Comment

What exactly will the tsconfig without files do?
1

If it doesn't recognize the Angular module and suggest the d.ts import automatically, you can add the angularjs typings to your project manually.

http://definitelytyped.org describes how to import the typings into your project. I'd recommend TypeScript Definition manager as it keeps the reference comments in you code files succinct.

1 Comment

I am not trying to use angular though, that was just an example that I saw. I am using PlaygroundJS and was wondering if it was possible to get intellisense for that. I ill take a look at that website though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.