英文:
Missing-this-annot together with jQuery each()
问题
Here's the translated text:
"jQuery的基本用法似乎不容易在Flow中给出适当的类型?"
jQuery(`.someclass`).each(function(j, el) { ... }
有什么建议吗?我尝试添加/*this: Object*/
之类的东西,但似乎不够。显然,我不能改变像这样的外部库函数中参数的顺序,尽管Flow希望this
始终是第一个参数。
顺便说一下,我已经在文件顶部声明了declare var jQuery: any
。我需要更具体吗?
英文:
Pretty basic usage of jQuery that seems not easy to give a proper type in Flow inline?
jQuery(`.someclass`).each(function(j, el) { ... }
Any tips? I've tried to add /*this: Object*/
or such, but seems not enough. Obviously I cannot change the order of arguments in an external library function like this, even tho Flow wants this
to always be the first argument.
I already have declare var jQuery: any
at top of file, btw. Do I need to be more specific?
答案1
得分: 1
你尝试过利用 flow-typed 吗?jquery 已经在那里有类型定义,并且似乎你正在寻找的 each
函数也在这里 https://github.com/flow-typed/flow-typed/blob/master/definitions/npm/jquery_v3.x.x/flow_v0.104.x-/jquery_v3.x.x.js#L3257
英文:
Have you tried leveraging flow-typed? jquery is already typed there and seems the each
function you're looking for is also there https://github.com/flow-typed/flow-typed/blob/master/definitions/npm/jquery_v3.x.x/flow_v0.104.x-/jquery_v3.x.x.js#L3257
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论