grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.46k stars 762 forks source link

Missing dot after enum's namespace in typescript file #1271

Closed heggi closed 1 year ago

heggi commented 1 year ago

Has 2 proto files:

enum.proto

syntax = "proto3";

enum DocEnum {
    DOC_ENUM_PDF = 0;
    DOC_ENUM_HTML = 1;
}

test.proto

syntax = "proto3";

import "enum.proto";

package Test;

message HelloRequest {
    DocEnum doc = 1;
}

Generated code (test_pb.d.ts)

import * as jspb from 'google-protobuf'

import * as enum_pb from './enum_pb';

export class HelloRequest extends jspb.Message {
  getDoc(): enum_pbDocEnum;
  setDoc(value: enum_pbDocEnum): HelloRequest;

  serializeBinary(): Uint8Array;
  toObject(includeInstance?: boolean): HelloRequest.AsObject;
  static toObject(includeInstance: boolean, msg: HelloRequest): HelloRequest.AsObject;
  static serializeBinaryToWriter(message: HelloRequest, writer: jspb.BinaryWriter): void;
  static deserializeBinary(bytes: Uint8Array): HelloRequest;
  static deserializeBinaryFromReader(message: HelloRequest, reader: jspb.BinaryReader): HelloRequest;
}

export namespace HelloRequest {
  export type AsObject = {
    doc: enum_pbDocEnum,
  }
}

enum_pbDocEnum must be enum_pb.DocEnum at 3 places


protoc version 3.20.1 protoc-grpc-web 1.3.1 run as protoc --proto_path=./protos --js_out=import_style=commonjs,binary:gen --grpc-web_out=import_style=typescript,mode=grpcwebtext:gen ./protos/*.proto

sampajano commented 1 year ago

Thanks so much for the bug report!

I'll take a look in the near future! :)

sampajano commented 1 year ago

I've taken a look and it seems that the issue is that we forgot to insert a . between the package name and the enum name here:

https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/generator/grpc_generator.cc#L338-L340

I'll send a patch soon thanks :)