Skip to content

Support adding JSDoc comments for union constituents #54510

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

Closed
5 tasks done
cseas opened this issue Jun 3, 2023 · 1 comment
Closed
5 tasks done

Support adding JSDoc comments for union constituents #54510

cseas opened this issue Jun 3, 2023 · 1 comment

Comments

@cseas
Copy link

cseas commented Jun 3, 2023

Suggestion

πŸ” Search Terms

  • typescript jsdoc for union constituents
  • jsdoc comments for typescript variable values autocomplete in vscode intellisense
  • chakra ui mui vscode intellisense for token values

βœ… Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Support adding JSDoc comments for individual union constituents.

πŸ“ƒ Motivating Example

JSDoc comments for union members would appear in IDE IntelliSense (refer below example).

πŸ’» Use Cases

Consider the following type for spacing tokens in a UI library.

type Spacing =
  /** 4px */
  | 'spacing.1'
  /** 8px */
  | 'spacing.2';

We want the equivalent px values of these tokens to be visible in the IDE wherever this type is used in our components for spacing based props. This way our users wouldn't need to refer the library documentation for what the final value of a token is.

Screenshot 2023-06-02 at 8 37 56 AM

Currently this is only possible by building an extension for the IDE, something similar to Tailwind CSS IntelliSense.

Screenshot 2023-06-02 at 11 36 39 AM

We're discussing workarounds here: razorpay/blade#1249

Similar use-case has also been asked on StackOverflow:
https://stackoverflow.com/questions/63067208/writing-more-descriptive-intellisense-docs-for-typescript-union-types

@cseas
Copy link
Author

cseas commented Jun 3, 2023

Update:

I found this comment in a TSDoc issue that explains the use-case well:
microsoft/tsdoc#164 (comment)

I see the author has already opened an issue for this but it didn't appear in any of my Google searches (check in Issue description)

Closing as #38106 captures the requirement well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant