Using Custom Types with Repeated Keyword Doesn't Work
See original GitHub issueBuilding this proto file
syntax = "proto3";
message Car {
string name = 1;
string color = 2;
}
// custom repeated type throws error
message Cars {
repeated Car cars = 1;
}
// primitve type works fine
message List {
repeated string list = 1;
}
throws
/node_modules/typescript/lib/typescript.js:11851
return array.hasOwnProperty("pos") && array.hasOwnProperty("end");
^
TypeError: Cannot read property 'hasOwnProperty' of null
at Object.isNodeArray (/node_modules/typescript/lib/typescript.js:11851:22)
at createNodeArray (/node_modules/typescript/lib/typescript.js:20082:25)
at Object.createCallExpression (/node_modules/typescript/lib/typescript.js:21335:95)
at Object.createCall (/node_modules/typescript/lib/typescript.js:2814:29)
at createToObject (/node_modules/protoc-gen-ts/index.js:49:14)
at createMessage (/node_modules/protoc-gen-ts/index.js:1016:5)
at processMessageDescriptor (/node_modules/protoc-gen-ts/index.js:1545:5)
at processProtoDescriptor (/node_modules/protoc-gen-ts/index.js:1590:12)
at main (/node_modules/protoc-gen-ts/index.js:1680:24)
at Object.<anonymous> (/node_modules/protoc-gen-ts/index.js:1765:1)
I’ve created a repro here: https://github.com/flolu/protoc-gen-ts-repeated-repro
Basically it seems as if custom Types (in this case Car
) doesn’t work with the repeated
keyword.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Why do we have to use the “new” keyword when creating ...
Why do we have to use the “new” keyword when creating custom data types but not with basic data types like float, int,...
Read more >How To Create Custom Types in TypeScript - DigitalOcean
In TypeScript, the syntax for creating custom types is to use the type keyword followed by the type name and then an assignment...
Read more >Documentation - Advanced Types - TypeScript
This page lists some of the more advanced ways in which you can model types, it works in tandem with the Utility Types...
Read more >Making Our Own Types and Typeclasses - Learn You a Haskell
So far, we've run into a lot of data types. Bool, Int, Char, Maybe, etc. But how do we make our own? Well,...
Read more >Types vs. interfaces in TypeScript - LogRocket Blog
We use the type keyword to create a new type alias, ... Declaration merging does not work with types. ... Duplicate identifier Song....
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
I had the same problem. It seems you need to check the build package deploy in npm. When I built and generated locally, I could use it without any problem.
Looks like it fails while generating the typescript files. It could be easily traced IMHO. I’ll take look at it in a few hours after work.