Repeated enum results in type error.
See original GitHub issueRepeated 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:
- Created a year ago
- Comments:7 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://www.npmjs.com/package/protoc-gen-ts/v/0.8.6-rc1
@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.