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
Support for as const
enums
#1675
Comments
I'm going to look at this again before releasing 0.23, should TypeDoc do this even if you don't tag the variable with Vote: 👍 👎 |
@Gerrit0 Could this be extended for enum-object declarations? eg. instead of
there is (in .d.ts ) just
there is even a "convenience variant":
I am happy to open new issue for this if this is doable! |
The one without |
TypeDoc already supports enum-like objects with string literal values via TypeStrong#1675 and TypeStrong#1740. Enum-like objects with numeric literal values should also be supported, as they are a popular choice for developers wishing to avoid use of TypeScript enums. This PR adds support for such objects. Tests and a new example have been added to cover this type of object. Resolves TypeStrong#1918.
Search Terms
as const
, enumerationsProblem
Since TypeScript's
enum
is rather inconvenient to work with, some packages define their own enum-like objects, TypeDoc does this too.typedoc/src/lib/utils/entry-point.ts
Lines 15 to 35 in 664e27c
However, the generated documentation doesn't make it obvious that this value should be treated as an enumeration.
Suggested Solution
Detect variables annotated with
@enum
with all readonly properties that are string literals, and convert them as an enumeration.If there is also a type alias by the same name whose content is
typeof T[keyof typeof T]
, remove it from the documentation since enums are also types.The text was updated successfully, but these errors were encountered: