我有一个Button函数,它接受一些参数(名称,标签,onClick)。我可以将Button!type设置为fn(name: string, label: string, onClick: fn())
,但实际上应该类似于fn(config: {name: string, label: string, onClick: fn()})
。问题是,当我尝试第二个示例时,出现错误Unrecognized type spec
。是否有正确的方法将键指定为函数参数的对象?
仅在某些情况下,我正在为Brackets使用一个名为Ternific的自动完成插件。插件没有问题,仅与我的配置有关。
这是我的.turn-project文件,该文件引发错误:(滚动到底部以查看Button)
{
"!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."
}
}