Title: Event `type` (name string) doesn't get properly checked or suggestions when using addEventListener() on an Union of multiple HTMLElement types · Issue #58497 · microsoft/TypeScript · GitHub
Open Graph Title: Event `type` (name string) doesn't get properly checked or suggestions when using addEventListener() on an Union of multiple HTMLElement types · Issue #58497 · microsoft/TypeScript
X Title: Event `type` (name string) doesn't get properly checked or suggestions when using addEventListener() on an Union of multiple HTMLElement types · Issue #58497 · microsoft/TypeScript
Description: 🔎 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.querySelec...
Open Graph Description: 🔎 Search Terms "event type", "addEventListener", "suggestion" 🕗 Version & Regression Information This is a crash ⏯ Playground Link No response 💻 Code type DivOrSpan = HTMLDivElement | HTMLSpanEleme...
X Description: 🔎 Search Terms "event type", "addEventListener", "suggestion" 🕗 Version & Regression Information This is a crash ⏯ Playground Link No response 💻 Code type DivOrSpa...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/58497
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Event `type` (name string) doesn't get properly checked or suggestions when using addEventListener() on an Union of multiple HTMLElement types","articleBody":"### 🔎 Search Terms\r\n\r\n\"event type\", \"addEventListener\", \"suggestion\"\r\n\r\n### 🕗 Version & Regression Information\r\n\r\n- This is a crash\r\n\r\n\r\n### ⏯ Playground Link\r\n\r\n_No response_\r\n\r\n### 💻 Code\r\n\r\n```typescript\r\ntype DivOrSpan = HTMLDivElement | HTMLSpanElement\r\nconst divOrSpan = document.querySelector\u003cDivOrSpan>(\".could-be-div-or-span\")!\r\ndivOrSpan.addEventListener(\"typo\", () => {}) // neither complain or suggest when first typing\r\n\r\nconst div = document.querySelector\u003cHTMLDivElement>(\".div\")!\r\ndiv.addEventListener(\"click\", () => {}) // doesn't complain either but get suggestions automatically as well as pressing ctrl+i\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nfirst one neither complain or suggest when first typing.\r\n\r\n### 🙂 Expected behavior\r\n\r\nget suggestions automatically as well as pressing `ctrl+i` like the second one.\r\n\r\n### Additional information about the issue\r\n\r\n_No response_","author":{"url":"https://github.com/LifeJustDLC","@type":"Person","name":"LifeJustDLC"},"datePublished":"2024-05-10T22:36:04Z","url":"https://github.com/microsoft/TypeScript/issues/58497"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8f4164b5-ae30-efbe-9429-ad5019612bac |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C42A:842EC:738A66:9C216D:6B00DC6D |
| html-safe-nonce | dd32d941506d82f1c460c6f25b5adcaeca801d5dabdab2d241b664a3640131d0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNDJBOjg0MkVDOjczOEE2Njo5QzIxNkQ6NkIwMERDNkQiLCJ2aXNpdG9yX2lkIjoiNDk0MjY4MDg3ODkzNDQ0OTI2MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 58b8f38d9c0b850e70973e3ec9b59a129c57b8c2e58a2f37ea20004711717394 |
| hovercard-subject-tag | issue:2290490594 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/58497/issue_layout |
| twitter:image | https://opengraph.githubassets.com/431e80998644e38786f0b69683cb89253c779bf9f3c745a730e94405a1b5c528/microsoft/TypeScript/issues/58497 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/431e80998644e38786f0b69683cb89253c779bf9f3c745a730e94405a1b5c528/microsoft/TypeScript/issues/58497 |
| og:image:alt | 🔎 Search Terms "event type", "addEventListener", "suggestion" 🕗 Version & Regression Information This is a crash ⏯ Playground Link No response 💻 Code type DivOrSpan = HTMLDivElement | HTMLSpanEleme... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LifeJustDLC |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width