Skip to content
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

Encode crashes on null object values #1026

Open
gabrielOttopia opened this issue Apr 10, 2024 · 2 comments
Open

Encode crashes on null object values #1026

gabrielOttopia opened this issue Apr 10, 2024 · 2 comments

Comments

@gabrielOttopia
Copy link

If i try to encode an object that has null values, instead of undefined, the encode() fails. These null values are sometimes nested objects as well.

I used v1.171 and it still crashes.

@stephenh
Copy link
Owner

@gabrielOttopia can you include the snippet of code from encode that stack traces?

Are you using the useNullAsOptional flag introduced in #1017 ? Historically we've not supported null, so unless you're using useNullAsOptional that behavior is probably expected.

@gabrielOttopia
Copy link
Author

gabrielOttopia commented Apr 10, 2024

@stephenh I tried that flag and got this error:

`src/autogenerated/X/X_management.ts:241:96 - error TS2345: Argument of type '{ clientId?: { id?: string | undefined; } | null | undefined; stationId?: { id?: { id?: string | undefined; } | null | undefined; address?: { ipv4?: number | null | undefined; ipv6?: Uint8Array | null | undefined; } | null | undefined; } | null | undefined; }' is not assignable to parameter of type '{ clientId?: { id?: string | undefined; } | null | undefined; stationId?: { id?: { id?: string | undefined; } | null | undefined; address?: { ipv4?: number | null | undefined; ipv6?: Uint8Array | null | undefined; } | null | undefined; } | null | undefined; } & { ...; } & {}'.
  Type '{ clientId?: { id?: string | undefined; } | null | undefined; stationId?: { id?: { id?: string | undefined; } | null | undefined; address?: { ipv4?: number | null | undefined; ipv6?: Uint8Array | null | undefined; } | null | undefined; } | null | undefined; }' is not assignable to type '{ clientId?: ({ id?: string | undefined; } & { id?: string | undefined; } & {}) | undefined; stationId?: ({ id?: { id?: string | undefined; } | null | undefined; address?: { ipv4?: number | null | undefined; ipv6?: Uint8Array | ... 1 more ... | undefined; } | null | undefined; } & { ...; } & {}) | undefined; }'.
    Types of property 'clientId' are incompatible.
      Type '{ id?: string | undefined; } | null | undefined' is not assignable to type '({ id?: string | undefined; } & { id?: string | undefined; } & {}) | undefined'.
        Type 'null' is not assignable to type '({ id?: string | undefined; } & { id?: string | undefined; } & {}) | undefined'.

241     message.connectedClients = object.connectedClients?.map((e) => ConnectedClient.fromPartial(e)) || [];
`

`      Type '{ id?: string | undefined; } | null | undefined' is not assignable to type '({ id?: string | undefined; } & { id?: string | undefined; } & {}) | undefined'.
        Type 'null' is not assignable to type '({ id?: string | undefined; } & { id?: string | undefined; } & {}) | undefined'.ts(2345)
`

the error snipped i get probably wont be too helpful

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants