-
-
Notifications
You must be signed in to change notification settings - Fork 80
Description
What happened?
I am using ts_proto_library from rules_ts to generate TypeScript definitions from my .proto files. However, I noticed that fields defined in snake_case in the .proto files are automatically converted to camelCase in the generated .d.ts files.
For example, given this .proto definition:
message Example {
string example_field = 1;
}The generated TypeScript definition is:
interface Example {
exampleField: string;
}This automatic conversion is not always desirable, especially when working with APIs that expect snake_case field names.
Currently, rules_ts does not provide an option to disable this conversion. Many users of ts-proto rely on the snakeToCamel option (--ts_proto_opt=snakeToCamel=false) to keep the generated TypeScript field names consistent with their .proto definitions. However, ts_proto_library in rules_ts does not expose a way to pass this option.
Version
Development (host) and target OS/architectures:
Output of bazel --version: aspect oss 2024.45.21-2252fc6 (with local changes)
Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:
Language(s) and/or frameworks involved: TypeScript
How to reproduce
1. Define a .proto file with snake_case field names.
2. Use ts_proto_library from rules_ts to generate TypeScript definitions.
3. Observe that the generated TypeScript uses camelCase instead of snake_case.Any other information?
Would it be possible to expose an option in ts_proto_library to control this behavior? Specifically, allowing users to pass --ts_proto_opt=snakeToCamel=false to protoc-gen-ts_proto would make it more flexible.
This feature would help teams that want to maintain consistency between .proto field names and the generated TypeScript types, avoiding unexpected naming mismatches.
Let me know if you need any additional details! Thanks for maintaining rules_ts! 🚀