wechat-miniprogram / wechat-miniprogram/api-typings
[Bug]selectAll和select两个选择器的返回值应该是不一样的
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 803
- Forks
- 117
- Avg merge
- 24m
- Merged PRs (30d)
- 1
Description
环境
- api-typings 版本:3.3.2
- 系统版本:macos 10.14.6
- ide: vscode 1.57.0
问题
在使用 selectAll时,boundingClientRect cb 里面的 results 是个对象,而不是数组。
wx.createSelectorQuery().selectAll('.a-class').boundingClientRect(function(rects){
rects // d.ts 内是个对象而不是数组
}).exec()
证明它是个问题
根据小程序文档可知:
wx.createSelectorQuery().select.boundingClientRect(cb)
和
wx.createSelectorQuery().selectAll.boundingClientRect(cb)
内的cb类型实际上是不同的。
前者内的 cb 类型类似这样
(result: BoundingClientRectCallbackResult) => void
而后者的cb类型应该是这样
(results: BoundingClientRectCallbackResult[]) => void
但是在 lib.wx.api.d.ts中,返回的都是 NodesRef 类型,没有区分对象和集合
select(
/** 选择器 */
selector: string
): NodesRef
selectAll(
/** 选择器 */
selector: string
): NodesRef
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib.wx.api.d.ts at the select and selectAll declarations and inspect the NodesRef type, especially boundingClientRect callback definitions. Update the declarations so select uses a single BoundingClientRectCallbackResult while selectAll uses an array, then verify the generated TypeScript types distinguish both callbacks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100