From 67868e9eb810de94ca0bb6e1298799ee3f550145 Mon Sep 17 00:00:00 2001 From: Karl-Philipp Wulfert Date: Tue, 2 Apr 2019 16:24:27 +0200 Subject: [PATCH] fix: correct isThing guard --- src/core/types/Guards.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/types/Guards.ts b/src/core/types/Guards.ts index a0efd1b6..ac03e169 100644 --- a/src/core/types/Guards.ts +++ b/src/core/types/Guards.ts @@ -24,7 +24,11 @@ import {SCThing, SCThingType} from '../Thing'; * @param {any} something Something to check */ export function isThing(something: any): something is SCThing { - return (something.type && something.type in SCThingType); + return ( + typeof something === 'object' + && typeof something.type === 'string' + && Object.values(SCThingType).indexOf(something.type) >= 0 + ); } /**