TypeScript types for schema
See original GitHub issueWe are writing our site in typescript, using Gatsby and React. It would be great if the Sanity schema could be compiled to typescript interfaces, so that we could leverage static type safety during development.
I imagine generating this with a sanity
cli command.
Given the translation layers between Sanity, GraphQL and TypeScript, I imagine this is is a subtle problem. If there’s any more info I can provide to be helpful, let me know.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:55
- Comments:30 (12 by maintainers)
Top Results From Across the Web
google/schema-dts: JSON-LD TypeScript types for ... - GitHub
schema -dts provides TypeScript definitions for Schema.org vocabulary in JSON-LD format. The typings are exposed as complete sets of discriminated type unions, ...
Read more >typescript-json-schema - npm
typescript -json-schema generates JSON Schema files from your Typescript sources. Latest version: 0.55.0, last published: a month ago.
Read more >Typescript Type of JSON schema object - Stack Overflow
Is there a special type associated with JSON-schema objects in typescript? My class has a method that checks whether its members satisfy the ......
Read more >Schemas and Elements in TypeScript - iTwin.js
A Schema represents an ECSchema in TypeScript. It is a collection of Entity-based classes. See the BIS overview for how ECSchemas are used...
Read more >Schemas in TypeScript - Mongoose
Mongoose schemas are separate from TypeScript interfaces, so you need to define both a document interface and a schema until V6.3.1. Mongoose supports...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry to pollute this thread and the ironic tone, but … IMO Sanity in 2022 should have 100% TypeScript support, hell, all the init/sample projects should be scaffolded in TS
What is the point of GROQ Graphql, etc if everything in sanity (by default) is in plain JS?
Does anyone want to write any schema or plugin without TS today? Coming from other CMEs and framework, I am baffled by those schema files with 0 autocomplete or types
Edit:
The official docs have so little on that topic: https://www.sanity.io/docs/using-typescript-in-sanity-studio
100% this
my mind was so boggled by how they took all the time for TS yet didnt pass any of that on
still 🤯🤯