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.

Using Custom Types with Repeated Keyword Doesn't Work

See original GitHub issue

Building 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:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
JoowonYuncommented, Dec 14, 2020

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.

1reaction
thesayyncommented, Oct 1, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

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