-
-
Notifications
You must be signed in to change notification settings - Fork 737
feat: enum expressions #1956
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: enum expressions #1956
Conversation
Thanks for getting rid of the eval! I haven't had time to pull it down and play with it yet, but a few thoughts:
|
Yeah but I like it for exhaustiveness purposes, to ensure that no undefined behavior happens if the code is ever refactored.
It does. I added a test to demonstrate this.
Ok, I added that.
Here I would rather that TypeDoc let the end-user be in control. I can understand that there is some value in preventing the user from potentially shooting themselves in the foot in the case of e.g. a enum member with a weird non-primitive type. But in general, I think you get even more value by airing on the side of letting the user be in complete control. It's not TypeDoc's job to be a code linter, rather it is to respect how the end-user wants their documentation to look, even if it is non-standard or potentially incorrect. |
Dead code is bad code, an error would be better, but not having it is probably even better. The worst case scenario here is that an enum member doesn't have a type.
There's a balance here, I agree, TypeDoc isn't a linter, but documentation writers aren't the only people affected by this. It's also important to consider TypeDoc plugin developers + maintainers. An "enum" is a well defined concept in TypeScript. If a TypeDoc model claims to be an enum member but has call signatures, well... I wouldn't fault any plugin developer for not considering handling that nonsensical case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can simplify the logic a bit
Co-authored-by: Gerrit Birkeland <gerrit@gerritbirkeland.com>
Thanks! Released in 0.22.18 |
This PR fixes the bug where TypeDoc will interpret the following code as a variable instead of an enum:
The tests fail because one of the spec files changed.