Nested enum types have no name
还没有人认领这个 Issue。
评估
调研方向
首先检查 JSON 协议定义和 emulateTouchFromMouseEvent 中的 inline enum,然后将其与 dispatchMouseEvent 进行比较。确定重复的 enum 形状表示一个命名类型,还是表示相互独立的类型;当 inline enum 具有命名的域定义,并且属性或参数使用引用时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Some domain types/commands/events in the JSON protocol definitions have properties/parameters of enum types that are not references to a top-level domain enum type, but that are instead inlined on the spot. For instance here is one:
...
{
"name": "emulateTouchFromMouseEvent",
"description": "Emulates touch event from the mouse event parameters.",
"experimental": true,
"parameters": [
{
"name": "type",
"description": "Type of the mouse event.",
"type": "string",
"enum": [
"mousePressed",
"mouseReleased",
"mouseMoved",
"mouseWheel"
]
...
I'm generating code from the JSON definitions, but I'm facing 2 problems with this at the moment:
- because these types are not defined at the top level as "domain types", they have no name so I have to either use a plain
Stringtype (which defeats the purpose of the enum) or generate a name (which might not be user-friendly). In the example above, a good name might beMouseEventType. This problem would affect any language that doesn't support string union types (in my case, Kotlin). - some of these enums are implicitily reused across multiple commands/events (the example above appears in
dispatchMouseEventandemulateTouchFromMouseEvent), but there is no way to tell whether they are different types and just happen to have the same enum values (and thus might change independently), or whether they are a single reused type (and thus will evolve together and always stay in sync). This means I cannot choose systematically between declaring different enum types or just one. This problem would affect the same set of languages I believe, basically all those who have to declare enums as a named type.
I haven't found any inlined object type like this (these are only refs), I only found enums suffering from this problem.
It would be great if all enums were extracted into the domain types list and only references appeared in the properties and parameters. Some enums already are defined at the top level, just not all of them.
- 主要语言
- TypeScript
- 星标
- 1.6k
- 派生
- 279
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ChromeDevTools/devtools-protocol 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 35/100
ChromeDevTools/devtools-protocol#311 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 30/100
ChromeDevTools/devtools-protocol#298 · 4 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 35/100
ChromeDevTools/devtools-protocol#233 · 4 条评论 ·
-
Keep track of URL changes可能重新可做 @hashseed 于 2199 天前认领,目前没有进行中的 PR。 未关闭
ChromeDevTools/devtools-protocol#224 · 4 条评论 · 1 个 reaction · 已指派 1 人 ·
查看 ChromeDevTools/devtools-protocol 的全部 Issue
相似的 Issue
-
ADD openalgo未关闭template
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
factory-active factory-automatic task-bug-reproduction-success task-identify-harness-labels-done task-identify-issue-type-done
难度 2/5 1-3 小时 新手友好度 90/100
维护者通常 1 天内回复
-
bug Needs: Triage :mag:
难度 2/5 1-3 小时 新手友好度 84/100
microsoft/fluentui-contrib#671 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
sveltejs/acorn-typescript#150 ·
-
难度 2/5 1-3 小时 新手友好度 78/100