From e58da74f6f8c5a4a8155e372b51c1500d0d643f2 Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Wed, 8 Dec 2021 09:33:18 +0000 Subject: [PATCH] fix noImplicitReturns error in Value.unwrap Fixes #432 --- src/main.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main.ts b/src/main.ts index 9e39cfa44..6d9d4a1ab 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1370,19 +1370,20 @@ function generateUnwrap(fullProtoTypeName: string): Code[] { if (isAnyValueTypeName(fullProtoTypeName)) { chunks.push(code`unwrap(message: Value): string | number | boolean | Object | null | Array | undefined { - if (message.stringValue !== undefined) { + if (message?.stringValue !== undefined) { return message.stringValue; - } else if (message.numberValue !== undefined) { + } else if (message?.numberValue !== undefined) { return message.numberValue; - } else if (message.boolValue !== undefined) { + } else if (message?.boolValue !== undefined) { return message.boolValue; - } else if (message.structValue !== undefined) { + } else if (message?.structValue !== undefined) { return message.structValue; - } else if (message.listValue !== undefined) { + } else if (message?.listValue !== undefined) { return message.listValue; - } else if (message.nullValue !== undefined) { + } else if (message?.nullValue !== undefined) { return null; } + return undefined; }`); }