Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Nested enum types have no name

未关闭
#244 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
kotlin
领域
api

调研方向

首先检查 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:

  1. 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 String type (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 be MouseEventType. This problem would affect any language that doesn't support string union types (in my case, Kotlin).
  2. some of these enums are implicitily reused across multiple commands/events (the example above appears in dispatchMouseEvent and emulateTouchFromMouseEvent), 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,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ChromeDevTools/devtools-protocol 的其他 Issue

查看 ChromeDevTools/devtools-protocol 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。