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

TS Top Level Enums are not imported correctly #454

Closed
rogchap opened this issue Feb 5, 2019 · 1 comment · Fixed by #481
Closed

TS Top Level Enums are not imported correctly #454

rogchap opened this issue Feb 5, 2019 · 1 comment · Fixed by #481

Comments

@rogchap
Copy link
Contributor

rogchap commented Feb 5, 2019

As a result of: #433

@shaxbee Firstly, thank you for this PR, makes for much better typings.

I've noticed that this has caused a side-effect with importing top level enums that are imported; messages seem to be correctly referenced but enums are not. In the below example I would expect Status to be status_pb.Status in the *.d.ts

Input:

// echo.proto
syntax = "proto3";

package grpc.gateway.testing;
import "status.proto";

message EchoStatusRequest {
  Status status = 1;
  StatusMessage msg = 2;
}

// status.proto
syntax = "proto3";

package grpc.gateway.testing;

enum Status {
  UNKNOWN = 0;
  SUCCESS = 1;
}

message StatusMessage {
  string status = 1;
}

Output:

// echo_pb.d.ts
import * as status_pb from './status_pb';

export class EchoStatusRequest {
  constructor ();
  getStatus(): Status;
  setStatus(a: Status): void;
  getMsg(): status_pb.StatusMessage;
  setMsg(a: status_pb.StatusMessage): void;
  toObject(): EchoStatusRequest.AsObject;
  serializeBinary(): Uint8Array;
  static deserializeBinary: (bytes: {}) => EchoStatusRequest;
}

export namespace EchoStatusRequest {
  export type AsObject = {
    status: Status;
    msg: status_pb.StatusMessage;
  }
}
rogchap added a commit to SafetyCulture/grpc-web that referenced this issue Feb 5, 2019
@shaxbee
Copy link
Contributor

shaxbee commented Feb 5, 2019

Thanks for finding this ;-)

stanley-cheung added a commit to stanley-cheung/grpc-web that referenced this issue Feb 27, 2019
loyalpartner pushed a commit to loyalpartner/grpc-web that referenced this issue Sep 4, 2020
* Allow non root resources

* code review

* code review

* code review

* code review

* add non root resource test

* add non root resource test

* add non root resource test

* code review

* code review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants