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

Feature request: Enum vs string unions #5

Open
holloway opened this issue Jan 14, 2025 · 2 comments
Open

Feature request: Enum vs string unions #5

holloway opened this issue Jan 14, 2025 · 2 comments

Comments

@holloway
Copy link

The latest version of Node supports TS but only via type stripping and it can't generate enums.

Could you library optionally generate string unions instead? Rather than (eg)

export enum SlugEnum {
  Bcp = 'bcp',
  Experimental = 'experimental',
  Historic = 'historic',
  Informational = 'informational',
  Standard = 'standard',
  Unknown = 'unknown'
}

A string union like,

export SlugEnum = 
  'bcp' |
  'experimental' |
  'historic' |
  'informational' |
  'standard' |
  'unknown'
vladkens added a commit that referenced this issue Jan 18, 2025
@vladkens
Copy link
Owner

vladkens commented Jan 19, 2025

Hi, @holloway. Thank you for issue.

Added in v1.1.0.

Here a docs: https://github.com/vladkens/apigen-ts?tab=readme-ov-file#string-union-as-enums

@holloway
Copy link
Author

@vladkens excellent!

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

2 participants