From 7add02981dffb7e23478e8ee0ed55bb9a2bc0e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gautier=20Ben=20A=C3=AFm?= <48261497+GauBen@users.noreply.github.com> Date: Tue, 1 Aug 2023 11:15:38 +0200 Subject: [PATCH] Update debugJsonValue to accept unknown (#535) --- packages/protobuf-bench/README.md | 2 +- packages/protobuf/src/private/json-format-common.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/protobuf-bench/README.md b/packages/protobuf-bench/README.md index fe1e3f448..737f0a16e 100644 --- a/packages/protobuf-bench/README.md +++ b/packages/protobuf-bench/README.md @@ -10,5 +10,5 @@ server would usually do. | code generator | bundle size | minified | compressed | |---------------------|------------------------:|-----------------------:|-------------------:| -| protobuf-es | 88,672 b | 37,773 b | 9,865 b | +| protobuf-es | 88,669 b | 37,770 b | 9,843 b | | protobuf-javascript | 394,384 b | 288,761 b | 45,123 b | diff --git a/packages/protobuf/src/private/json-format-common.ts b/packages/protobuf/src/private/json-format-common.ts index e13b4e439..a1f0d5b0d 100644 --- a/packages/protobuf/src/private/json-format-common.ts +++ b/packages/protobuf/src/private/json-format-common.ts @@ -328,7 +328,7 @@ export function makeJsonFormatCommon( }; } -function debugJsonValue(json: JsonValue): string { +function debugJsonValue(json: unknown): string { if (json === null) { return "null"; } @@ -338,7 +338,7 @@ function debugJsonValue(json: JsonValue): string { case "string": return json.length > 100 ? "string" : `"${json.split('"').join('\\"')}"`; default: - return json.toString(); + return String(json); } }