jsdoc icon indicating copy to clipboard operation
jsdoc copied to clipboard

How to document properties with colon?

Open markcellus opened this issue 2 years ago • 2 comments

I recently have to work with RSS/XML objects that have colons in the property name e.g. dc:creator. How is this expressed in JSDocs? Whenever I try adding dc:creator to typed object, it's not recognized.

Input code

/**
 * @typedef {object} XMLChannel
 * @property {string} [dc:creator]
 */

Expected behavior

Output and support by JSDoc integrated tools like VSCode

Current behavior

Outputs nothing + causes error in JSDoc supported tools like VSCode

markcellus avatar Nov 04 '23 17:11 markcellus

/**
 * @typedef {{
 *  'dc:creator': string
 * }} XMLChannel
 */

begin-again avatar Nov 21 '23 21:11 begin-again

Yeah but I'd have to make a seperate typedef just for this property or change all of my other types to use this inline {{}} syntax just for this property.

I was hoping that there was a way to declare the property without changing the type syntax everywhere. If anyone knows of a way, please do send it my way! Thanks!

markcellus avatar Nov 21 '23 21:11 markcellus