René's URL Explorer Experiment


Title: Suggestion: introduce UniveralElement to eliminate most type assertions in DOM programming (prototype created) · Issue #3304 · microsoft/TypeScript · GitHub

Open Graph Title: Suggestion: introduce UniveralElement to eliminate most type assertions in DOM programming (prototype created) · Issue #3304 · microsoft/TypeScript

X Title: Suggestion: introduce UniveralElement to eliminate most type assertions in DOM programming (prototype created) · Issue #3304 · microsoft/TypeScript

Description: TS heavily relies on type assertion in DOM programming. In my experiences, type assertion is a major factor of produtivity-reduction in font-end TS. There is another user expressed similar concern (#3263). So I try to eliminate most type...

Open Graph Description: TS heavily relies on type assertion in DOM programming. In my experiences, type assertion is a major factor of produtivity-reduction in font-end TS. There is another user expressed similar concern ...

X Description: TS heavily relies on type assertion in DOM programming. In my experiences, type assertion is a major factor of produtivity-reduction in font-end TS. There is another user expressed similar concern ...

Opengraph URL: https://github.com/microsoft/TypeScript/issues/3304

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Suggestion: introduce UniveralElement to eliminate most type assertions in DOM programming (prototype created)","articleBody":"TS heavily relies on type assertion in DOM programming. In my experiences, type assertion is a major factor of produtivity-reduction in font-end TS. There is another user expressed similar concern (#3263).\n\nSo I try to eliminate most type assertions in DOM programming by adding a `UniveralElement` interface to `lib.d.ts`, see [my fork of `lib.es6.d.ts`](https://github.com/duanyao/typescript-fluent-dom).\n\nIn my fork, `querySelector()`, `getElementById()`, `getElementsByClassName()`, `children`, `firstElementChild` etc. return `UniversalElement` or a list of `UniversalElement`, which inherits all known sub interfaces of `Element`; `UIEvent::target` is typed as `UniversalUIEventTarget`, which extends `UniversalElement`, `Document`, and `Window`. So in most case  so you don't have to cast the result before use anymore. Additionally you don't loose the power of type check and autocompletion.\n\nA snapshot of autocompletion using my prototype:\n\n\u003cimg src=\"https://github.com/duanyao/typescript-fluent-dom/raw/master/ts-fluent-snapshot.png\" />\n\nAnd some sample codes:\n\n``` javascript\n/// \u003creference path=\"lib.es6.d.ts\" />\n\nvar ue = document.querySelector('#foo'); // UniversalElement\n// from Element\nvar cls: string = ue.className;\n// from HTMLElement\nue.blur();\n// from HTMLMediaElement\nue.play();\n\n// from HTMLInputElement\nvar files = document.querySelectorAll('input[type=file]')[0].files;\nvar fname = files[0].name;\n\n// from HTMLImageElement\nvar nh = document.body.children[0].naturalHeight;\n\nvar svg = document.getElementsByClassName(\"bar\")[0];\n// from SVGElement\nvar vp = svg.viewportElement;\n// from SVGLineElement\nsvg.x1.baseVal.newValueSpecifiedUnits(1, SVGLength.SVG_LENGTHTYPE_PX);\n\n// type of href from HTMLAnchorElement becomes \"any\" because of type confliction\n// with SVGElements\nvar href = document.querySelector('a').href;\n\n// UIEvent::target is UniversalUIEventTarget, which extends UniversalElement,\n// Document, and Window\ndocument.addEventListener('mousemove', ev => {\n    var targ = ev.target;\n    if (targ.classList.contains('movable')) {\n        targ.style.left = ev.pageX + 'px';\n        targ.style.right = ev.pageX + 'px';\n    }\n});\n```\n\n@NekR and @kitsonk, what do you think?\n","author":{"url":"https://github.com/duanyao","@type":"Person","name":"duanyao"},"datePublished":"2015-05-29T18:13:10Z","url":"https://github.com/microsoft/TypeScript/issues/3304"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:9d3dd9d5-e167-d696-e206-3ab5e8af32c8
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBF4C:2AB944:23C881:2FE8B1:6AFBE254
html-safe-noncee9ef9c6267cbe7a31fa4723c2d6345916569d5676c4f778cda02491ef65f0834
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjRDOjJBQjk0NDoyM0M4ODE6MkZFOEIxOjZBRkJFMjU0IiwidmlzaXRvcl9pZCI6Ijg2OTkxNDE1NTQ3MDQyMTI1NjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacb4ea36f1ad01196cf36f2ba0894e0354757e60c6a66a299abcfbdd1bc14e0158
hovercard-subject-tagissue:82529896
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/3304/issue_layout
twitter:imagehttps://opengraph.githubassets.com/ce40a920e8af793c59f48b33d32b0413cdf158313854c1f540ea25486cde8971/microsoft/TypeScript/issues/3304
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/ce40a920e8af793c59f48b33d32b0413cdf158313854c1f540ea25486cde8971/microsoft/TypeScript/issues/3304
og:image:altTS heavily relies on type assertion in DOM programming. In my experiences, type assertion is a major factor of produtivity-reduction in font-end TS. There is another user expressed similar concern ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameduanyao
hostnamegithub.com
expected-hostnamegithub.com
None744d4381b1c4dbd6d8736c7d7e5bbe7dc11217584e457a3555020c631764e8ec
turbo-cache-controlno-preview
go-importgithub.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id20929025
octolytics-dimension-repository_nwomicrosoft/TypeScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id20929025
octolytics-dimension-repository_network_root_nwomicrosoft/TypeScript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasedf859c48a4c8b4c0009c19bb4e82101aacb4b998
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/3304#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F3304
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F3304
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoft%2FTypeScript
Reloadhttps://github.com/microsoft/TypeScript/issues/3304
Reloadhttps://github.com/microsoft/TypeScript/issues/3304
Reloadhttps://github.com/microsoft/TypeScript/issues/3304
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests334 (334)https://github.com/microsoft/TypeScript/pulls
Actionshttps://github.com/microsoft/TypeScript/actions
Projectshttps://github.com/microsoft/TypeScript/projects
Wikihttps://github.com/microsoft/TypeScript/wiki
Security and qualityhttps://github.com/microsoft/TypeScript/security
Insightshttps://github.com/microsoft/TypeScript/pulse
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/3304
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/3304
Suggestion: introduce UniveralElement to eliminate most type assertions in DOM programming (prototype created)https://github.com/microsoft/TypeScript/issues/3304#top
DeclinedThe issue was declined as something which matches the TypeScript visionhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Declined%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
https://github.com/duanyao
Duan Yao (duanyao)https://github.com/duanyao
on May 29, 2015https://github.com/microsoft/TypeScript/issues/3304#issue-82529896
#3263https://github.com/microsoft/TypeScript/issues/3263
my fork of lib.es6.d.tshttps://github.com/duanyao/typescript-fluent-dom
https://github.com/duanyao/typescript-fluent-dom/raw/master/ts-fluent-snapshot.png
Arthur Stolyar (@NekR)https://github.com/NekR
Kitson Kelly (@kitsonk)https://github.com/kitsonk
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on May 29, 2015https://github.com/microsoft/TypeScript/issues/3304#issuecomment-106909872
https://github.com/duanyao
Duan Yao (duanyao)https://github.com/duanyao
on May 30, 2015https://github.com/microsoft/TypeScript/issues/3304#issuecomment-106969510
https://github.com/jeffreymorlan
jeffreymorlanhttps://github.com/jeffreymorlan
on May 30, 2015https://github.com/microsoft/TypeScript/issues/3304#issuecomment-106969847
https://github.com/duanyao
Duan Yao (duanyao)https://github.com/duanyao
on May 30, 2015https://github.com/microsoft/TypeScript/issues/3304#issuecomment-106971035
https://github.com/NekR
Arthur Stolyar (NekR)https://github.com/NekR
on May 30, 2015https://github.com/microsoft/TypeScript/issues/3304#issuecomment-107015962
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Jun 10, 2015https://github.com/microsoft/TypeScript/issues/3304#issuecomment-110547924
#3304 (comment)https://github.com/microsoft/TypeScript/issues/3304#issuecomment-106909872
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jun 10, 2015https://github.com/microsoft/TypeScript/issues/3304#event-326913795
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
DeclinedThe issue was declined as something which matches the TypeScript visionhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Declined%22
on Jun 10, 2015https://github.com/microsoft/TypeScript/issues/3304#event-326913859
https://github.com/duanyao
Duan Yao (duanyao)https://github.com/duanyao
on Jun 10, 2015https://github.com/microsoft/TypeScript/issues/3304#issuecomment-110559029
Mohamed Hegazy (@mhegazy)https://github.com/mhegazy
#3304 (comment)https://github.com/microsoft/TypeScript/issues/3304#issuecomment-106969510
https://github.com/NoelAbrahams
Noel Abrahams (NoelAbrahams)https://github.com/NoelAbrahams
on Jun 10, 2015https://github.com/microsoft/TypeScript/issues/3304#issuecomment-110596544
Duan Yao (@duanyao)https://github.com/duanyao
jeffreymorlanhttps://github.com/jeffreymorlan
https://github.com/duanyao
Duan Yao (duanyao)https://github.com/duanyao
on Jun 10, 2015https://github.com/microsoft/TypeScript/issues/3304#issuecomment-110613027
Noel Abrahams (@NoelAbrahams)https://github.com/NoelAbrahams
https://github.com/NoelAbrahams
Noel Abrahams (NoelAbrahams)https://github.com/NoelAbrahams
on Jun 10, 2015https://github.com/microsoft/TypeScript/issues/3304#issuecomment-110712937
https://github.com/duanyao
Duan Yao (duanyao)https://github.com/duanyao
on Jun 10, 2015https://github.com/microsoft/TypeScript/issues/3304#issuecomment-110765638
Noel Abrahams (@NoelAbrahams)https://github.com/NoelAbrahams
microsofthttps://github.com/microsoft
on Jun 19, 2018https://github.com/microsoft/TypeScript/issues/3304#event-1689600216
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/3304
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/3304
DeclinedThe issue was declined as something which matches the TypeScript visionhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Declined%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.