grpc-node icon indicating copy to clipboard operation
grpc-node copied to clipboard

proto-loader-gen-types Typename templates

Open install opened this issue 3 years ago • 1 comments

  • Allow for customizing the naming pattern for both restricted and permissive types

Enums and filenames are left untouched

install avatar Aug 05 '22 16:08 install

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: install / name: austin (49b7c5c656cbf9c6f6e5d2ce3bdf4631d1a02acf)

Can you expand some more on what your use case is for this, and also why you excluded enums?

murgatroid99 avatar Aug 17 '22 16:08 murgatroid99

@murgatroid99 I've found that for the majority of my use cases I'm consuming the __Output types, so it'd be nice if the consumer can determine the naming format for inputs vs outputs.

The enum is a special case because it's both a type and a value. Parent messages seem to reference the enum directly.

export interface TestMessage {
  'enum'?: (test_v1_Enum | keyof typeof test_v1_Enum);
}

export interface TestMessage__Output {
  'enum': (keyof typeof test_v1_Enum);
}

It might be worth treating enums like messages in that we create both an input and an output version, and the input/output parent message would point to the corresponding one. I wanted to leave that for a different PR for now.

install avatar Aug 19 '22 16:08 install

Hey @murgatroid99 have you had a chance to look at this? I'm open to any feedback and suggestions :) thanks

install avatar Sep 06 '22 15:09 install

@murgatroid99 Thanks for the feedback! I've addressed your comments and updated the golden tests to use the new flags. Here's the corresponding proposal PR: https://github.com/grpc/proposal/pull/326

install avatar Sep 07 '22 14:09 install

FYI - prefixing interfaces with "I" conflicts with Hungarian notation commonly misused in other parts of the TS ecosystem. Suggest prefixing with "In"/"Out" rather than "I/O"

snarky-puppy avatar Sep 19 '22 01:09 snarky-puppy

FYI - prefixing interfaces with "I" conflicts with Hungarian notation commonly misused in other parts of the TS ecosystem. Suggest prefixing with "In"/"Out" rather than "I/O"

It's just an example. This won't actually change any of the generated type names by default. Nevertheless if @murgatroid99 prefers different values for the golden test I can change it.

install avatar Sep 19 '22 17:09 install

It doesn't matter to me. That test is mainly there to verify the consistency of the generator output.

murgatroid99 avatar Sep 19 '22 17:09 murgatroid99

@murgatroid99 How can I help push this forward?

install avatar Sep 21 '22 13:09 install

Sorry about the delay here.

murgatroid99 avatar Sep 21 '22 17:09 murgatroid99

This is out in version 0.7.3

murgatroid99 avatar Sep 21 '22 18:09 murgatroid99