You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeDivOrSpan=HTMLDivElement|HTMLSpanElementconstdivOrSpan=document.querySelector<DivOrSpan>(".could-be-div-or-span")!divOrSpan.addEventListener("typo",()=>{})// neither complain or suggest when first typingconstdiv=document.querySelector<HTMLDivElement>(".div")!div.addEventListener("click",()=>{})// doesn't complain either but get suggestions automatically as well as pressing ctrl+i
π Actual behavior
first one neither complain or suggest when first typing.
π Expected behavior
get suggestions automatically as well as pressing ctrl+i like the second one.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
I suspect this is just a caveat of #29011, you're calling a union of overloaded and generic methods. Feels like a design limitation to me (just a nosy bystander and not a TS team member)
The caveats are that only one type in the list of union members is allowed to have overloads, and only one type within the list of union members is allowed to have type parameters.
I didn't fully understand that post, but I think it's a little different:
As @weswigham described, and as I understand, it will at least get an intersected signature (suggestion) between A and B? which is "2" in the above case. but in the similar case of HTMLDivElement and HTMLSpanElement, this seems doesn't work.
π Search Terms
"event type", "addEventListener", "suggestion"
π Version & Regression Information
β― Playground Link
No response
π» Code
π Actual behavior
first one neither complain or suggest when first typing.
π Expected behavior
get suggestions automatically as well as pressing
ctrl+i
like the second one.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: