ricokahler / sanity-codegen

Generate TypeScript types from your Sanity.io schemas
sanity-codegen-dev.vercel.app
MIT License
270 stars 19 forks source link

fix(v1): generate unions of options list values #295

Open ochicf opened 1 year ago

ochicf commented 1 year ago

Reads the list option and defines the type of a union of those literal values. This should be probably tested.

Let me know if there's any other place where lists can be specified.

Fixes https://github.com/ricokahler/sanity-codegen/issues/63

vercel[bot] commented 1 year ago

@ochicf is attempting to deploy a commit to the Rico Kahler Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sanity-codegen-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 21, 2023 2:12pm
ochicf commented 1 year ago

@ricokahler added test.

Just one small comment: I've set the order of list items in the structure and in the matching test object is different because the order of the list options is not respected, but always consistently returned as they are sorted by hash here. I guess this is the expected behaviour.