Skip to content

Commit

Permalink
fix: generate all nested enums first
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <christian@aperture.us>
  • Loading branch information
paralin committed Apr 26, 2024
1 parent 188da66 commit 7b22a18
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export function generateTs(schema: Schema) {
if (message.file !== file) {
return;
}

for (const nestedEnum of message.nestedEnums) {
generateEnum(f, nestedEnum);
}

messageTypes.push(message);
const deps = new Set<DescMessage>();
for (const field of message.fields) {
Expand Down Expand Up @@ -198,12 +203,6 @@ function generateMessage(
f.print(" },");
f.print(");");
f.print();
for (const nestedEnum of message.nestedEnums) {
generateEnum(f, nestedEnum);
}
for (const nestedMessage of message.nestedMessages) {
generateMessage(schema, f, nestedMessage);
}
}

function generateField(f: GeneratedFile, field: DescField) {
Expand Down

0 comments on commit 7b22a18

Please sign in to comment.