TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: TypeScript types that conform to JSON schemas without code generation

17 pointsby robbieoover 5 years ago

1 comment

robbieoover 5 years ago
This library allows you to write code that generates Typescript type&#x2F;JSON schema pairs &lt;T, s&gt; such that<p>1. Any type that s can validate is assignable to T<p>2. As few objects as possible that are assignable to T cannot be validated by s.<p>This allows you to write JSON schemas and use the corresponding Typescript type without having to resort to code generation, maintaining two types side-by-side, or re-writing a whole JSON schema validator in something like io-ts.<p>Hope it&#x27;s useful to someone!