Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Generating map<K, V> on javascript type issue

オープン
#14 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript, nodejs, typescript

調査の方向性

提供された .proto の map フィールドと protoc コマンドから始め、生成された MessageResponse .ts AsObject 宣言を確認します。指定された master/v3.18 および Node.js のセットアップで出力を再現し、生成された map 型とフィールド名が文書化された JavaScript/TypeScript の想定と一致すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug javascript P3 triaged

What version of protobuf and what language are you using?
Version: master/v3.18
Language: Javascript

What operating system (Linux, Windows, ...) and version? Linux

What runtime / compiler are you using (e.g., python version or gcc version) Nodejs

What did you do?
Steps to reproduce the behavior:

  1. Trying to export type map<K, V> so I created a proto file like this:
message MessageResponse {
  string _id = 1;
  string title = 2;
  bool disabled = 3;
  map<string,string> metadata = 4;
}
  1. Converting it using this some commands like this:
protoc -I=/libraries/protos/ /libraries/protos/src/*.proto /libraries/protos/src/**/*.proto --plugin=/libraries/protos/binaries/linux/protoc-gen-grpc-web --js_out=import_style=commonjs,binary:/libraries/protos/build/typescript --grpc-web_out=import_style=typescript,mode=grpcwebtext:/libraries/protos/build/typescript --experimental_allow_proto3_optional
  1. What I am getting on .ts files is something like:
export namespace MessageResponse {
  export type AsObject = {
    id: string,
    title: string,
    disabled: boolean,
    metadataMap: Array<[string, string]>,
  }
}
  1. Well we can see there is a suffix called Map added to my field name! also the generated type is Array<[string, string]>. but what we were expecting, based on language guide here, where an object of {"k": v, …}, like Record<string, V>

What did you expect to see
An object like: Record<string, string>

What did you see instead?
Array<[string, string]>

主要言語
JavaScript
スター
471
フォーク
91
平均マージ
3時間 57分
マージ済み PR(30日)
2

環境構築

このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

protocolbuffers/protobuf-javascript のほかの issue

protocolbuffers/protobuf-javascript の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。