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

Enums as values #571

Closed
benmccann opened this issue Feb 9, 2024 · 2 comments
Closed

Enums as values #571

benmccann opened this issue Feb 9, 2024 · 2 comments

Comments

@benmccann
Copy link
Contributor

I can use the --useEnumType flag to generate enums instead of union types. For example:

export enum JobCommand {
    Start = "start",
    Pause = "pause",
    Resume = "resume",
    Empty = "empty",
    ClearFailed = "clear-failed"
}

However, this won't let me reference the values in code like JobCommand.Start

Screenshot from 2024-02-09 15-00-32

I'm trying to migrate from the official open api generator, which generated this:

export const JobCommand = {
    Start: 'start',
    Pause: 'pause',
    Resume: 'resume',
    Empty: 'empty',
    ClearFailed: 'clear-failed'
} as const;
@Xiphe
Copy link
Collaborator

Xiphe commented Feb 12, 2024

Hi @benmccann 🤙

This is strange... It should™ work exactly this way and with the demo/enumApi.ts it does:

image

I'd assume this is a problem on your end. Maybe along the lines of import type { JobCommand } instead of import { JobCommand }. Can you please double-check?

Closing as I assume we can't help with this, please re-open when you have more infos and need adjustments on our end.

@Xiphe Xiphe closed this as completed Feb 12, 2024
@benmccann
Copy link
Contributor Author

Yes, I did get it working on my end: immich-app/immich#7110. Thanks so much and sorry for the false report!

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