UNPKG

guardz

Version:

A simple and lightweight TypeScript type guard library for runtime type validation.

21 lines (20 loc) 677 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getExpectedTypeName = void 0; /** * Get the expected type name from a type guard function * @param typeGuardFn - The type guard function to analyze * @returns The expected type name as a string */ const getExpectedTypeName = (typeGuardFn) => { const fnName = typeGuardFn.name; if (fnName.startsWith('is')) { return fnName.slice(2).toLowerCase(); } // For nested isType calls (which have empty names), return 'object' instead of 'unknown' if (!fnName) { return 'object'; } return 'unknown'; }; exports.getExpectedTypeName = getExpectedTypeName;