From a177d4b61fe1fb5e096d73019ea9bc4af5599a6a Mon Sep 17 00:00:00 2001 From: DieMyst Date: Thu, 8 Aug 2019 18:58:23 +0300 Subject: [PATCH] add null checks --- assembly/encoder.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/assembly/encoder.ts b/assembly/encoder.ts index 72b2b15..d9aa186 100644 --- a/assembly/encoder.ts +++ b/assembly/encoder.ts @@ -54,7 +54,7 @@ export class JSONEncoder { this.isFirstKey.pop(); } - pushObject(name: string): bool { + pushObject(name: string | null): bool { this.writeKey(name); this.write("{"); this.isFirstKey.push(true); @@ -66,14 +66,14 @@ export class JSONEncoder { this.isFirstKey.pop(); } - private writeKey(str: string): void { + private writeKey(str: string | null): void { if (!this.isFirstKey[this.isFirstKey.length - 1]) { this.write(","); } else { this.isFirstKey[this.isFirstKey.length - 1] = false; } if (str != null) { - this.writeString(str); + this.writeString(str as string); this.write(":"); } }