1

我有一个接受一些参数(名称、标签、onClick)的按钮函数。我可以将 Button !type 设置为fn(name: string, label: string, onClick: fn()),但实际上它应该是fn(config: {name: string, label: string, onClick: fn()}). 问题是当我尝试第二个示例时出现错误Unrecognized type spec。是否有正确的方法来指定带有键的对象作为函数参数?

只是在某些情况下,我正在使用一个名为 Ternific 的 Brackets 自动完成插件。插件没有问题,只是我的配置。

这是我的 .turn-project 文件,它抛出了错误:(滚动到底部查看按钮)

{
  "!name": "mb-core",
  "ComponentOfType": {
    "InteractiveValidated": {
        "prototype": {
          "enable": {
            "!type": "fn()",
            "!doc": "Enable component."
          },
          "disable": {
            "!type": "fn()",
            "!doc": "Disable component."
          },
          "isFilledOut": {
            "!type": "fn() -> boolean",
            "!doc": "Check if component's is filled out."
          },
          "isCorrect": {
            "!type": "fn() -> boolean",
            "!doc": "Check if component's value is correct."
          },
          "value": {
            "!type": "fn()",
            "!doc": "Get components value."
          },
          "reset": {
            "!type": "fn()",
            "!doc": "Reset component."
          },
          "show": {
            "!type": "fn()",
            "!doc": "Show component."
          },
          "hide": {
            "!type": "fn()",
            "!doc": "Hide component."
          }
        }
    }
  },
  "Button": {
    "!type": "fn(config: {name: string, label: string, onClick: fn()}) -> +ComponentType.InteractiveValidated",
    "!url": "https://docs.mathbrainius.com/problem-development/shared-components#button",
    "!doc": "Creates a button."
  }
}
4

0 回答 0