UNPKG

@toreda/strong-types

Version:

Better TypeScript code in fewer lines.

13 lines (12 loc) 504 B
/** * Validate `value` a valid type_T and return it if valid, otherwise * return `fallback`. Quick and easy way to validate configs, maps, and * other objects with a guaranteed return type. * @param typeName JavaScript type name for expected type. * @param value Value to be validated as `typeName`. * @param fallback Value returned when `value` is not a valid type_T. * @returns * * @category Core */ export declare function typeValue<T>(typeName: string, value: unknown, fallback: T): T;