Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Request for a TypeScript starter studio with desk structure example in Slack thread.

6 replies
Last updated: Jul 18, 2023
Hey all! Is there a good sanity starter studio available with Typescript? I want to transition my studio to using typescript and need a reference project (hopefully one by the sanity team) to create my types correctly. Let me know if any projects come to mind!:)
Jul 18, 2023, 7:11 PM
There are a few! I’d say take a look at any official starters. This one specifically.
Jul 18, 2023, 7:18 PM
This is great!
user M
Do you know of an example with typescript and desk structure? I have my projects organized with a
desk
folder which has the structured format such as this
index.js
(within my desk folder):
import { home } from './home'
import { projects } from './projects'
import { posts } from './posts'
import { settings } from './settings'

export const structure = (S) =>
  S.list()
    .title('Content')
    .items([
      home(S),
      projects(S),
      posts(S),
      S.divider(),
      settings(S),
      S.divider()
    ])
The example you shared is great for schemas, but I was wondering if there is a desk structure example (I would like to make my
index.js
into
index.ts
with the proper imports from sanity with typescript).
Jul 18, 2023, 7:23 PM
if you’re using vscode you can command click on the desktool() function and find the types to use for structure builder https://share.cleanshot.com/cW1qTfHB
Jul 18, 2023, 7:33 PM
you can do this for entire config object and it should show you the types of the props for the defineConfig function
Jul 18, 2023, 7:35 PM
your function just needs
S: StructureBuilder
from
_from_ 'sanity/desk'
Jul 18, 2023, 7:37 PM
Hey
user J
this is awesome. Thanks for the tip on that I had no idea I could just see the types!
Jul 18, 2023, 7:42 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?