microsoft / microsoft/TypeScript
Display default values for property types.
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
🔎 Search Terms
- jsdoc property and default tooltip
- jsdoc declare default values on object properties
- use jsdoc property with default
🕗 Version & Regression Information
Unsure if it's always been this way.
⏯ Playground Link
💻 Code
/**
* @typedef {object} Props
* @property {'sm' | 'md' | 'lg'} [Props.size='md'] Button size.
* @property {string} [Props.label] Button label.
*/
/**
* @returns {Props}
* @default { size: 'md', label: undefined }
*/
function getProps() {
return {}
}
let { size = 'md', label } = getProps()
🙁 Actual behavior
Tooltip when hovering size destructured property:
let size: "sm" | "md" | "lg"
Button size.
🙂 Expected behavior
Tooltip when hovering size destructured property:
let size: "sm" | "md" | "lg"
Button size.
---
@default 'md'
Additional information about the issue
Potentially relates to https://github.com/microsoft/TypeScript/issues/24746
When defining object property types using JSDoc default value notation, such as @property {'sm' | 'md' | 'lg'} [Props.size='md'], I'd like to see tooltip details about the default value. I assume the only way to denote default values with @property is to use [key=value] notation since @default cannot be inlined.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked TypeScript Playground and reproduce the JSDoc @property default-value case, then compare it with the related issue 24746. Trace how the destructured size tooltip is produced and make the completed behavior display the documented default value, such as @default 'md'.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- compilers, developer-experience
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100