UNPKG

guardz

Version:

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

44 lines (43 loc) 1.01 kB
import { type TypeGuardFn } from '../../../typeguards/isType'; export interface UserProfile { bio: string; } export interface User { id: number; name: string; role: 'admin' | 'user'; profile?: UserProfile; } export interface ApiResponse { data: { users: User[]; meta: { total: number; page: number; }; }; } export declare const validApiResponse: ApiResponse; export declare const invalidApiResponse: { data: { users: ({ id: number; name: string; role: string; profile: { bio: string; }; } | { id: string; name: string; role: string; profile?: never; })[]; meta: { total: number; page: string; }; }; }; export declare function createApiResponseGuard(): TypeGuardFn<ApiResponse>; export declare function parseJsonPayload(raw: string): unknown;