-
Notifications
You must be signed in to change notification settings - Fork 43
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
[BUG] Jsonify
marks properties that are required and may be undefined as optional
#689
Comments
This is similar to #534 - but occurs when |
Thanks for the report, @fnimick! The tricky thing here is that JSON has no concept of A workaround in situations like this could be a type assertion: Given the inability for JSON to represent |
Ah, I didn't realize that. I think explicitly typing (edit: as a user) our interface types to allow for undefined / optional is the best, when those interfaces are going to be returned from inngest calls. (having different behavior for those cases is a HUGE code smell anyway). So in that way, the types are correct, and flagging the type error here is the right thing to do! I'm not sure how this interacts with the |
Thanks for the reply! Closing this as it seems like things are working as intended. I'll note that we would like to add more complex middleware typing at some point to allow you to customize the output of steps (to remove or add to the existing "jsonification"). |
Describe the bug
Jsonify marks all properties that may be undefined as optional, which breaks when dealing with types that have required, potentially undefined properties.
To Reproduce
Example:
TestJsonify
has the following type:This means that values of type
Jsonify<Test>
can no longer be assigned to values of typeTest
, as the required, potentially undefined property no longer type checks.Expected behavior
The type of
Jsonify<object>
and the object itself should match, for simple interfaces like this.Code snippets / Logs / Screenshots
If applicable, add screenshots to help explain your problem.
System info (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: