You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// incorrect, doesn't return a promiseconstgenericFetch=<Schemaextendsz.ZodSchema>(url: string,schema: Schema): z.infer<Schema>=>{returnfetch(url).then((res)=>res.json()).then((result)=>schema.parse(result));};
This is because the current test case checks the type of result, which awaits genericFetch, so it doesn't care if genericFetch returns a Promise or not.
I came up with two possibilities for a test case that catches this - I don't love either of these, maybe a TS Wizard could come up with something more elegant.
Just check that genericFetch returns a promise of some sort
Currently both of these "solutions" pass exercise 14:
This is because the current test case checks the type of
result
, which awaitsgenericFetch
, so it doesn't care ifgenericFetch
returns a Promise or not.I came up with two possibilities for a test case that catches this - I don't love either of these, maybe a TS Wizard could come up with something more elegant.
The text was updated successfully, but these errors were encountered: