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

jsdoc of enum values #7

Closed
benny-medflyt opened this issue Mar 8, 2017 · 2 comments
Closed

jsdoc of enum values #7

benny-medflyt opened this issue Mar 8, 2017 · 2 comments

Comments

@benny-medflyt
Copy link

This is a cool little library.

When manually hand-rolling an enum, it is possible to annotate each enum value with a jsdoc. This way, your IDE can show you documentation during autocomplete and during hover:

tmp00001

Is it possible to achieve this also with typescript-string-enums?

@dphilipson
Copy link
Owner

Hi benny, first of all, sorry for the slow response.

Unfortunately I do not know of a way to make this work. I would be surprised if this is possible, as the jsdoc would need to understand to make the jump from a function argument to the key of a computed type. If documenting individual values is important to you, you may be stuck with the repetitive definition.

@dphilipson
Copy link
Owner

Fixed in 0.2.0 with the new object syntax. The following now works:

export const Status = Enum({
    /**
     * Everything is fine.
     *
     * Hovering over Status.RUNNING in an IDE will show this comment.
     */
    RUNNING: "running",

    /**
     * All is lost.
     */
    STOPPED: "stopped",
});
export type Status = Enum<typeof Status>;

console.log(Status.RUNNING); // -> "running"

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

2 participants