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

Static members should always be ignored when generating interfaces #192

Open
DaRosenberg opened this issue Feb 25, 2024 · 0 comments
Open

Comments

@DaRosenberg
Copy link

Currently, given this C# class:

public class NormalizationCounts
{
	public static readonly NormalizationCounts Zero = new(0, 0);
	public static readonly NormalizationCounts Success = new(1, 0);
	public static readonly NormalizationCounts Failure = new(0, 1);

	private NormalizationCounts(int numberComponentsNormalized, int numberComponentsFailed)
	{
		NumberComponentsNormalized = numberComponentsNormalized;
		NumberComponentsFailed = numberComponentsFailed;
	}

	public int NumberComponentsNormalized { get; }
	public int NumberComponentsFailed { get; }
}

TypeGen generates the following TypeScript interface:

export interface NormalizationCounts {
	readonly zero: NormalizationCounts;
	readonly success: NormalizationCounts;
	readonly failure: NormalizationCounts;
	numberComponentsNormalized: number;
	numberComponentsFailed: number;
}

It might make sense to include static members when generating classes, but when generating interfaces then IMO this makes absolutely zero sense.

I would suggest to either ignore static members by default when generating interfaces, or at the very least add a global configuration option to do so.

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