Skip to content

Commit

Permalink
change cast of int64 input (map values) from string to Long | string …
Browse files Browse the repository at this point in the history
…in fromJSON

(see discussion here: #405 (comment))
  • Loading branch information
christians committed Nov 24, 2021
1 parent 787327a commit 511c941
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 @@ -226,7 +226,7 @@ export const SimpleWithMap = {
message.longLookup = {};
if (object.longLookup !== undefined && object.longLookup !== null) {
Object.entries(object.longLookup).forEach(([key, value]) => {
message.longLookup[key] = Long.fromValue(value as string);
message.longLookup[key] = Long.fromValue(value as Long | string);
});
}
return message;
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,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.fromValue(${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 511c941

Please sign in to comment.