This is similar to question 38702398, but I have an additional requirement.
I want PhpStorm to stop pestering me with the "Possible iteration over custom/inherited properties" diagnostic.
In order to achieve this, I want to find a way to use JSDoc to inform PhpStorm that the object being iterated is a "plain" object and doesn't have any custom or inherited properties. I am not as much interested in documenting the value type of this dictionary object as I am in successfully declaring to PhpStorm's built-in linter that the object is indeed a plain dictionary.
Consider this example:
class DictionaryEntry {
// ...
}
/**
* @typedef {Object.<string, DictionaryEntry>} Dictionary
*/
/**
* @param {Dictionary} dictionary
*/
function use_dictionary(dictionary)
{
for (let key in dictionary) {
const entry = dictionary[key]; // <- get rid of diagnostic here!
// do something with entry ...
}
}
Is this something that ShouldWork™, i.e. a bug in PhpStorm?