How to get IntelliSense in VS Code for own js-files?

Hi…,

I try to write a little game Engine for my needs with JavaScript in Cocos Creator. The code is split in a lot of js-files, like this

var ENGINE = require("Engine");

ENGINE.Vector2 = function (x, y) {
	this.x = x || 0;
	this.y = y || 0;
};
ENGINE.Vector2.prototype = {
	constructor: ENGINE.Vector2,
	set: function ( x, y ) {
		this.x = x;
		this.y = y;
		return this;
	},
...
};

Now I would like to use IntelliSense in VS Code. Does anybody have experience with it, and how to switch IntelliSense on?

Thanks

Mike

This way works for me

And in a secondary class I can read these comments:

Hi @Alekhine,

you have what I want. :wink: Have you set something in Visual Studio Code? I don’t get these suggestions at all.

Thanks

Mike

Hi @Alekhine and Creator/JS-friends,

I have played hours without success. Please can someone take a look at my helloWorld example: helloWorld_noIntelliSense.zip (209.7 KB)

I have placed a JSDoc-comment to my function subVectors.

But no IntelliSense shows up in Visual Code:

The needed jsconfig file is also in the main directory:

Any ideas?

Thank you very much

Mike

I think your solution works in Module only (where use module.exports). I have tried in other places without success.

@MikeFromMars use Atom.io and install tern js and docblockr plugins…

Is Atom.io better than VSCode?

Hi @eydamson,

thank you for tip. I’ve tried also WebStorm, because in generall I like it, but was not so happy with Cocos Creator.

Cheers

Michael

@jrosich as a javascript editor i would say yes… (with the right plugins)
they both have their advantages, but if you use vs code you will get intellisense for cocos creator api. but not with your own scripts but if your gonna use Atom.io with tern js, you will have intellisense for your own scripts but not with cocos creator api…

just a matter of preference :slight_smile:
in my case i choose Atom.io i prefer intellisense for my script as i could always see the docs for cocos api and also it helps me to memorize cocos :smiley:

I’m running the ESLint extension, it seems like the main problem is that it can’t find anything in the cc namespace at all, so then it sees a giant block of code for a cc.Class, for instance, and completely gives up.

Might have to be fixed by the Cocos VSCode extension developers. I’m not sure how you expose external JS bindings to Intellisense (maybe via the creator.d.ts file?)…

EDIT: It looks like there might be some way to do this since there are configurations already for things like Meteor which also have their own set of “built-in” exports (assuming I can get ESL to parse TypeScript, looks like the parser is hot-swappable though), I’m going to play around with this some more.

Have you solved this problem?