Skip to content

Commit

Permalink
Merge pull request #2370 from install/explicit-field-type-long-check
Browse files Browse the repository at this point in the history
proto-loader-gen-types Narrow field Long check
  • Loading branch information
murgatroid99 authored Feb 24, 2023
2 parents cac499f + 31aec87 commit 1054432
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/proto-loader/bin/proto-loader-gen-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ function generateMessageInterfaces(formatter: TextFormatter, messageType: Protob
const childTypes = getChildMessagesAndEnums(messageType);
formatter.writeLine(`// Original file: ${(messageType.filename ?? 'null')?.replace(/\\/g, '/')}`);
formatter.writeLine('');
const isLongField = (field: Protobuf.Field) =>
['int64', 'uint64', 'sint64', 'fixed64', 'sfixed64'].includes(field.type);
messageType.fieldsArray.sort((fieldA, fieldB) => fieldA.id - fieldB.id);
for (const field of messageType.fieldsArray) {
if (field.resolvedType && childTypes.indexOf(field.resolvedType) < 0) {
Expand All @@ -424,7 +426,7 @@ function generateMessageInterfaces(formatter: TextFormatter, messageType: Protob
seenDeps.add(dependency.fullName);
formatter.writeLine(getImportLine(dependency, messageType, options));
}
if (field.type.indexOf('64') >= 0) {
if (isLongField(field)) {
usesLong = true;
}
}
Expand All @@ -439,7 +441,7 @@ function generateMessageInterfaces(formatter: TextFormatter, messageType: Protob
seenDeps.add(dependency.fullName);
formatter.writeLine(getImportLine(dependency, messageType, options));
}
if (field.type.indexOf('64') >= 0) {
if (isLongField(field)) {
usesLong = true;
}
}
Expand Down

0 comments on commit 1054432

Please sign in to comment.