When enumStyle: "union" is set, all user-defined enums are correctly generated as plain type aliases (e.g. export type Status = "active" | "inactive"). However, the built-in ContentType in the generated http-client is still emitted as a regular TypeScript enum regardless of the setting.
Additionally, the generated API call sites use ContentType.Json, ContentType.FormData, etc. — dot-property access that requires a runtime object. Since a plain type alias has no runtime representation, this produces invalid TypeScript under isolatedModules: true and breaks at runtime.
This was missed in #1754 where enumStyle was introduced. The const branch was handled for ContentType (it generates a const object + type alias), but no union branch was added.
Expected behaviour:
With enumStyle: "union":
// http-client
export type ContentType = "application/json" | "application/vnd.api+json" | "multipart/form-data" | "application/x-www-form-urlencoded" | "text/plain";
// generated API call
createPet(data: Pet, params: RequestParams = {}) =>
this.request<Pet, any>({
path: `/pets`,
method: "POST",
body: data,
type: "application/json", // ← string literal, not ContentType.Json
...params,
})
Actual behaviour:
ContentType is generated as export enum ContentType { ... } and call sites use type: ContentType.Json.
Apologies for the oversight — this should have been caught and included in #1754.
When
enumStyle: "union"is set, all user-defined enums are correctly generated as plain type aliases (e.g.export type Status = "active" | "inactive"). However, the built-inContentTypein the generated http-client is still emitted as a regular TypeScriptenumregardless of the setting.Additionally, the generated API call sites use
ContentType.Json,ContentType.FormData, etc. — dot-property access that requires a runtime object. Since a plain type alias has no runtime representation, this produces invalid TypeScript underisolatedModules: trueand breaks at runtime.This was missed in #1754 where
enumStylewas introduced. Theconstbranch was handled for ContentType (it generates aconstobject + type alias), but nounionbranch was added.Expected behaviour:
With
enumStyle: "union":Actual behaviour:
ContentTypeis generated asexport enum ContentType { ... }and call sites usetype: ContentType.Json.Apologies for the oversight — this should have been caught and included in #1754.