From 99cceef4d96a61a7af285176c6581f2f708c66d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Kubern=C3=A1t?= Date: Tue, 10 Sep 2024 10:24:24 +0200 Subject: [PATCH] Fix inverse condition --- package.json | 2 +- src/rpcmessage.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index bed3f3e..e962b7a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libshv-js", - "version": "3.3.0", + "version": "3.3.1", "description": "Typescript implementation of libshv", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", diff --git a/src/rpcmessage.ts b/src/rpcmessage.ts index 8d35a08..b47092f 100644 --- a/src/rpcmessage.ts +++ b/src/rpcmessage.ts @@ -142,14 +142,14 @@ class RpcMessage { } const error_map = this.value[KeyError]; - if (!(typeof error_map[ERROR_CODE] !== 'number')) { + if (typeof error_map[ERROR_CODE] !== 'number') { return new ProtocolError('Response had an error, but this error did not contain at least an error code'); } - const code = error_map[ERROR_CODE]; + const code = error_map[ERROR_CODE] as unknown; const ErrorType = (() => { - switch (code.value) { + switch (code) { case ErrorCode.InvalidRequest: return InvalidRequest; case ErrorCode.MethodNotFound: return MethodNotFound; case ErrorCode.InvalidParams: return InvalidParams;