Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

fix(v1): handle _key and _type in objects #294

Open
wants to merge 3 commits into
base: alpha
Choose a base branch
from

Conversation

ochicf
Copy link
Contributor

@ochicf ochicf commented Apr 3, 2023

Fixes #236

The strategy taken has been to recursively forward an ancestors array so the parent is available when generating the types for a node. Ff current node is object and parent is array, then it add _key and _type.

Let me know if those fields should be added in any other cases.

Also @ricokahler I'm not able to run tests, so I have not updated them. But I think it would be good to add a case to ensure this is kept on future refactors/changes.

@vercel
Copy link

vercel bot commented Apr 3, 2023

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

A member of the Team first needs to authorize it.

@MurmeltierS
Copy link

this seems very much needed .__.

@ochicf any chance you are already publishing a fixed version somewhere for the moment

@ochicf
Copy link
Contributor Author

ochicf commented Apr 20, 2023

this seems very much needed .__.

@ochicf any chance you are already publishing a fixed version somewhere for the moment

Hey @MurmeltierS. I have integrated all my PRs into this branch: https://github.com/OrigenStudio/sanity-codegen/tree/release/v1.0.0-alpha.next

You could take that branch, build the packages I've changed (looked for bumped versions in the package.json) and publish it to a local installation of Verdaccio. Then you can install the package pointing to your local registry so it's installed from there. It's how I'm doing it to generate the types locally.

I'm wondering aswell if it could be possible to install it directly from GitHub? I have never tried it so not sure if can be done, but I guess even if possible, it will be complicated as it's a monorepo with multiple packages inside 🤔

@vercel
Copy link

vercel bot commented May 10, 2023

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:09pm

Comment on lines +147 to +151
_key: string;
_type: "objectLike";
properties?: {
_key: string;
_type: "propertyPair";
Copy link
Contributor Author

@ochicf ochicf May 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ricokahler the tests failed here because these properties are being generated now, so I added them aswell to make the tests pass. I think it makes sense but I'm not fully sure these properties are there in this case?

@phmasek
Copy link

phmasek commented Jun 19, 2023

Nice work @ochicf! ⭐ Would be really helpful to have this one merged.

@maximilianschmitt
Copy link

This is great, I also need this! Thank you!

@michelebruno
Copy link

This would be a huge improvement! @ricokahler any chance this could be merged please?

@shreyansqt
Copy link

@ricokahler this would a much needed feature. Do you think you can review this PR?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Objects in array are missing _type and _key
6 participants