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

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

Closed
heggi opened this issue Sep 4, 2022 · 2 comments · Fixed by #1278
Closed

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

heggi opened this issue Sep 4, 2022 · 2 comments · Fixed by #1278

Comments

@heggi
Copy link

heggi commented Sep 4, 2022

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
Copy link
Collaborator

Thanks so much for the bug report!

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

@sampajano
Copy link
Collaborator

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 :)

sampajano added a commit to sampajano/grpc-web that referenced this issue Sep 16, 2022
Verified with the example in grpc#1271

// enum.proto
```proto
syntax = "proto3";

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

// test.proto
```proto
syntax = "proto3";

import "enum.proto";

package Test;

message HelloRequest {
    DocEnum doc = 1;
}
```

generate:
```
protoc --proto_path=. --js_out=import_style=commonjs,binary:. --grpc-web_out=import_style=typescript,mode=grpcwebtext:. *.proto
```
sampajano added a commit that referenced this issue Sep 16, 2022
Verified with the example in #1271

// enum.proto
```proto
syntax = "proto3";

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

// test.proto
```proto
syntax = "proto3";

import "enum.proto";

package Test;

message HelloRequest {
    DocEnum doc = 1;
}
```

generate:
```
protoc --proto_path=. --js_out=import_style=commonjs,binary:. --grpc-web_out=import_style=typescript,mode=grpcwebtext:. *.proto
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants