shadeglare
shadeglare

Reputation: 7536

JSDoc: property name

Is there a way to make a correct description for a property with special symbols like "+" in jsdoc?

Example:

/**
  * @typedef {Object} TestObject
  * @property {string} "id+name"
  */

"id+name" seems to be an invalid syntax in this case.

Upvotes: 5

Views: 1241

Answers (1)

DrakaSAN
DrakaSAN

Reputation: 7853

Looks like you can use a TypeScript like syntax that have better support for that case

https://github.com/BeyondCodeBootcamp/js-with-types-jsdoc-tsc-starter/issues/3

/**
 * @typedef {{
 *   "Emp#": string,
 *   "First Name": string,
 * }} EmpCsv
 */

While a pure typescript solution would be:

interface EmployeeCsv {
  "Emp#": string,
  "First Name": string,
}

Upvotes: 2

Related Questions