René's URL Explorer Experiment


Title: Why does { foo: T } not satisfy { [key:string]: T }? · Issue #6041 · microsoft/TypeScript · GitHub

Open Graph Title: Why does { foo: T } not satisfy { [key:string]: T }? · Issue #6041 · microsoft/TypeScript

X Title: Why does { foo: T } not satisfy { [key:string]: T }? · Issue #6041 · microsoft/TypeScript

Description: Various libraries I use want to see dictionary "loops" that take some number of key/value pairs and operate on them. E.g.: async.auto({ 'foo': (cb) => getFoo(cb), 'bar': ['foo', (cb, results) => getBar(results.foo)] }, (err, results...

Open Graph Description: Various libraries I use want to see dictionary "loops" that take some number of key/value pairs and operate on them. E.g.: async.auto({ 'foo': (cb) => getFoo(cb), 'bar': ['foo', (cb, results) ...

X Description: Various libraries I use want to see dictionary "loops" that take some number of key/value pairs and operate on them. E.g.: async.auto<any>({ 'foo': (cb) => getFoo(cb), &#...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Why does { foo: T } not satisfy { [key:string]: T }?","articleBody":"Various libraries I use want to see dictionary \"loops\" that take some number of key/value pairs and operate on them. E.g.:\n\n```\nasync.auto\u003cany>({\n   'foo': (cb) => getFoo(cb),\n   'bar': ['foo', (cb, results) => getBar(results.foo)]\n}, (err, results) => { ... });\n```\n\nThe typings file for async likes to [define helper dictionary](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/async/async.d.ts#L6) types like this:\n\n```\ninterface Dictionary\u003cT> { [key: string]: T; }\n```\n\nPeriodically, I need to create these key/value pairs conditionally and on the fly but the compiler yells at me if I try to send it in without explicitly typing my temporary object:\n\n```\nvar block = {\n    'foo': (cb) => getFoo(cb),\n    'bar': ['foo', (cb, results) => getBar(results.foo)\n}\n\nif (flag) {\n    block.foo = getOtherFoo(cb);\n}\n\nasync.auto\u003cany>(block, (err, results) => { ... });\n```\n\n`block` now technically satisfies the `{ [key: string]: T; }` because it is an object with two keys, both strings. TypeScript will still yell at me for it, though, unless I explicit add a similar dictionary type to `block`. I, therefore, find myself putting this dictionary type all over the place just to satisfy what seems to be an arbitrary distinction between what is or is not a `key:string`.\n\nThis comes up enough that I find the type bloat irritating and it also makes it a requirement to _only_ access `block.foo` as `block['foo']`.\n","author":{"url":"https://github.com/MrHen","@type":"Person","name":"MrHen"},"datePublished":"2015-12-10T21:15:39Z","url":"https://github.com/microsoft/TypeScript/issues/6041"}

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:db81a4a6-b5cf-c3da-b22b-fb84cb75239d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8040:3F8AB1:BCB1B9:F376CF:6B00E9DA
html-safe-noncefbcfd157fde93911d8b98ca61598ba53c9f8252213733af36830d436414c75a6
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDQwOjNGOEFCMTpCQ0IxQjk6RjM3NkNGOjZCMDBFOURBIiwidmlzaXRvcl9pZCI6IjEyNjIxMTMyODQ2MDE5OTc3ODYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacd2762f71f5f300cb3d5c5bdf4f7d7e2de5fb4dcdc1727c7f46b1c9d270e8d316
hovercard-subject-tagissue:121578889
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/6041/issue_layout
twitter:imagehttps://opengraph.githubassets.com/58a1f424524b8ef324a45b9c8dcacd1e34e71269ee5d4ff293e1727470448094/microsoft/TypeScript/issues/6041
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/58a1f424524b8ef324a45b9c8dcacd1e34e71269ee5d4ff293e1727470448094/microsoft/TypeScript/issues/6041
og:image:altVarious libraries I use want to see dictionary "loops" that take some number of key/value pairs and operate on them. E.g.: async.auto({ 'foo': (cb) => getFoo(cb), 'bar': ['foo', (cb, results) ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameMrHen
hostnamegithub.com
expected-hostnamegithub.com
None4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc
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
release9983dd5da06943f833c971dd5b6bc988e2858be5
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/6041#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F6041
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%2F6041
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/6041
Reloadhttps://github.com/microsoft/TypeScript/issues/6041
Reloadhttps://github.com/microsoft/TypeScript/issues/6041
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests308 (308)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/6041
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/6041
Why does { foo: T } not satisfy { [key:string]: T }?https://github.com/microsoft/TypeScript/issues/6041#top
CommittedThe team has roadmapped this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Committed%22
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
TypeScript 2.0https://github.com/microsoft/TypeScript/milestone/1
https://github.com/MrHen
MrHenhttps://github.com/MrHen
on Dec 10, 2015https://github.com/microsoft/TypeScript/issues/6041#issue-121578889
define helper dictionaryhttps://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/async/async.d.ts#L6
https://github.com/MrHen
MrHenhttps://github.com/MrHen
on Dec 10, 2015https://github.com/microsoft/TypeScript/issues/6041#issuecomment-163761200
#5683https://github.com/microsoft/TypeScript/issues/5683
https://github.com/sandersn
Nathan Shively-Sanders (sandersn)https://github.com/sandersn
on Dec 10, 2015https://github.com/microsoft/TypeScript/issues/6041#issuecomment-163782405
https://github.com/ahejlsberg
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Dec 11, 2015https://github.com/microsoft/TypeScript/issues/6041#issuecomment-163803087
MrHenhttps://github.com/MrHen
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
Needs More InfoThe issue still hasn't been fully clarifiedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20More%20Info%22
on Dec 11, 2015https://github.com/microsoft/TypeScript/issues/6041#event-488880348
https://github.com/MrHen
MrHenhttps://github.com/MrHen
on Dec 11, 2015https://github.com/microsoft/TypeScript/issues/6041#issuecomment-163843267
Nathan Shively-Sanders (@sandersn)https://github.com/sandersn
Anders Hejlsberg (@ahejlsberg)https://github.com/ahejlsberg
Playgroundhttp://www.typescriptlang.org/Playground#src=interface%20Dictionary%3CT%3E%20%7B%20%5Bkey%3A%20string%5D%3A%20T%3B%20%7D%0A%0Afunction%20auto%3CT%3E%28commands%3ADictionary%3CT%3E%29%20%7B%09%0A%7D%0A%0Avar%20block%20%3D%20%7B%0A%09'foo'%3A%20%28cb%29%20%3D%3E%20%7B%20console.log%28'foo'%29%3B%20cb%28%29%7D%2C%0A%09'bar'%3A%20%28cb%29%20%3D%3E%20%7B%20console.log%28'bar'%29%3B%20cb%28%29%7D%0A%7D%0A%0Aauto%28block%29%3B%0A
https://github.com/joeskeen
Joe Skeen (joeskeen)https://github.com/joeskeen
on Dec 22, 2015https://github.com/microsoft/TypeScript/issues/6041#issuecomment-166667682
Playground linkhttp://www.typescriptlang.org/Playground#src=interface%20HttpHeaders%20%7B%0A%09%5Bkey%3A%20string%5D%3A%20string%0A%7D%0A%0Ainterface%20HttpService%20%7B%0A%09%3CT%3E%28path%3A%20string%2C%20method%3A%20string%2C%20headers%3A%20HttpHeaders%29%3A%20PromiseLike%3CT%3E%3B%0A%7D%0A%0Alet%20httpService%3A%20HttpService%3B%0A%2F%2Fthis%20works%3A%0AhttpService%28''%2C%20''%2C%20%7B%0A%09'Content-Type'%3A%20'application%2Fx-www-form-urlencoded'%0A%7D%29%3B%0A%2F%2Fthis%20does%20not%3A%0Aconst%20headers%20%3D%20%7B%0A%09'Content-Type'%3A%20'application%2Fx-www-form-urlencoded'%0A%7D%3B%0AhttpService%28''%2C%20''%2C%20headers%29%3B%20
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Dec 22, 2015https://github.com/microsoft/TypeScript/issues/6041#issuecomment-166668579
http://stackoverflow.com/questions/22077023/why-cant-i-indirectly-return-an-object-literal-to-satisfy-an-index-signature-rehttp://stackoverflow.com/questions/22077023/why-cant-i-indirectly-return-an-object-literal-to-satisfy-an-index-signature-re
https://github.com/MrHen
MrHenhttps://github.com/MrHen
on Dec 22, 2015https://github.com/microsoft/TypeScript/issues/6041#issuecomment-166747720
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
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
Needs More InfoThe issue still hasn't been fully clarifiedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20More%20Info%22
on Dec 22, 2015https://github.com/microsoft/TypeScript/issues/6041#event-498979127
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Dec 22, 2015https://github.com/microsoft/TypeScript/issues/6041#issuecomment-166751843
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Jan 19, 2016https://github.com/microsoft/TypeScript/issues/6041#issuecomment-173013941
master...RyanCavanaugh:inferStringIndexers#diff-8b210ad15fe8058f8cadce2a5a0c71ccR1https://github.com/microsoft/TypeScript/compare/master...RyanCavanaugh:inferStringIndexers#diff-8b210ad15fe8058f8cadce2a5a0c71ccR1
https://github.com/ahejlsberg
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Jan 19, 2016https://github.com/microsoft/TypeScript/issues/6041#issuecomment-173021108
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Jan 19, 2016https://github.com/microsoft/TypeScript/issues/6041#issuecomment-173022323
Anders Hejlsberg (@ahejlsberg)https://github.com/ahejlsberg
https://github.com/MrHen
MrHenhttps://github.com/MrHen
on Jan 20, 2016https://github.com/microsoft/TypeScript/issues/6041#issuecomment-173263146
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Feb 7, 2016https://github.com/microsoft/TypeScript/issues/6041#issuecomment-180922891
https://github.com/MrHen
MrHenhttps://github.com/MrHen
on Feb 7, 2016https://github.com/microsoft/TypeScript/issues/6041#issuecomment-181045049
async.parallelhttps://github.com/caolan/async#parallel
lodash.maphttps://lodash.com/docs#map
_.maphttps://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/lodash/lodash.d.ts#L8000
helper interfaceshttps://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/lodash/lodash.d.ts#L17931
https://github.com/ahejlsberg
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Feb 8, 2016https://github.com/microsoft/TypeScript/issues/6041#issuecomment-181167670
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
CommittedThe team has roadmapped this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Committed%22
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%22
on Feb 11, 2016https://github.com/microsoft/TypeScript/issues/6041#event-547663789
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#7029https://github.com/microsoft/TypeScript/pull/7029
on Feb 16, 2016https://github.com/microsoft/TypeScript/issues/6041#event-552812255
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
on Feb 23, 2016https://github.com/microsoft/TypeScript/issues/6041#event-562543214
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
TypeScript 2.0https://github.com/microsoft/TypeScript/milestone/1
on Feb 23, 2016https://github.com/microsoft/TypeScript/issues/6041#event-562543266
https://github.com/AlexGalays
Alexandre Galays (AlexGalays)https://github.com/AlexGalays
on Nov 23, 2016https://github.com/microsoft/TypeScript/issues/6041#issuecomment-262490510
https://github.com/SamVerschueren
Sam Verschueren (SamVerschueren)https://github.com/SamVerschueren
on Mar 22, 2017https://github.com/microsoft/TypeScript/issues/6041#issuecomment-288355671
microsofthttps://github.com/microsoft
on Jun 19, 2018https://github.com/microsoft/TypeScript/issues/6041#event-1689628300
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/6041
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/6041
CommittedThe team has roadmapped this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Committed%22
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
TypeScript 2.0https://github.com/microsoft/TypeScript/milestone/1
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.