René's URL Explorer Experiment


Title: Mapped types enumerating keys in `string` behave poorly · Issue #22509 · microsoft/TypeScript · GitHub

Open Graph Title: Mapped types enumerating keys in `string` behave poorly · Issue #22509 · microsoft/TypeScript

X Title: Mapped types enumerating keys in `string` behave poorly · Issue #22509 · microsoft/TypeScript

Description: TypeScript Version: 2.8.0-dev20180308 Search Terms: mapped types Code type Thing = { [K in string]: K }; var thing: Thing = new Proxy({}, { get(_, k) { return k; } }); let res = thing.x; // res should be of type 'x', but is string Playgr...

Open Graph Description: TypeScript Version: 2.8.0-dev20180308 Search Terms: mapped types Code type Thing = { [K in string]: K }; var thing: Thing = new Proxy({}, { get(_, k) { return k; } }); let res = thing.x; // res sho...

X Description: TypeScript Version: 2.8.0-dev20180308 Search Terms: mapped types Code type Thing = { [K in string]: K }; var thing: Thing = new Proxy({}, { get(_, k) { return k; } }); let res = thing.x; // res sho...

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

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Mapped types enumerating keys in `string` behave poorly","articleBody":"**TypeScript Version:**  2.8.0-dev20180308\r\n**Search Terms:** mapped types\r\n**Code**\r\n\r\n```ts\r\ntype Thing = {\r\n    [K in string]: K\r\n};\r\n\r\nvar thing: Thing = new Proxy({}, {\r\n    get(_, k) {\r\n        return k;\r\n    }\r\n});\r\n\r\nlet res = thing.x; // res should be of type 'x', but is string\r\n```\r\n[Playground Link](http://www.typescriptlang.org/play/index.html#src=type%20Thing%20%3D%20%7B%0D%0A%20%20%20%20%5BK%20in%20string%5D%3A%20K%0D%0A%7D%3B%0D%0A%0D%0Avar%20thing%3A%20Thing%20%3D%20new%20Proxy(%7B%7D%2C%20%7B%0D%0A%20%20%20%20get(_%2C%20k)%20%7B%0D%0A%20%20%20%20%20%20%20%20return%20k%3B%0D%0A%20%20%20%20%7D%0D%0A%7D)%3B%0D%0A%0D%0Alet%20res%20%3D%20thing.x%3B%20%2F%2F%20res%20should%20be%20of%20type%20'x'%2C%20but%20is%20string)\r\n\r\nHere I expect `string` to behave as if it were the union of all possible string literal types. The present semantics are identical to a string indexer. IMO if we don't want map types `K in string` to do anything interesting, then the syntax should be an error and we should require people to write the indexer. \r\n\r\nFor what it's worth, ultimately I would love to type Allen's Apparatus for Method Extraction, roughly typed below:\r\n\r\n```ts\r\ntype ExtractorThing = {\r\n    [K in string]: \u003cT>(base: T) => K extends keyof T ? T[K] : never;\r\n}\r\n\r\nvar extract: ExtractorThing = new Proxy({}, {\r\n    get(target, prop) {\r\n        \"use strict\";\r\n        return (base: any) => function(this: any, ...args: any[]) {\r\n          return base[prop].apply(this || base, args); \r\n        }\r\n    }\r\n});\r\n\r\nlet obj = {\r\n    x: 0,\r\n    succ() {\r\n        return ++this.x;\r\n    },\r\n    dec() {\r\n        return --this.x;\r\n    }\r\n}\r\n\r\nlet succ = extract.succ(obj);\r\nlet dec = extract.dec(obj);\r\n\r\nsucc(); // 1\r\nsucc(); // 2\r\ndec(); // 1\r\ndec(); // 0\r\n```\r\n\r\nI would probably work towards putting a constraint on T such that you get a red squiggle if you pass an object without the proper method to extract, but hopefully this serves as a useful example.","author":{"url":"https://github.com/bterlson","@type":"Person","name":"bterlson"},"datePublished":"2018-03-13T16:43:20Z","url":"https://github.com/microsoft/TypeScript/issues/22509"}

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:168ca853-0264-10f7-e59c-3547137b3d82
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id95DA:2E648F:ACE66C:ECB47F:6B0451D1
html-safe-nonce30460c5dc23e82b9a94b87d540123ad820619448ffc3e85198a99ac1dbac2718
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NURBOjJFNjQ4RjpBQ0U2NkM6RUNCNDdGOjZCMDQ1MUQxIiwidmlzaXRvcl9pZCI6IjI4ODU4NDQ5ODUzMjI5NTExMjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac3e3063b3b395088c04c6506c635167f46f315e9dc48a0ec1ca54a7abc608a740
hovercard-subject-tagissue:304845159
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/22509/issue_layout
twitter:imagehttps://opengraph.githubassets.com/8cbc2998697bb03e16017d9a591ea84d059b0a51a897ba5bc2adc0649d67dfd8/microsoft/TypeScript/issues/22509
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/8cbc2998697bb03e16017d9a591ea84d059b0a51a897ba5bc2adc0649d67dfd8/microsoft/TypeScript/issues/22509
og:image:altTypeScript Version: 2.8.0-dev20180308 Search Terms: mapped types Code type Thing = { [K in string]: K }; var thing: Thing = new Proxy({}, { get(_, k) { return k; } }); let res = thing.x; // res sho...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebterlson
hostnamegithub.com
expected-hostnamegithub.com
None910ca0e260cfec6aff11407d8dc6a0d3a4cd381a2ec9ada56627b063426892a0
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
releasee086f9b7e88322eb2b41885a6ad425b215737fa5
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/22509#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F22509
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%2F22509
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/22509
Reloadhttps://github.com/microsoft/TypeScript/issues/22509
Reloadhttps://github.com/microsoft/TypeScript/issues/22509
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests320 (320)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/22509
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/22509
Mapped types enumerating keys in string behave poorlyhttps://github.com/microsoft/TypeScript/issues/22509#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/bterlson
Brian Terlson (bterlson)https://github.com/bterlson
on Mar 13, 2018https://github.com/microsoft/TypeScript/issues/22509#issue-304845159
Playground Linkhttp://www.typescriptlang.org/play/index.html#src=type%20Thing%20%3D%20%7B%0D%0A%20%20%20%20%5BK%20in%20string%5D%3A%20K%0D%0A%7D%3B%0D%0A%0D%0Avar%20thing%3A%20Thing%20%3D%20new%20Proxy(%7B%7D%2C%20%7B%0D%0A%20%20%20%20get(_%2C%20k)%20%7B%0D%0A%20%20%20%20%20%20%20%20return%20k%3B%0D%0A%20%20%20%20%7D%0D%0A%7D)%3B%0D%0A%0D%0Alet%20res%20%3D%20thing.x%3B%20%2F%2F%20res%20should%20be%20of%20type%20'x'%2C%20but%20is%20string
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Mar 13, 2018https://github.com/microsoft/TypeScript/issues/22509#issuecomment-372761260
Anders Hejlsberg (@ahejlsberg)https://github.com/ahejlsberg
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
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 Mar 13, 2018https://github.com/microsoft/TypeScript/issues/22509#event-1519398824
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
on Mar 13, 2018https://github.com/microsoft/TypeScript/issues/22509#event-1519399129
https://github.com/jack-williams
Jack Williams (jack-williams)https://github.com/jack-williams
on Mar 13, 2018https://github.com/microsoft/TypeScript/issues/22509#issuecomment-372785068
https://github.com/DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
on Mar 13, 2018https://github.com/microsoft/TypeScript/issues/22509#issuecomment-372798250
Jack Williams (@jack-williams)https://github.com/jack-williams
https://github.com/jack-williams
Jack Williams (jack-williams)https://github.com/jack-williams
on Mar 13, 2018https://github.com/microsoft/TypeScript/issues/22509#issuecomment-372815112
Daniel Rosenwasser (@DanielRosenwasser)https://github.com/DanielRosenwasser
https://github.com/ahejlsberg
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Mar 14, 2018https://github.com/microsoft/TypeScript/issues/22509#issuecomment-372861132
https://github.com/bterlson
Brian Terlson (bterlson)https://github.com/bterlson
on Mar 14, 2018https://github.com/microsoft/TypeScript/issues/22509#issuecomment-373086970
Anders Hejlsberg (@ahejlsberg)https://github.com/ahejlsberg
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
DeclinedThe issue was declined as something which matches the TypeScript visionhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Declined%22
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%22
on Jun 24, 2021https://github.com/microsoft/TypeScript/issues/22509#event-4937125234
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Jun 24, 2021https://github.com/microsoft/TypeScript/issues/22509#issuecomment-867997485
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jun 24, 2021https://github.com/microsoft/TypeScript/issues/22509#event-4937126056
https://github.com/DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
on Oct 7, 2021https://github.com/microsoft/TypeScript/issues/22509#issuecomment-938188546
Brian Terlson (@bterlson)https://github.com/bterlson
https://github.com/eggers
Jacob Eggers (eggers)https://github.com/eggers
on Aug 29, 2022https://github.com/microsoft/TypeScript/issues/22509#issuecomment-1230746230
https://github.com/tlrobinson
Tom Robinson (tlrobinson)https://github.com/tlrobinson
on Jan 29, 2023https://github.com/microsoft/TypeScript/issues/22509#issuecomment-1407558048
tRPChttps://trpc.io/
Jacob Eggers (@eggers)https://github.com/eggers
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/22509
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/22509
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

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.