Comments (7)
I believe #1052 is a good approach, and at least fixes all current test cases 😅 , I went ahead and merged the fix, let us know if there are other exceptions. 🤞
from ts-proto.
Same problema here. This is a breaking change that is given us a lot of problems.
from ts-proto.
Hey guys, thanks for the report! Hopefully it won't be too bad to craft a regex that achieves both goals--I'll take a look at this in a few days/next weekend, unless @BrandonArmand you can take a look/beat me to it. Thanks!
from ts-proto.
Hey yeah i actually noticed this today as well. I will be happy to whip up some regex.
from ts-proto.
Thanks.
I think, the original cause was two-fold:
- the consecutive capital letters were not being treated as independent words.
- metacharacter
\w
contains capital letters.
For 1.
Consider a series of uppercase letters as a word, and consider that they can be separated by one before they change to lowercase letters.
For 2.
Use [a-z0-9]
insted of \w
.
So, I came up with the following regular expression.
export function camelToSnake(s: string): string {
return s.replace(/(?<!^)([a-z0-9][A-Z]|([A-Z][A-Z])[a-z0-9])/g, (m) => m.length === 2 ? m[0] + "_" + m[1] : m[0] + "_" + m[1] + m[2]).toUpperCase();
}
// getAPIValueV1Beta1 => GET_API_VALUE_V1_BETA1
I have passed the test case, but I feel it is not very elegant.
If you have any good ideas, please let me know.
from ts-proto.
🎉 This issue has been resolved in version 1.176.2 🎉
The release is available on:
Your semantic-release bot 📦🚀
from ts-proto.
@stephenh Thank you so much for the fix !
from ts-proto.
Related Issues (20)
- NestJS without Observables HOT 1
- meta generated for messages with oneOf properties is incorret for other properties HOT 1
- Add types for toJSON/fromJSON methods HOT 1
- TypeError on Runtime ChannelCredentials object HOT 1
- Using 'useDate=string' parameter; the response is still anticipating an object for Timestamp Wrapper
- Encode crashes on `null` object values HOT 2
- Rpc doesn't account for metadata HOT 2
- Rpc is not exported by ts-proto as it previously was HOT 6
- Generated affixes HOT 5
- Conflicting protobuf definitions when using ts-proto plugin with Buf HOT 2
- Support for proto-loader "virtual" oneof field
- Release updated ts-proto-descriptors? HOT 4
- Proto import statements not being recognized HOT 1
- Support for messages with the same name as an rpc method HOT 2
- Typescript as peerDependency HOT 3
- Easier to use oneof=union generated code HOT 1
- Support default instances on singular/required fields HOT 6
- Option to include generated type registry in exports HOT 5
- Consider switching many types to interfaces HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ts-proto.