0

Given an object definition that I'm not allowed to modify:

let a = {"a-b" : 5};

How can I add JSDoc over it ?

I tried

/**
* @type {{"a-b": number}}
*/

But WebStorm tells me that this is not valid JSDoc.

manuc66
  • 2,701
  • 29
  • 28

2 Answers2

1

At the moment it's a topic which hasn't been resolved yet and still is in-progress.

I'd suggest to use class comments:

/**
 * @typedef {Object}
 * @property {number} a-b
 */
Ehsan
  • 1,245
  • 11
  • 20
1

It's a valid way to document namepaths with special chanracters - see http://usejsdoc.org/about-namepaths.html, Namepaths of objects with special characters in the name. But WebStorm doesn't yet support it - see WEB-18032

lena
  • 90,154
  • 11
  • 145
  • 150