Skip to content

Next.js does not serialize values that are undefined #492

@m8vago

Description

@m8vago

First of all thanks for your hard work, ts-proto is really awesome!

Recently we'd updated to the latest version and noticed, the grpc response has undefined values as a default for fields which aren't sent in the wire.

I think the change was made in this commit:
https://github.com/stephenh/ts-proto/commit/70832d33bae82ecb3c5f87845d14e992a13437e4#diff-4fab5baaca5c14d2de62d8d2fceef376ddddcc8e9509d86cfa5643f51b89ce3d

However this broke our Next.js frontend, because next forbids to send an object in getServerSideProps() as a response that has any undefined value.

As far as i see, in the current code-base there is no option to disable the default undefined value for optional fields.

I am aware of Type.toJson() calls are dealing with this issue, but those are returning any types, which would make our code less type-safe.

Would it be possible to have a flag that restores the old behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions