Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Repeated enum invalid TypeScript, TS1011 error #1

Open
leeola opened this issue Nov 20, 2018 · 1 comment
Open

Repeated enum invalid TypeScript, TS1011 error #1

leeola opened this issue Nov 20, 2018 · 1 comment

Comments

@leeola
Copy link

leeola commented Nov 20, 2018

In the following example:

syntax = "proto3";

message SearchRequest {
  string query = 1;
  int32 page_number = 2;
  int32 result_per_page = 3;
  enum Corpus {
    UNIVERSAL = 0;
    WEB = 1;
    IMAGES = 2;
    LOCAL = 3;
    NEWS = 4;
    PRODUCTS = 5;
    VIDEO = 6;
  }
  repeated Corpus corpuses = 4;
}

message Result {
  string title = 1;
}

message SearchResponse {
  repeated Result result = 1;
}

service SearchService {
  rpc Search (SearchRequest) returns (SearchResponse);
}

The repeated Corpus corpuses = 4; produces a typescript line of return (<any>Corpus[])[this._json.corpuses!], which causes a failure of:

output/example_003.ts:78:25 - error TS1011: An element access expression should take an argument.

78     return (<any>Corpus[])[this._json.corpuses!]

I'm not too familiar with TypeScript syntax here, but the bug should be fairly easy to reproduce. Thoughts?

@yash2code
Copy link

same issue

ccpost added a commit to ccpost/protoc-gen-twirp_ts that referenced this issue Jul 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants