RFC: Specify that doc comments are allowed on simple union types
See original GitHub issueHello,
I can’t find any documentation on adding tsdocs to a typescript string literal type. I was wondering if the following is possible:
type InputType =
/** the TSDoc doesn't work for num1, but I'd like it to */
| 'num1'
/** the TSDoc doesn't work for num2, but I'd also like it to */
| 'num2'
export const test = (...input: InputType[]) => {
return input
}
// I'd like to get the TSDoc from 'num1' string literal to show up
// when inputting it into the `tac` function but it does not currently show
test('num1')
I’m not 100% tied to using string literal types, so if there is another way to do this with enums
, etc., I’d love to learn 😄
If the above is not currently possible, I’d love to work to add it to tsdoc (with some guidance 😄).
Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:71
- Comments:11 (2 by maintainers)
Top Results From Across the Web
PHP RFC: Union Types 2.0
Supporting union types in the language allows us to move more type information from phpdoc into function signatures, with the usual advantages ...
Read more >Request for Comments Summary RFC Numbers 3400-3499
This is a status report on these RFCs. This memo provides information for the Internet community. It does not specify an Internet standard...
Read more >RFC 6020: YANG - A Data Modeling Language for the ...
1. Modules and Submodules A module contains three types of statements: module-header statements, revision statements, and definition statements. · 2. Data ...
Read more >Final draft ETSI ES 201 873-10 V4.2.2 (2011-04)
Part 10: TTCN-3 Documentation Comment Specification ... In the case of record, set and union types, module parameters, constants and templates the ...
Read more >PHP 8.0: Union Types
Union types does not allow redundant class types. However, it is important to note that this only applies to a few special special...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Gerrit0 my thinking to restrict this feature to a very special pattern that is commonly used like an enum. We could give it a name like “union enum”.
For example, these would be union enums:
But it’s optional. For example, maybe a documentation tool only treats a type as an “union enum” if at least one of the members has a
/** */
comment.And it would NOT apply to any other generalized expressions, not even this sort of thing:
For the most part, such a feature would be a feature request for your particular documentation tool. If TSDoc “supports” this feature, its role is merely to:
Hi there, I have the same thing. I am using String Literal types to define classnames and would love to populate with some more information.
So basically:
I would love to populate the docs on the right side of the intellisense:
This is how we can document with properties:
Which would be amazing to have on string literals