question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v3 function schemas don't show error for missing fields on returns

See original GitHub issue

Given code: image

The function returns additional fields that are not on the returns schema. The expected behavior is that TS would throw an error due to key2 being an additional field on the type. Adding strict() does not fix this either

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
colinhackscommented, Mar 26, 2021

Yep either one is good.

Note that if TestSchema contains transforms you’ll want to use z.input instead of z.infer.

1reaction
mmahalwycommented, Mar 26, 2021

Ah interesting. I was thinking of this:

export const func = z
  .function()
  .args(z.string())
  .returns(TestSchema)
  .implement((arg1): z.infer<typeof TestSchema> => {
    // write code
  })
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unsure how to resolve Missing field while writing result error ...
We'd like to resolve this issue and remove the errors from the console, but have so far been unsuccessful. We tried to update...
Read more >
Customizing the behavior of cached fields - Apollo GraphQL
The following read function returns a default value of UNKNOWN NAME for the name field of a Person type whenever a value isn't...
Read more >
How do I resolve issues with missing or incorrect schema ...
I have run into various cases where errors are occurring related to the DatabaseSchemaVersion property in the LSW_SYSTEM_SCHEMA table for the BPM and...
Read more >
Quickstart — marshmallow 3.19.0 documentation
Make a field required by passing required=True . An error will be raised if the the value is missing from the input to...
Read more >
Mongoose Schema hasn't been registered for model
This seemed to solve the Schema error, but now there's a "router is not defined" error in routes/index.js . I understand what a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found