sindresorhus/element-ready

Use types directly from querySelector, without copying them

開放

#32 建立於 2020年12月29日

 (0 則留言) (2 個反應) (0 位負責人)JavaScript (17 個分叉)user submission
enhancementhelp wanted

倉庫指標

星標
 (447 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

If the selector is 'a', querySelector‘s return type is be HTMLAnchorElement. To achieve the same in element-ready, we had to manually copy its types and adapt them to elementReady

Ideally, instead, we should try to “inherit” directly from the global querySelector so that, if its types are enhanced (via typed-query-selector or natively), element-ready automatically gets upgraded.

Note: We can't use Parameters<typeof querySelector> and such because it doesn't support overloads nor generics.

This has been unsuccessfully tried in #31. More info about it in that PR. A possible solution might be https://github.com/microsoft/TypeScript/issues/33185#issuecomment-526969274

貢獻者指南