Generating map<K, V> on javascript type issue
还没有人认领这个 Issue。
评估
- 难度
- 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 内容生成。
描述
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:
- Trying to export type
map<K, V>so I created aprotofile like this:
message MessageResponse {
string _id = 1;
string title = 2;
bool disabled = 3;
map<string,string> metadata = 4;
}
- 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
- What I am getting on
.tsfiles is something like:
export namespace MessageResponse {
export type AsObject = {
id: string,
title: string,
disabled: boolean,
metadataMap: Array<[string, string]>,
}
}
- Well we can see there is a suffix called
Mapadded to my field name! also the generated type isArray<[string, string]>. but what we were expecting, based on language guide here, where an object of{"k": v, …}, likeRecord<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
- 平均合并
- 1 天 12 小时
- 30 天内合并 PR
- 6
环境准备
我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
protocolbuffers/protobuf-javascript 的其他 Issue
-
难度 5/5 一周以上 新手友好度 25/100
-
难度 5/5 一周以上 新手友好度 30/100
protocolbuffers/protobuf-javascript#248 · 1 条评论 · 13 个 reaction ·
-
question
难度 3/5 1-2 天 新手友好度 45/100
protocolbuffers/protobuf-javascript#222 · 9 条评论 ·
-
enhancement port-fix triaged
难度 4/5 3-5 天 新手友好度 35/100
protocolbuffers/protobuf-javascript#185 · 1 条评论 ·
-
enhancement port-fix triaged
难度 4/5 3-5 天 新手友好度 35/100
protocolbuffers/protobuf-javascript#182 · 3 条评论 · 1 个 reaction ·
查看 protocolbuffers/protobuf-javascript 的全部 Issue
相似的 Issue
-
Complexity: Small P-Feature: Projects page ready for merge team role: back end/devOps role: front end size: 0.25pt
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 67/100
bellingcat/toolkit#905 ·
-
self-care self-care:docs-build-time-investigator
难度 2/5 半天 新手友好度 76/100
githubnext/gh-aw-cao#14191 ·
维护者通常 1 天内回复
-
effort:low impact:medium RAG status: auto-triaged
难度 2/5 1-3 小时 新手友好度 84/100
mastra-ai/mastra#25229 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
sugarlabs/musicblocks#8984 ·
维护者通常 1 天内回复