最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to write JSDoc if name of property is string, like 'aria-label' - Stack Overflow

programmeradmin1浏览0评论

I want to write JSDoc for some React component:

/**
 * Some Component
 * @param {Object} props - props of the component
 * @param {boolean} [props.active=false] - active
 * @param {string} props.text - text
 * ...
 * @returns {React.ReactElement} Some Component
 */

How can I correctly add property named 'aria-label' in JSDoc?

I can't find the necessary solution in the Net.

I want to write JSDoc for some React component:

/**
 * Some Component
 * @param {Object} props - props of the component
 * @param {boolean} [props.active=false] - active
 * @param {string} props.text - text
 * ...
 * @returns {React.ReactElement} Some Component
 */

How can I correctly add property named 'aria-label' in JSDoc?

I can't find the necessary solution in the Net.

Share Improve this question asked Nov 28, 2024 at 10:09 Lazy_CatLazy_Cat 215 bronze badges 3
  • 1 Object property names with hyphens doesn't seem to be well-supported by JSDoc. Maybe try * @param {string} props.aria-label - an alternative label? – evolutionxbox Commented Nov 28, 2024 at 10:51
  • It does not work. – Lazy_Cat Commented Dec 2, 2024 at 16:21
  • 1 After some investigation it appears that JSDoc doesn't support params with hyphens in their name. – evolutionxbox Commented Dec 2, 2024 at 19:56
Add a comment  | 

1 Answer 1

Reset to default 0
@param {string} props['aria-label'] - your description

or in case it is not a part of props object:

@param {string} ['aria-label'] - your description
发布评论

评论列表(0)

  1. 暂无评论