javascript - Tern 函数参数:如何用键指定对象?
问题描述
我有一个接受一些参数(名称、标签、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."
}
}
解决方案
推荐阅读
- python - 为什么我在 Kivymd 中的 rgb 颜色看起来与真实颜色不同?
- python - 将 Std Err 设置为 tkinter 中的消息框
- javascript - 如何在 React 中让测验的提示像一个刽子手游戏
- css - CSS 样式,100%/100vh 不会覆盖通过视图高度
- r - 定义 grid.arrange() 使第三个图在中间?
- javascript - 类型错误:无法读取 null 的“用户”属性
- c# - 在 C# 中静音麦克风
- jenkins - jenkins允许逗号分隔的值一个一个传递来生成job dsl
- android - 如何在我启动应用程序时显示 Intent 而不是主 Activity
- javascript - 如何为参数 [word] 的长度创建返回语句?