René's URL Explorer Experiment


Title: Expose global declarations on `window` · Issue #19816 · microsoft/TypeScript · GitHub

Open Graph Title: Expose global declarations on `window` · Issue #19816 · microsoft/TypeScript

X Title: Expose global declarations on `window` · Issue #19816 · microsoft/TypeScript

Description: Window in a web page serves a dual purpose. it implements the Window interface representing the web page main view, but also acts as an alias to the global namespace. All global variables are accessible on the window object at run-time; ...

Open Graph Description: Window in a web page serves a dual purpose. it implements the Window interface representing the web page main view, but also acts as an alias to the global namespace. All global variables are acces...

X Description: Window in a web page serves a dual purpose. it implements the Window interface representing the web page main view, but also acts as an alias to the global namespace. All global variables are acces...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Expose global declarations on `window`","articleBody":"[Window](https://developer.mozilla.org/en-US/docs/Web/API/Window) in a web page serves a dual purpose. it implements the `Window` interface representing the web page main view, but also acts as an alias to the global namespace. All global variables are accessible on the `window` object at run-time; this applies to builtin JS declarations like `Array`, `Math`, `JSON`, `Intl` as well as global DOM declarations like `HTMLElement`, `Event`, `HTMLCollection`, etc...\r\n\r\nTypeScript today does not model this behavior. For instance `window.Math` is not defined, so is all the `HTMLElement` family of declarations.\r\n\r\nMost of the patterns `window` is used to access global declarations are anti-patterns (see a [good article about window usage](http://2ality.com/2013/09/window.html)), the main exception is testing for API existence, e.g.: `if (window.MutationObserver) { ... }`. There is not really a legal way to do this out-of-the-box in TS today.\r\n\r\nOur recommendation has been to manually add a declaration for the global object on `Window`, e.g.:\r\n\r\n```ts\r\ndeclare global {\r\n    interface Window {\r\n        MutationObserver?: typeof MutationObserver;\r\n   }\r\n}\r\n``` \r\n\r\nThis is a. inconvenient and b. not easy to find if you are new to TS. Here is a list of issues we have so far related to this issue:\r\n* #8866 `window.Blob`\r\n* #14402 `window.createImageBitmap`\r\n* #9325 `window.Math`\r\n* #3753 `window.URL`\r\n* #11305 `window.MutationObserver`\r\n* #18756 `window.PointerEvent`\r\n* #19758 `window.MouseEvent`\r\n* #23886 `window.Element`\r\n* #25651 `window.PerformanceObserver`\r\n\r\nIt is also worth noting that the same problem occurs with [`self` in web workers](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/self) and [`global` for node](https://nodejs.org/api/globals.html#globals_global)\r\n\r\n\r\nPossible options here:\r\n1. support a global type (tracked by #14052), and allow `Window` to extend from it. \r\n2. generate lib.d.ts with **all** global declarations mirrored on `Window`.\r\n","author":{"url":"https://github.com/mhegazy","@type":"Person","name":"mhegazy"},"datePublished":"2017-11-07T18:52:38Z","url":"https://github.com/microsoft/TypeScript/issues/19816"}

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:f1fcbd4c-2d93-a8b4-a971-c425941a5405
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE080:17FB7:1FFE73D:2892B57:6B01A6FE
html-safe-nonceefa781cebe5499bc013169e63001096f189657a854cd357cccadfb99dad7e887
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDgwOjE3RkI3OjFGRkU3M0Q6Mjg5MkI1Nzo2QjAxQTZGRSIsInZpc2l0b3JfaWQiOiI2NDEyMDE5NjI5MzI5MzI3ODcwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacdcfab67132c30a0b1d8909231016b22203dc410d387666204f70b233aaefc757
hovercard-subject-tagissue:271943087
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/19816/issue_layout
twitter:imagehttps://opengraph.githubassets.com/87e6eb939bc80e8abfa4d83a0550a8139637277cfa703b0a5ee1ffc838f96e42/microsoft/TypeScript/issues/19816
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/87e6eb939bc80e8abfa4d83a0550a8139637277cfa703b0a5ee1ffc838f96e42/microsoft/TypeScript/issues/19816
og:image:altWindow in a web page serves a dual purpose. it implements the Window interface representing the web page main view, but also acts as an alias to the global namespace. All global variables are acces...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemhegazy
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetcanary-1
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/19816#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F19816
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%2F19816
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/19816
Reloadhttps://github.com/microsoft/TypeScript/issues/19816
Reloadhttps://github.com/microsoft/TypeScript/issues/19816
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests312 (312)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/insights
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/19816
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/19816
microsoft/TypeScript-DOM-lib-generator#715https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/715
Expose global declarations on windowhttps://github.com/microsoft/TypeScript/issues/19816#top
microsoft/TypeScript-DOM-lib-generator#715https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/715
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Nov 7, 2017https://github.com/microsoft/TypeScript/issues/19816#issue-271943087
Windowhttps://developer.mozilla.org/en-US/docs/Web/API/Window
good article about window usagehttp://2ality.com/2013/09/window.html
Blob property is missing on Window interface #8866https://github.com/microsoft/TypeScript/issues/8866
ImageBitmap interface missing #14402https://github.com/microsoft/TypeScript/issues/14402
Property Math is missing on Window interface #9325https://github.com/microsoft/TypeScript/issues/9325
URL is missing from Window interface #3753https://github.com/microsoft/TypeScript/issues/3753
MutationObserver API declarations missing #11305https://github.com/microsoft/TypeScript/issues/11305
window.PointerEvent is undefined #18756https://github.com/microsoft/TypeScript/issues/18756
Event types do not exist in the Window interface #19758https://github.com/microsoft/TypeScript/issues/19758
window.Element is a stable API, but is not included in the interface Window(lib.d.ts:19060). #23886https://github.com/microsoft/TypeScript/issues/23886
Add typings for PerformanceObserver #25651https://github.com/microsoft/TypeScript/issues/25651
self in web workershttps://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/self
global for nodehttps://nodejs.org/api/globals.html#globals_global
Access global as a type #14052https://github.com/microsoft/TypeScript/issues/14052
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%22
on Nov 7, 2017https://github.com/microsoft/TypeScript/issues/19816#event-1330359431
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Nov 7, 2017https://github.com/microsoft/TypeScript/issues/19816#event-1330361126
https://github.com/yortus
Troy Gerwien (yortus)https://github.com/yortus
on Nov 8, 2017https://github.com/microsoft/TypeScript/issues/19816#issuecomment-342725403
#10050 (comment)https://github.com/microsoft/TypeScript/issues/10050#issuecomment-236596782
KevinSnyderCodeshttps://github.com/KevinSnyderCodes
on Nov 8, 2017https://github.com/microsoft/TypeScript/issues/19816#event-1331239651
Fix DefinitelyTyped#21235: add global types to DOMWindow interfacehttps://github.com/KevinSnyderCodes/DefinitelyTyped/commit/d6ac21e95f12e3617e92176258d523bba910aa0a
DefinitelyTyped#21235https://github.com/DefinitelyTyped/DefinitelyTyped/issues/21235
d6ac21ehttps://github.com/KevinSnyderCodes/DefinitelyTyped/commit/d6ac21e95f12e3617e92176258d523bba910aa0a
Fix DefinitelyTyped#21235: add global types to DOMWindow interfacehttps://github.com/KevinSnyderCodes/DefinitelyTyped/commit/557e9ce971f8558a6d3bcb7f5767ccdd2b4bae3b
DefinitelyTyped#21235https://github.com/DefinitelyTyped/DefinitelyTyped/issues/21235
557e9cehttps://github.com/KevinSnyderCodes/DefinitelyTyped/commit/557e9ce971f8558a6d3bcb7f5767ccdd2b4bae3b
https://github.com/michahell
Michael Trouw (michahell)https://github.com/michahell
on Apr 9, 2018https://github.com/microsoft/TypeScript/issues/19816#issuecomment-379720941
https://github.com/HolgerJeromin
Holger Jeromin (HolgerJeromin)https://github.com/HolgerJeromin
on Jul 23, 2018https://github.com/microsoft/TypeScript/issues/19816#issuecomment-407019820
different contextshttps://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/instanceof
https://github.com/mpawelski
Mariusz Pawelski (mpawelski)https://github.com/mpawelski
on Apr 11, 2019https://github.com/microsoft/TypeScript/issues/19816#issuecomment-482358680
#29332https://github.com/microsoft/TypeScript/pull/29332
globalThis PRhttps://github.com/Microsoft/TypeScript/pull/29332
Nathan Shively-Sanders (@sandersn)https://github.com/sandersn
https://github.com/sandersn
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
on Apr 15, 2019https://github.com/microsoft/TypeScript/issues/19816#issuecomment-483317875
Mariusz Pawelski (@mpawelski)https://github.com/mpawelski
https://github.com/thomaLV
thomaLVhttps://github.com/thomaLV
on May 30, 2019https://github.com/microsoft/TypeScript/issues/19816#issuecomment-497436255
https://github.com/maksnester
Maksim Nesterenko (maksnester)https://github.com/maksnester
on Jul 5, 2019https://github.com/microsoft/TypeScript/issues/19816#issuecomment-508705611
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
TypeScript-DOM-lib-generator#715https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/715
on Jul 10, 2019https://github.com/microsoft/TypeScript/issues/19816#event-2473772207
https://github.com/inoyakaigor
Igor «InoY» Zviagintsev (inoyakaigor)https://github.com/inoyakaigor
on Aug 20, 2019https://github.com/microsoft/TypeScript/issues/19816#issuecomment-522990603
alendorffhttps://github.com/alendorff
https://github.com/maksnester
Maksim Nesterenko (maksnester)https://github.com/maksnester
on Aug 22, 2019https://github.com/microsoft/TypeScript/issues/19816#issuecomment-523824789
Igor «InoY» Zviagintsev (@inoyakaigor)https://github.com/inoyakaigor
https://github.com/inoyakaigor
Igor «InoY» Zviagintsev (inoyakaigor)https://github.com/inoyakaigor
on Aug 22, 2019https://github.com/microsoft/TypeScript/issues/19816#issuecomment-523832224
alendorffhttps://github.com/alendorff
https://github.com/maksnester
Maksim Nesterenko (maksnester)https://github.com/maksnester
on Aug 22, 2019https://github.com/microsoft/TypeScript/issues/19816#issuecomment-524046751
Igor «InoY» Zviagintsev (@inoyakaigor)https://github.com/inoyakaigor
https://github.com/TranquilMarmot
Nate Moore (TranquilMarmot)https://github.com/TranquilMarmot
on Jun 7, 2020https://github.com/microsoft/TypeScript/issues/19816#issuecomment-640263670
https://github.com/mersanuzun
ersan (mersanuzun)https://github.com/mersanuzun
on Jun 9, 2020https://github.com/microsoft/TypeScript/issues/19816#issuecomment-641535220
https://github.com/raphael10-collab
raphael10-collabhttps://github.com/raphael10-collab
on Feb 9, 2021https://github.com/microsoft/TypeScript/issues/19816#issuecomment-775975963
Nate Moore (@TranquilMarmot)https://github.com/TranquilMarmot
https://github.com/TranquilMarmot
Nate Moore (TranquilMarmot)https://github.com/TranquilMarmot
on Feb 9, 2021https://github.com/microsoft/TypeScript/issues/19816#issuecomment-776032302
raphael10-collabhttps://github.com/raphael10-collab
https://github.com/raphael10-collab
raphael10-collabhttps://github.com/raphael10-collab
on Feb 9, 2021https://github.com/microsoft/TypeScript/issues/19816#issuecomment-776043432
Nate Moore (@TranquilMarmot)https://github.com/TranquilMarmot
https://github.com/TranquilMarmot
Nate Moore (TranquilMarmot)https://github.com/TranquilMarmot
on Feb 9, 2021https://github.com/microsoft/TypeScript/issues/19816#issuecomment-776047636
raphael10-collabhttps://github.com/raphael10-collab
https://github.com/raphael10-collab
raphael10-collabhttps://github.com/raphael10-collab
on Feb 9, 2021https://github.com/microsoft/TypeScript/issues/19816#issuecomment-776058646
https://github.com/TranquilMarmot
Nate Moore (TranquilMarmot)https://github.com/TranquilMarmot
on Feb 9, 2021https://github.com/microsoft/TypeScript/issues/19816#issuecomment-776110394
raphael10-collabhttps://github.com/raphael10-collab
https://github.com/raphael10-collab
raphael10-collabhttps://github.com/raphael10-collab
on Feb 9, 2021https://github.com/microsoft/TypeScript/issues/19816#issuecomment-776131710
Nate Moore (@TranquilMarmot)https://github.com/TranquilMarmot
https://github.com/raphael10-collab/Libp2pPlayinghttps://github.com/raphael10-collab/Libp2pPlaying
https://github.com/TranquilMarmot
Nate Moore (TranquilMarmot)https://github.com/TranquilMarmot
on Feb 9, 2021https://github.com/microsoft/TypeScript/issues/19816#issuecomment-776170776
raphael10-collabhttps://github.com/raphael10-collab
https://github.com/raphael10-collab
raphael10-collabhttps://github.com/raphael10-collab
on Feb 9, 2021https://github.com/microsoft/TypeScript/issues/19816#issuecomment-776192470
Nate Moore (@TranquilMarmot)https://github.com/TranquilMarmot
https://github.com/TranquilMarmot
Nate Moore (TranquilMarmot)https://github.com/TranquilMarmot
on Feb 9, 2021https://github.com/microsoft/TypeScript/issues/19816#issuecomment-776222438
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/19816
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/19816
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%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.