diff --git a/src/function.ts b/src/function.ts index 4ad9e9a..414ab2a 100644 --- a/src/function.ts +++ b/src/function.ts @@ -1,13 +1,10 @@ import { truncate } from './helpers.js' import type { Options } from './types.js' -export default function inspectFunction(func: Function, options: Options) { - let functionType = 'Function' - // @ts-ignore - const stringTag = func[Symbol.toStringTag]; - if (typeof stringTag === 'string') { - functionType = stringTag; - } +type ToStringable = Function & {[Symbol.toStringTag]: string}; + +export default function inspectFunction(func: ToStringable, options: Options) { + const functionType = func[Symbol.toStringTag] || 'Function' const name = func.name if (!name) { diff --git a/src/index.ts b/src/index.ts index e5656cb..4b0c644 100644 --- a/src/index.ts +++ b/src/index.ts @@ -129,7 +129,7 @@ export function inspect(value: unknown, opts: Partial = {}): string { if (type === 'object') { type = toString.call(value).slice(8, -1) } - + // If it is a base value that we already support, then use Loupe's inspector if (type in baseTypesMap) { return (baseTypesMap[type as keyof typeof baseTypesMap] as Inspect)(value, options)