From 360a6c7bbf2f4eb5d6949e5229cc340804c64600 Mon Sep 17 00:00:00 2001 From: Timo Stamm Date: Thu, 19 Nov 2020 11:02:28 +0100 Subject: [PATCH] Fix jstype = JS_STRING field option for speed optimized code There was a bug in internal-binary-read.ts When the field option jstype = JS_STRING was set, the generated method `internalBinaryRead` would still read the field as a bigint. This problem only surfaces if the plugin parameter long_type_string is *not* set and code is optimized for speed (instead of for code size). --- .../src/message-type-extensions/internal-binary-read.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/plugin/src/message-type-extensions/internal-binary-read.ts b/packages/plugin/src/message-type-extensions/internal-binary-read.ts index 1ab6fb8c..269c15f2 100644 --- a/packages/plugin/src/message-type-extensions/internal-binary-read.ts +++ b/packages/plugin/src/message-type-extensions/internal-binary-read.ts @@ -949,11 +949,8 @@ export class InternalBinaryRead implements CustomMethodGenerator { if (!Interpreter.isLongValueType(type)) { return readerMethodCall; } - if (longType === undefined) { - longType = this.options.normalLongType; - } let convertMethodProp; - switch (longType) { + switch (longType ?? rt.LongType.STRING) { case rt.LongType.STRING: convertMethodProp = ts.createPropertyAccess(readerMethodCall, ts.createIdentifier('toString')); break;