I'm trying to get intellisense in visual studio code. The following code works fine:
var Bar = function(){
}
Bar.prototype.logMsg = function(msg){
console.log(msg);
}
But I don't recive any intellisense when writing:
var FOO = {};
FOO.Bar = function(){
}
FOO.Bar.prototype.logMsg = function(msg){
console.log(msg);
}
This might be due to restrictions I'm not aware of, but I can't find any documentation/posts mentioning this. Is there a way to get it working without rewriting big parts?
I work on TypeScript and JavaScript support in VSCode. As of VSCode 1.8.1, this type of dynamic property assignment is not something that our IntelliSense recognizes.
We use TypeScript to power both our TypeScript and JavaScript IntelliSense, and while TypeScript is able to recognize the common prototype
pattern shown in your first example, it does not recognize properties added to an object, as in your second example. This means that FOO.Bar
will always have an any
type.
We're tracking support for this type of IntelliSense in the TypeScript project: https://github.com/Microsoft/TypeScript/issues/13271