-
Notifications
You must be signed in to change notification settings - Fork 63
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
Support generating different case enum strings from wit enums #509
Comments
Just to understand the usage you're referring to, to clarify, where currently we output: export type SomeEnum = 'value-a' | 'value-b' | 'value-c'; you're wanting a configuration option to alter this to: export type SomeEnum = 'VALUE_A' | 'VALUE_B' | 'VALUE_C'; Ideally in future, JS would have first-class enums and we could use: export enum SomeEnum {
valueA,
valueB,
valueC
} in which case we'd likely have an option to use this feature while it's being developed, including whether or not it should define the values as symbols or kebab strings, but overall we do take a position that customization of these kinds of features isn't something Jco aims to offer as a first-class construct. Please do let me know if I'm missing anything though. |
Yep! That's exactly what we're trying to achieve. Using strings in the format of
I thought this was off the table or is it still being discussed for JS? Even most things in TypeScript are moving towards string unions instead of their
🤔 If that's the case, why chose |
I was under the impressio that the convention for shout case in JS was usually restricted to top-level constants such as: const MY_CONST = 'val'; where you might have a const representing an enum value but then you'd pass it by reference like That said the TypeScript docs do have one example of uppercase strings used for enum values. Wondering if you know of any other references here? In short, the Jco position is to try to go to with the combination of what is expected in the JS ecosystem with where the JS ecosystem is headed. |
It seems that the TypeScript Enum handbook chapter typically uses all caps when the string value will be used. For example, Enums at Compile Time uses all caps for log levels since key strings are being used for access. I don't think the JavaScript community really has common patterns for enums that aren't just re-implementations of what TypeScript has done for years. |
At Arcjet, we use jco to transpile our Wasm components. However, when transpiling enums, jco consistently outputs kebab-cased strings, while our configuration requires SCREAMING_SNAKE_CASE. As a result, we need to convert these enum strings before invoking Wasm using the generated bindings.
After discussing this with @blaine-arcjet, we believe the ideal solution would be to add configurable case options to jco, allowing users to specify the desired case for generated enums. We are happy to work on this feature ourselves and open a pull request, but we wanted to check in with you first to confirm that this is something you'd like to see in jco.
The text was updated successfully, but these errors were encountered: