GithubHelp home page GithubHelp logo

Comments (7)

stephenh avatar stephenh commented on May 22, 2024

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.

hrb-bacigalupo-diego avatar hrb-bacigalupo-diego commented on May 22, 2024

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.

stephenh avatar stephenh commented on May 22, 2024

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.

stephenh avatar stephenh commented on May 22, 2024

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.

stephenh avatar stephenh commented on May 22, 2024

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.

ByronComparisonTech avatar ByronComparisonTech commented on May 22, 2024

@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.

stephenh avatar stephenh commented on May 22, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.