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

Generated Typescript loses information about combined enum flags when using UseString #271

Open
mlemoine-clgx opened this issue Sep 14, 2023 · 0 comments

Comments

@mlemoine-clgx
Copy link

This is somewhat similar to #24, but applies when using UseString with Flags enums.

[Flags] [TsEnum(IncludeNamespace = false, UseString = true)]
public enum UserGroup
{
	None				= 0x00,
	Administrator			= 0x01,
	Standard				= 0x02,
	Restricted			= 0x04,
	Guest				= 0x08,
	RestrictedAndLower	= Restricted | Guest,
	Default				= Standard,
}

The typescript will give us:

export enum UserGroupExample {
	None = "None",
	Administrator = "Administrator",
	Standard = "Standard",
	Default = "Default",
	Restricted = "Restricted",
	Guest = "Guest",
	RestrictedAndLower = "RestrictedAndLower"
}

Note that the link between Default and Standard, and the one between RestrictedAndLower and Restricted and Guest is lost.

Ideally, I would have expected something like:

export enum UserGroupExample {
	None = "None",
	Administrator = "Administrator",
	Standard = "Standard",
	Default = "Standard",
	Restricted = "Restricted",
	Guest = "Guest",
	RestrictedAndLower = ["Restricted", "Guest"]
}

I think having a single value for Standard/Default is quite uncontroversial.

But I understand that not everyone would want RestrictedAndLower to become an array without opt-in.

I'm not sure if that's a bug or a feature request...

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

1 participant