From 7e8eeb96c2bf64f8f879081b62ebed85ff8c53a6 Mon Sep 17 00:00:00 2001 From: Bjorn Stromberg Date: Mon, 15 Jun 2020 13:29:44 +0900 Subject: [PATCH] Make argument type more specific for isOfType --- source/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/index.ts b/source/index.ts index 71a4a32..3d96809 100644 --- a/source/index.ts +++ b/source/index.ts @@ -93,10 +93,12 @@ function isPrimitiveTypeName(name: unknown): name is PrimitiveTypeName { export type TypeName = ObjectTypeName | PrimitiveTypeName; -const {toString} = Object.prototype; // eslint-disable-next-line @typescript-eslint/ban-types -const isOfType = (type: string) => (value: unknown): value is T => typeof value === type; +function isOfType(type: PrimitiveTypeName | 'function') { + return (value: unknown): value is T => typeof value === type; +} +const {toString} = Object.prototype; const getObjectType = (value: unknown): ObjectTypeName | undefined => { const objectName = toString.call(value).slice(8, -1); if (objectName) {