Missing-this-annot 与 jQuery each() 一起使用

huangapple go评论47阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年6月8日 23:06:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76433269.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定