{"repo":"peter-leonov/type-predicate-generator","free":true,"listed":false,"github":"https://github.com/peter-leonov/type-predicate-generator","clone":"git clone https://github.com/peter-leonov/type-predicate-generator.git","description":"Type safe predicate generator for TypeScript","language":"TypeScript","stars":103,"topics":["api","codegen","schema","typesafety","typescipt"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"TypeScript Type Predicate Generator Check JSON APIs responses 100% type safe 🔒, unit tested ✅ and at blazing speed 🚀! Give it a try in the Playground. About - Safe : generates strictly typed code and unit tests - Fast : 120 times faster than Zod, instant cold starts - Lightweight : no runtime dependencies, minifies into bytes - Portable : supports all browsers, runtimes and bundlers - Reliable : the output code is trivial to audit A TypeScript type predicates generator that produces strictly type safe .ts files with readable and extremely fast TypeScript code suitable to use in the browser, a Node.js / Deno / Bun app, CloudFront Functions, Cloudflare Workers and Akamai EdgeWorkers. It supports deeply nested types, recursive structures, arrays, unions and more. How to use It generates src/types guards.ts with the predicate functions for all the exported types in src/types.ts and init tests in src/types guards.test.ts for each generated predicate. Double safe! Extended example The source file with the types: Running the generator on it: This is the output with a readable and strictly type safe TS guard: Play with it in the Playground. This is what esbuild --minify reduces it to (formatted for readability): As you can see, esbuild nicely merges all the if s for the same set of properties into just one combined check. The tests generated for the predicate look like this. They are not covering all possible combinations as the number of combinations grows exponentially, instead t","default_branch":null,"files":null,"tree":[],"storefront":"/r/peter-leonov","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/peter-leonov/type-predicate-generator/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}