Skip to content

Commit

Permalink
fix: use Long.fromValue instead of Long.fromString for improved robus…
Browse files Browse the repository at this point in the history
…tness regarding already parsed objects (#405)

Co-authored-by: christians <christian.schroeder@consistec.de>
  • Loading branch information
SchroederChris and christians committed Nov 27, 2021
1 parent 11d333d commit 7bdc3ee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion integration/simple-long/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export const SimpleWithMap = {
);
message.longLookup = Object.entries(object.longLookup ?? {}).reduce<{ [key: string]: Long }>(
(acc, [key, value]) => {
acc[key] = Long.fromString(value as string);
acc[key] = Long.fromValue(value as Long | string);
return acc;
},
{}
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ function generateFromJson(ctx: Context, fullName: string, messageDesc: Descripto
return code`${utils.bytesFromBase64}(${from} as string)`;
}
} else if (isLong(valueType) && options.forceLong === LongOption.LONG) {
return code`Long.fromString(${from} as string)`;
return code`Long.fromValue(${from} as Long | string)`;
} else if (isEnum(valueType)) {
return code`${from} as number`;
} else {
Expand Down

0 comments on commit 7bdc3ee

Please sign in to comment.