Skip to content

Event type (name string) doesn't get properly checked or suggestions when using addEventListener() on an Union of multiple HTMLElement typesΒ #58497

Closed as not planned
@LifeJustDLC

Description

@LifeJustDLC

πŸ”Ž Search Terms

"event type", "addEventListener", "suggestion"

πŸ•— Version & Regression Information

  • This is a crash

⏯ Playground Link

No response

πŸ’» Code

type DivOrSpan = HTMLDivElement | HTMLSpanElement
const divOrSpan = document.querySelector<DivOrSpan>(".could-be-div-or-span")!
divOrSpan.addEventListener("typo", () => {}) // neither complain or suggest when first typing

const div = 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions