I am super confused about how Intellisense works - sometimes it's "automagic" and sometimes I can never get it to work.
Here's an example where I just can't get it to work:
// item.js
export default class Item {
/**
* Creates an Item
* @param {string} type The item type
*/
constructor(type) {
this.type = type;
}
/**
* Logs the type of this item
*/
outputType() {
console.log(this.type);
}
}
// itemlist.js
import Item from './item';
export default class ItemList {
/**
* Makes an item list
* @type {string[]} items The types of the items to generate
*/
constructor(items) {
/**
* @type {Item[]}
*/
this.items = items.map(i => new Item(i));
}
}
In the above example, in itemlist.js
, Intellisense does not know that this.items
should be treated as a list of Item
objects, and therefore does not autosuggest class properties or methods when I type something like:
this.items[0].
Not even this works in itemlist.js
:
const item = new Item('simple');
item.
^ in the above examples there are no Intellisense suggestions for "outputType" or anything related to the item.