-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export AstroConfigType properly as type and not as a Zod schema value #7702
Conversation
🦋 Changeset detectedLatest commit: 227254b The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Now I'm clueless about the failing tests in https://github.com/withastro/astro/actions/runs/5588693525/jobs/10215913345?pr=7702#step:9:3338. |
@shishkin can you explain how you tested the feature? Maybe a screenshot to show this works now? |
@ematipico thanks for prompting me. I actually think my fix doesn't solve the problem I had. The issue is that I see only I thought this was due to the zod schema instance being exported as a type while it must be a value for the However, now even with my change I'm not able to get the autocompletion in an external integration project, though types now work internally within the astro monorepo for me. It seems the zod type generation combined with interface inheritance doesn't survive in the exported type definitions. I finally had to resort to zod way of inheritance to generate the final With latest changes I'm able to see autocompletions in an external integration project: |
I've tested your delucis/astro-embed repo and indeed autocomplete worked out of the box. But when I upgraded typescript to 5.1.6 and switched tsconfig module resolution to |
Good to know! I tested in https://github.com/withastro/starlight but still helpful to know this may be something introduced with specific config/dependency versions. |
Is there an intention to merge this? Even if it's not an immediate concern for developers not using module resolution |
Yes, that makes sense. The issue is due to changes in module resolution |
@bluwy I've updated the PR to export the type and not the schema value. Hope this makes sense now and can be merged. |
This makes the intended usage of Zod generated types actually possible
Changes
Export AstroConfigSchema as value instead of typeTesting
Previously, type autocomplete was broken on
AstroConfig
(e.g. inside an integration hook). With this change the zod schema value is retained and can be used to generate the proper type, so autocomplete works (e.g. inpackages/astro/src/@types/astro.ts
forAstroConfig
type).Docs
No docs impacted. This fixes previously intended behavior that wasn't working.