Giter Site home page Giter Site logo

Event `type` (name string) doesn't get properly checked or suggestions when using addEventListener() on an Union of multiple HTMLElement types about typescript HOT 5 OPEN

LifeJustDLC avatar LifeJustDLC commented on June 3, 2024
Event `type` (name string) doesn't get properly checked or suggestions when using addEventListener() on an Union of multiple HTMLElement types

from typescript.

Comments (5)

fatcerberus avatar fatcerberus commented on June 3, 2024

for the record: this is not a crash

from typescript.

LifeJustDLC avatar LifeJustDLC commented on June 3, 2024

@fatcerberus sorry, I didn't have the time to bisect the versions.

from typescript.

fatcerberus avatar fatcerberus commented on June 3, 2024

No, I just meant that you put

This is a crash

but itโ€™s not - the compiler didnโ€™t crash. Itโ€™s just not doing what you expect

from typescript.

jcalz avatar jcalz commented on June 3, 2024

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)

from typescript.

LifeJustDLC avatar LifeJustDLC commented on June 3, 2024

@jcalz Thanks for your insights.

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.

from typescript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.