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

"google.protobuf.NullValue" from "google/protobuf/struct.proto" is not supported #250

Open
mdreizin opened this issue Dec 4, 2020 · 3 comments

Comments

@mdreizin
Copy link

mdreizin commented Dec 4, 2020

Versions of relevant software used

[email protected]
[email protected]
@types/[email protected]

What happened

Generate wrong TypeScript definition, because google_protobuf_struct_pb.NullValueMap doesn't exist:

import * as jspb from "google-protobuf";
import * as google_protobuf_struct_pb from "google-protobuf/google/protobuf/struct_pb";

export class MyMessage extends jspb.Message {
  getValue(): google_protobuf_struct_pb.NullValueMap[keyof google_protobuf_struct_pb.NullValueMap];
  setValue(value: google_protobuf_struct_pb.NullValueMap[keyof google_protobuf_struct_pb.NullValueMap]): void;

  serializeBinary(): Uint8Array;
  toObject(includeInstance?: boolean): MyMessage.AsObject;
  static toObject(includeInstance: boolean, msg: MyMessage): MyMessage.AsObject;
  static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
  static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
  static serializeBinaryToWriter(message: MyMessage, writer: jspb.BinaryWriter): void;
  static deserializeBinary(bytes: Uint8Array): MyMessage;
  static deserializeBinaryFromReader(message: MyMessage, reader: jspb.BinaryReader): MyMessage;
}

export namespace MyMessage {
  export type AsObject = {
    value: google_protobuf_struct_pb.NullValueMap[keyof google_protobuf_struct_pb.NullValueMap],
  }
}

What you expected to happen

Generate right TypeScript definition.

If use the following proto:

syntax = "proto3";

enum NullValue {
  NULL_VALUE = 0;
}

message MyMessage {
  oneof kind {
    NullValue value = 1;
  }
}

it will generate right definition:

import * as jspb from "google-protobuf";

export class MyMessage extends jspb.Message {
  hasValue(): boolean;
  clearValue(): void;
  getValue(): NullValueMap[keyof NullValueMap];
  setValue(value: NullValueMap[keyof NullValueMap]): void;

  getKindCase(): MyMessage.KindCase;
  serializeBinary(): Uint8Array;
  toObject(includeInstance?: boolean): MyMessage.AsObject;
  static toObject(includeInstance: boolean, msg: MyMessage): MyMessage.AsObject;
  static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
  static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
  static serializeBinaryToWriter(message: MyMessage, writer: jspb.BinaryWriter): void;
  static deserializeBinary(bytes: Uint8Array): MyMessage;
  static deserializeBinaryFromReader(message: MyMessage, reader: jspb.BinaryReader): MyMessage;
}

export namespace MyMessage {
  export type AsObject = {
    value: NullValueMap[keyof NullValueMap],
  }

  export enum KindCase {
    KIND_NOT_SET = 0,
    VALUE = 1,
  }
}

export interface NullValueMap {
  NULL_VALUE: 0;
}

export const NullValue: NullValueMap;

How to reproduce it (as minimally and precisely as possible):

syntax = "proto3";

import "google/protobuf/struct.proto";

message MyMessage {
    google.protobuf.NullValue value = 1;
}

Full logs to relevant components

Anything else we need to know

@stale
Copy link

stale bot commented Apr 17, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 17, 2022
@jimblackler
Copy link

I have experienced the same issue recently.

@stale stale bot removed the wontfix label Jul 27, 2023
@tfennelly
Copy link

I'm seeing the same issue.

Did either of you get a resolution to this? @jimblackler @mdreizin

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

3 participants