Hacker GitHub

← All repos

bcherny/json-schema-to-typescript

View on GitHub ↗ ★ 3,350 TypeScript

Compile JSON Schema to TypeScript type declarations

13 mentions on Hacker News by 6 people: 1 story, 12 comments · first 2016-05-19 · latest 2023-10-06

Mentions per year 13 mentions · busiest year 2017 (5)
20082026
  1. …that don’t adhere to the spec, etc. Feel free to check out the tests to understand some of these: https://github.com/bcherny/json-schema-to-typescript (shameless plug — I have maintained this library for a number of years).
  2. …consistent interface, and almost every language has a reasonably up-to-date validation library. [1] https://github.com/bcherny/json-schema-to-typescript
  3. Take a look at https://github.com/bcherny/json-schema-to-typescript , too. I used it successfully at a previous job. IIRC, I had to write some code to convert OpenAPI to JSON Schema but it wasn’t onerous
  4. If you're using OpenAPI, you could use this to generate TypeScript interfaces: https://github.com/bcherny/json-schema-to-typescript It works really well
    comment by goodoldneon · 2022-05-06 · in TRPC: End-to-end typesafe APIs made easy
  5. …possible, though I don't know how strictly they map to/from each other. JSON schema to TypeScript - https://github.com/bcherny/json-schema-to-typescript TypeScript to JSON schema - https://github.com/YousefED/typescript-json-schema
  6. …achieved run-time type checking in TypeScript. In this case, it was done by code generation using: https://github.com/bcherny/json-schema-to-typescript Personally, I'd prefer a way that doesn't involve another build step. A popular library…
  7. …undefined to explicit types Or, use —strict to do both of those and more. Example tsconfig.json: https://github.com/bcherny/json-schema-to-typescript/blob/ma... Btw, what specifically is indecent about TS’s type guards?
    comment by bcherny · 2019-01-16 · in Migrate Jest to TypeScript
  8. …Or you could define your types using something like JSON Schema and validate against that. https://github.com/bcherny/json-schema-to-typescript https://github.com/YousefED/typescript-json-schema
  9. …are described in the separate JSONPointer spec [0]. See unit tests for examples: - In-file $ref: https://github.com/bcherny/json-schema-to-typescript/blob/ma... - Local $ref: https://github.com/bcherny/json-schema-to-typescript/blob/ma...…
  10. …but comments seem like a solid stopgap. Especially because they show up as tooltips in VSCode. [0] https://github.com/bcherny/json-schema-to-typescript/issues/...
  11. …e.g. validating an entry via RegEx. It tends to make APIs safer and runtime errors more clear. [1] https://github.com/bcherny/json-schema-to-typescript [2] https://github.com/YousefED/typescript-json-schema
    comment by whatever_dude · 2017-04-11 · in TypeScript at Slack
  12. Ha! That's the reason I started working on https://github.com/bcherny/json-schema-to-typescript . For the record, JSON Schemas are quite a bit more expressive than TypeScript interfaces, or even Scala Traits. I actually put together a big…
    comment by bcherny · 2016-05-19 · in Specifying JSON