Skip to content

Rethink Typescript types and required vs optional #209

@tstirrat15

Description

@tstirrat15

Description

Every field in protobuf is technically optional; if a field isn't supplied it's given the zero value.

The generated typescript types for scalars are marked as "required" according to typescript, even though you can send a message with the value missing, because of how proto actually works.

This mismatch is kind of frustrating when a user doesn't actually care about one of our optional_ fields.

One way to solve this would be to use proto3 optional annotations in the upstream; this may meaningfully change the semantics of the API. Another potential way to solve it would be wrapping or whacking the Typescript types.

The basic reason for this is that Typescript cares about presence and absence, where proto doesn't by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions