Generating string unions instead of enums #1328
Closed
CodeSmith32
started this conversation in
General
Replies: 1 comment
-
Ahh! Found it! There's a swagger-typescript-api/index.ts Lines 179 to 183 in a8c7e98 I'm using the programming api; so having added it to my options config, it worked fine: generateApi({
input: path.resolve(process.cwd(), "..."),
output: path.resolve(process.cwd(), "..."),
name: "api.ts",
templates: path.resolve(process.cwd(), "..."),
generateUnionEnums: true, // <----------------------
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How do I change the enum types generated from native enums to basic string unions?
The generated code looks like,
I instead need,
It's breaking because we rely on pre-existing string-union types. The types are ultimately equivalent once compiled, but the typescript is complaining because
"value1" | "value2"
is somehow a different type fromenum SomeEnum { ... }
.I imagine this will also be a problem for anyone trying to run the generated code directly from Node using
--experimental-strip-types
since native enums are not erasable.Beta Was this translation helpful? Give feedback.
All reactions