Skip to content

Commit 42eb018

Browse files
Copilotmrlubos
andcommitted
Simplify fix: avoid tagging JavaScript enums as 'type'
Co-authored-by: mrlubos <[email protected]>
1 parent 4069338 commit 42eb018

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

packages/codegen-core/src/bindings/utils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ export const createBinding = ({
5555
if (symbol.meta?.kind === 'type') {
5656
typeNames.push(name);
5757
}
58-
// For 'value-and-type' kind (JavaScript enums), we don't add to typeNames
59-
// so they won't be exported as type-only
6058
}
6159
// cast type names to names to allow for cleaner API,
6260
// otherwise users would have to define the same values twice

packages/openapi-ts/src/plugins/@hey-api/typescript/export.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@ export const exportType = ({
130130
objectType: typeofType,
131131
}),
132132
});
133-
134-
// Mark this symbol as containing both value and type
135-
symbol.meta = { ...symbol.meta, kind: 'value-and-type' };
136133
plugin.setSymbolValue(symbol, [objectNode, node]);
137134
return;
138135
} else if (

packages/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,17 @@ const handleComponent = ({
497497
schema: IR.SchemaObject;
498498
}) => {
499499
const type = schemaToType({ plugin, schema });
500+
501+
// Don't tag JavaScript enums as 'type' since they export both values and types
502+
const isJavaScriptEnum =
503+
schema.type === 'enum' &&
504+
plugin.config.enums.enabled &&
505+
plugin.config.enums.mode === 'javascript';
506+
500507
const symbol = plugin.registerSymbol({
501508
exported: true,
502509
meta: {
503-
kind: 'type',
510+
kind: isJavaScriptEnum ? undefined : 'type',
504511
},
505512
name: buildName({
506513
config: plugin.config.definitions,

0 commit comments

Comments
 (0)