Comments (7)
I haven't used ts-proto with babel before, but the compile error you gave links to babel docs which insinuate that turning on allowNamespaces
should make this work. Can you try that?
from ts-proto.
Thanks for u r reply.
Yes I tried to add allowNamespaces
but not work.
But when i change the namespace variable name to StateType
make this work.
from ts-proto.
Hm, yeah, not sure about that from a babel perspective. These enum static methods aren't really public anyway, so I'll change the namespace name, I don't think that would be considered a breaking change.
from ts-proto.
I poked around at a quick fix for this, and there was a little more nuance than I expected. Should still be fixable, just still working on it.
from ts-proto.
Okay, I've fixed this by not actually using the enum
keyword, but instead using a const
object literal that "looks like a enum" + can have the extra "static" toJSON
/fromJSON
methods. Version v.1.14.0 is published and has this fix. Thanks for reporting it!
from ts-proto.
@stephenh is it possible to have the enum type generation as an option?
I'm dynamically generating a form base off of these types and need to know when something is originally an enum
from ts-proto.
@ByronComparisonTech hm. I think I get what you're trying to accomplish, but I don't think the old way with enum
keywords would have worked either?
I.e. if you get something that is just:
const message = Message.decode(...);
// message.state is either (enums) StateEnum.ENABLED i.e. `0` ... or now `0`
I.e. either way the message.state
field is going to have the value 0
and I don't see how you could somehow derive that "this is an enum" / i.e. "what are the other valid enum values" without having the actual protobuf schema around.
from ts-proto.
Related Issues (20)
- I'm using the buf tool to generate a ts file and have set `-ts_proto_opt=esModuleInterop=true`, but the generated code still contains `import Long = require("long");` HOT 1
- Module has already exported a member named 'ServerStreamingMethodResult' HOT 7
- basic_string::_M_construct null not valid HOT 5
- removeEnumPrefix not working HOT 1
- fromJSON should accept both snake_case and camelCase keys HOT 1
- Provide Options type for execution in TS HOT 1
- Add common types to their own file/export w/outputIndex option HOT 2
- Questions about defaults, optionals, arrays, null/undefined HOT 2
- Support `google.api` attributes/conventions HOT 1
- 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 1
- Conflicting protobuf definitions when using ts-proto plugin with Buf HOT 2
- Support for proto-loader "virtual" oneof field
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.