From 511c941861c4dc19e4eb3893896b67891f8fa406 Mon Sep 17 00:00:00 2001 From: christians Date: Wed, 24 Nov 2021 08:41:38 +0100 Subject: [PATCH] change cast of int64 input (map values) from string to Long | string in fromJSON (see discussion here: https://github.com/stephenh/ts-proto/pull/405#discussion_r754373607) --- integration/simple-long/simple.ts | 2 +- src/main.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/simple-long/simple.ts b/integration/simple-long/simple.ts index edbc8b312..579f37c6c 100644 --- a/integration/simple-long/simple.ts +++ b/integration/simple-long/simple.ts @@ -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; diff --git a/src/main.ts b/src/main.ts index 41662fca5..77d3320c7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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 {