-
-
Notifications
You must be signed in to change notification settings - Fork 735
Support documentation for string literal types in unions #1148
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
Comments
This gets complicated quickly. Right now we don't support documenting any parts of types except for properties of interfaces. If we add support for members of a union, it seems reasonable to also make it possible to document parts of an intersection, properties within those parts... etc. I'm also not really sure how this extra documentation would be rendered. An alternative method of documenting this could be: interface Callbacks {
/** Fired when ready */
ready: never;
/** Fired when complete */
complete: never;
/** Fired when an error occurs */
error: never;
/** @hidden */
unknown: never
}
type CallbackType = keyof Callbacks |
Thanks @Gerrit0. I ended up going with a slight variation on this: type Callbacks = {
/** Fired when ready */
ready: never;
/** Fired when complete */
complete: never;
/** Fired when an error occurs */
error: never;
/** @hidden */
unknown: never
}
type CallbackType = keyof Callbacks I preferred the output of the documentation following a In either case, these are the results that I've observed:
Further to the last point, the output of the
But I expected
It's not 100%, but it is better than nothing. |
The Not linking to callbacks in |
You might be interested in microsoft/tsdoc#164, if a solution is discovered there I'd like to revisit this. |
Cool. Thanks for the share. |
Problem
Normally I would use an
enum
for this, however, I am documenting an existing JavaScript library as a.d.ts
file where the actual type doesn't exist in JavaScript.There doesn't appear to be any support for documenting or applying an
@tag
to individual string literals in a type union.Example:
The above example has no effect on the generated documentation.
Suggested Solution
Add support for documenting individual items in a union type including
@tags
.The text was updated successfully, but these errors were encountered: