Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display default values for property types. #61045

Open
theetrain opened this issue Jan 24, 2025 · 0 comments
Open

Display default values for property types. #61045

theetrain opened this issue Jan 24, 2025 · 0 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@theetrain
Copy link

πŸ”Ž 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

https://www.typescriptlang.org/play/?filetype=js#code/LAKFHoCpNACTYAEAuBPADgUwCaYGawDeA9gEYBWmAxsgL6wAKATsegM5wKLotZNpEA5GwC2g2AB9YgkdnFTBAGwDmg+gG1mrNgDo2ASwBemALwy5AXVgAhAK7JkxAHawDxnZyQ9WmfqiJsyEz6TsoaWuw6igCGpJiKVnYOzrAxcYoeIPDgoBDQnohMmMi2TE5sRBFstAW4eNG2ishErkaYAFzSsoIANKmx8Z22TnUhOLA1WZA5IHjDNPopysVVABQAlERwsDtFJWVEk5OgisUtbpiwJl1yfWnxE1ewy8hr66BAA

πŸ’» 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 #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.

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature labels Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants