How to use generic types in JSDoc to represent an instance of a (class) type
I am fairly sure this is not possible, but figured someone out there may know more.
Set the key type in the object based on the contents of the array
const keys = [‘x’, ‘y’, ‘z’]; /** @typedef ??????? KeyType`*/ //is important that the type is based on the values from the keys /** @type {{[key: KeyType]?: number}} */ const obj = {}; for(const k of keys){ obj[k] = Math.random(); // good } obj[‘foo’] = 3; // IDE should show warning, but it doesn’t care […]
In JsDoc, how do I make the @return type of my function the type of a local variable set in child class?
Using this question as a reference:
jsDoc : How do I make the @return type of my method the type of a local variable from it?
Can I define a jsdoc typedef (an object) by “spreading” existing typedefs?
Can I use the spread operator to create typedefs by combining existing typedefs?