Closed NuroDev closed 8 months ago
That is odd. ZodType
is the abstract class all other schema shapes inherit from. Could it be conflicting zod versions?
Ah, you are correct. My mistake. I didn't have zod
installed locally. For whatever reason the Zod nullish check didn't get flagged. I guess it imported Astro's version of Zod probably.
Either way that seemed to fix that error. However I now get a new error, naturally, complaining that top-level await
is not supported (yet)
Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)
Yep, it was brought up before. Cloudflare's settings are kinda strict, I think it's from the adapter's extra processing. Doesn't matter though, the import doesn't need to be top-level.
@NuroDev I thought it was the cloudflare adapter but maybe not, I was able to build correctly with it. Is there something else in your project that could be involved?
Hey y'all I'm also seeing that same error:
Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)
It seems to be referencing this part of the code:
I've tried changing the target to es2022 in the astro config file and a few other things in stackoverflow with no luck. Going to keep looking into it but just wanted to post here too
Oh wait, I missed your PR haha okay glad that will fix it. Thanks @lilnasy!
Released astro-typed-api@0.1.2
with a fix. Since I couldn't reproduce the error, I'll let one of you confirm before closing.
@lilnasy My bad forgot to circle back here, yup all is good now. Thanks!
Thanks!
Just testing out the
astro-typed-api
package & so far it's looking very promising. However one quick issue that I ran into immediately is that this check is running if you provide a Zod object schema (z.object({ ... })
).Example
If you try to query this you get the following error:
Cause
The issue being, as I mentioned above, being this check which seems to only check if the provided schema if of one possible sort of Zod schema. In this case something like a string.
Maybe switching this to a nullish check for a
_def
property inside the schema object may be better? And then if you want to get more specific check the schema definition type to limit which ones are allowed / supported. Otherwise you may need a lengthy check for all possible Zod classes that are and aren't supported.