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

add static fields to enum and error classes for discriminator, kind, and code fields #38

Merged
merged 2 commits into from
May 25, 2022

Conversation

kklas
Copy link
Owner

@kklas kklas commented May 25, 2022

closes #37

@kklas kklas merged commit d91c81d into master May 25, 2022
@kklas kklas deleted the enum-static branch May 25, 2022 20:27
@@ -457,6 +457,18 @@ function genEnum(
isExported: true,
name: variant.name,
properties: [
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this adds new static members instead of a replacing the instance variables - i.e. there are now both static and instance vars. Is this intentional?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's intentional. In typescript you cannot access static fields on an instance. So if we had only static fields you wouldn't be able to do foo.kind, only Foo.kind. So I have added both so we can do both.

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

Successfully merging this pull request may close these issues.

kind of typescript union members should be static
2 participants