question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Repeated enum results in type error.

See original GitHub issue

Repeated enums result in typescript errors on the generated files. The following proto file:

syntax = "proto3";

enum E {
    One = 0;
    Two = 1;
}

message Test {
    repeated E Enums = 1;
}

Results in the following generated TS:

    get Enums() {
        return pb_1.Message.getFieldWithDefault(this, 1, E.One) as E[];
    }

Which contains the following error:

Conversion of type 'import("/path").E' to type 'E[]' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.ts(2352)

The underlying implementation of it appears to be working fine? it’s just typed incorrectly.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
thesayyncommented, Nov 19, 2022

@thesayyn Thank you so much for merging so quickly! It’d be great if you could push a new release to NPM… I’m now aware of an easy way to use the latest HEAD.

Thanks in advance.

https://www.npmjs.com/package/protoc-gen-ts/v/0.8.6-rc1

0reactions
tsawadacommented, Nov 12, 2022

@thesayyn Thank you so much for merging so quickly! It’d be great if you could push a new release to NPM… I’m now aware of an easy way to use the latest HEAD.

Thanks in advance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Enum with some repeated values? - Stack Overflow
I have an enum which holds certain types together and certain fields for each type. public enum Types { A (1, A.class, "stringA"...
Read more >
Decode unknown enum values · Issue #233 - GitHub
In the current Java and C++ implementations, when unrecognized enum values are stripped out, they are stored along with other unknown fields.
Read more >
Compile time check for duplicate initialized Enum values
I can force an error at runtime using the following code, but I'd prefer there to be a compile time check. enum Testing...
Read more >
Language Guide (proto3) | Protocol Buffers - Google Developers
repeated : this field type can be repeated zero or more times in a well-formed message. The order of the repeated values will...
Read more >
Enum Exception Error - Oracle Communities
I created a class that contains several enums. Each enum has a few methods that contain as part of the method signature 'throws...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found