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

protoc-gen-tstypes: Generating types for dependencies #24

Open
mousavian opened this issue Sep 5, 2018 · 4 comments
Open

protoc-gen-tstypes: Generating types for dependencies #24

mousavian opened this issue Sep 5, 2018 · 4 comments

Comments

@mousavian
Copy link

mousavian commented Sep 5, 2018

Consider having this definition:

syntax = "proto3";
import "google/protobuf/timestamp.proto";
service Greeter {
  rpc SayHello(Request) returns (Response) {}
}
message Request {
  string name = 1;
}
message Response {
  google.protobuf.Timestamp date = 1;
}

Inside generated files, it can't resolve timestamp's type from google namespace.
screen shot 2018-09-05 at 4 53 22 pm

Am I missing anything or I has not been implemented?
Because I didn't see any handler for f.GetDependencies() in the generator.

@tmc
Copy link
Owner

tmc commented Sep 5, 2018

@mousavian we have a couple of options here. Can you weigh in on how you’d expect it to work?

@shanshanzhu
Copy link

shanshanzhu commented Sep 26, 2018

imported types also fails for protoc-gen-flowtypes for me. What are the options there for types with dependency? @tmc

@tmc
Copy link
Owner

tmc commented Mar 29, 2019

@shanshanzhu @mousavian the implementation work here isn't hard -- can you propose how you'd expect the output to end up as a design recommendation?

@timostamm
Copy link

Thanks for this generator, @tmc

There's some info about the canonical JSON mapping:
https://developers.google.com/protocol-buffers/docs/proto3#json

This is what I came up with so far:

declare namespace google.protobuf {
    type Any = {
        "@type": string;
        [index: string]: any
    };
    type Timestamp = string;
    type Duration = string;
    type Struct = { [index: string]: Value };
    type DoubleValue = number | 'NaN' | 'Infinity' | '-Infinity';
    type FloatValue = number | 'NaN' | 'Infinity' | '-Infinity';
    type Int64Value = string;
    type UInt64Value = number;
    type Int32Value = number;
    type UInt32Value = number;
    type BoolValue = boolean;
    type StringValue = string;
    type BytesValue = string;
    type Empty = {};
    type NullValue = null;
    type ListValue = Value[];
    type Value = string | number | boolean | any[] | null;
    type FieldMask = string;
}

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

4 participants