typescript-runtime-schemas
Version:
A TypeScript schema generation tool that extracts Zod schemas from TypeScript source files with runtime validation support. Generate validation schemas directly from your existing TypeScript types with support for computed types and constraint-based valid
24 lines (23 loc) • 1.16 kB
TypeScript
import { TypeAliasDeclaration, InterfaceDeclaration } from "ts-morph";
/**
* Utility function to determine whether a type or typeAlias object is a top-level
* intersection with SupportsRuntimeValidation.
*
* Examples:
* - type A = { id: number, title: string } → false
* - type B = A & SupportsRuntimeValidation → true
* - type C = Pick<B, 'id'> → false
* - type D = Pick<B, 'id'> & SupportsRuntimeValidation → true
*
* @param typeDeclaration - The TypeAliasDeclaration or InterfaceDeclaration to check
* @returns true if the type is a top-level intersection with SupportsRuntimeValidation, false otherwise
*/
export declare function isTopLevelIntersectionWithSupportsRuntimeValidation(typeDeclaration: TypeAliasDeclaration | InterfaceDeclaration): boolean;
/**
* Convenience function that works with source code strings
*
* @param sourceCode - TypeScript source code containing type definitions
* @param typeName - Name of the type to check
* @returns true if the specified type is a top-level intersection with SupportsRuntimeValidation
*/
export declare function checkTypeInSourceCode(sourceCode: string, typeName: string): boolean;