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

Add support for reserved message names. #1110

Open
halkeye opened this issue Sep 27, 2024 · 2 comments
Open

Add support for reserved message names. #1110

halkeye opened this issue Sep 27, 2024 · 2 comments

Comments

@halkeye
Copy link

halkeye commented Sep 27, 2024

// Function notification settings
message Function {
    string namespace = 1;
    string name = 2;
}

Generates a file that typescript is unable to process (for good reason)

 error TS2345: Argument of type 'Function | {}' is not assignable to parameter of type 'Function'.
  Type '{}' is missing the following properties from type 'Function': namespace, name

I know i can use --ts_proto_opt=typePrefix=MyPrefix or --ts_proto_opt=typeSuffix=MySuffix to add extra to each type, but that would do it for everything, not just reserved words, which would make migrated to generated output a little rougher.

Is there anything I can do to handle the reserved ones? I am up for contributing.

message Object {
  string key = 1;
}

Is another example.

@stephenh
Copy link
Owner

Hi @halkeye ! That makes sense...kinda surprised we haven't ran into this before 🤔

Ah yeah, I think it's here:

const builtInNames = ["Date"];

Maybe just add Function to that builtinNames?

A PR would be great! Thanks!

@halkeye
Copy link
Author

halkeye commented Sep 27, 2024

I'm going to get you a pr soon, but so i don't forget it, https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects is probably some others that might be worth grabbing a few from

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

2 participants