René's URL Explorer Experiment


Title: Using string enum as key in {[key]: Type} throws not an index signature · Issue #22892 · microsoft/TypeScript · GitHub

Open Graph Title: Using string enum as key in {[key]: Type} throws not an index signature · Issue #22892 · microsoft/TypeScript

X Title: Using string enum as key in {[key]: Type} throws not an index signature · Issue #22892 · microsoft/TypeScript

Description: TypeScript Version: 2.9.0-dev.20180325 Search Terms: string enum index signature cast Code enum Fruits { MANGO = 'MANGO', BANANA = 'BANANA', } type StringDict = { [key: string]: string }; function map(dict: StringDict, transform: (key: s...

Open Graph Description: TypeScript Version: 2.9.0-dev.20180325 Search Terms: string enum index signature cast Code enum Fruits { MANGO = 'MANGO', BANANA = 'BANANA', } type StringDict = { [key: string]: string }; function ...

X Description: TypeScript Version: 2.9.0-dev.20180325 Search Terms: string enum index signature cast Code enum Fruits { MANGO = 'MANGO', BANANA = 'BANANA', } type StringDict = { [key: string]: str...

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

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":"Using string enum as key in {[key]: Type} throws not an index signature","articleBody":"**TypeScript Version:**  2.9.0-dev.20180325\r\n\r\n**Search Terms:** string enum index signature cast\r\n\r\n**Code**\r\n\r\n```ts\r\nenum Fruits {\r\n    MANGO = 'MANGO',\r\n    BANANA = 'BANANA',\r\n}\r\n\r\ntype StringDict = { [key: string]: string };\r\n\r\nfunction map(dict: StringDict, transform: (key: string, value: string) => void) {\r\n    const result = {};\r\n\r\n    for (const key of Object.keys(dict)) {\r\n        result[key] = transform(key, dict[key]);\r\n    }\r\n\r\n    return result;\r\n}\r\n\r\nmap(Fruits, (key, value) => {\r\n    value.toLowerCase();\r\n});\r\n\r\n\r\nmap(Fruits as StringDict, (key, value) => {\r\n    value.toLowerCase();\r\n});\r\n```\r\n\r\n**Expected behavior:**\r\nBoth `map` calls succeed, because a string enum is essentially a `{[key: string]: string}`.  I ought to be able to use it anywhere that needs something indexed by string (as long as the values are appropriate).\r\n\r\n**Actual behavior:**\r\nindex.ts(14,5): error TS2345: Argument of type 'typeof Fruits' is not assignable to parameter of type 'StringDict'.\r\n  Index signature is missing in type 'typeof Fruits'.\r\nindex.ts(19,5): error TS2352: Type 'typeof Fruits' cannot be converted to type 'StringDict'.\r\n  Index signature is missing in type 'typeof Fruits'.\r\n\r\n[**Playground Link**](\r\nhttp://www.typescriptlang.org/play/#src=enum%20Fruits%20%7B%0D%0A%20%20%20%20MANGO%20%3D%20'MANGO'%2C%0D%0A%20%20%20%20BANANA%20%3D%20'BANANA'%2C%0D%0A%7D%0D%0A%0D%0Atype%20StringDict%20%3D%20%7B%20%5Bkey%3A%20string%5D%3A%20string%20%7D%3B%0D%0A%0D%0Afunction%20map(dict%3A%20StringDict%2C%20transform%3A%20(key%3A%20string%2C%20value%3A%20string)%20%3D%3E%20void)%20%7B%0D%0A%20%20%20%20const%20result%20%3D%20%7B%7D%3B%0D%0A%0D%0A%20%20%20%20for%20(const%20key%20of%20Object.keys(dict))%20%7B%0D%0A%20%20%20%20%20%20%20%20result%5Bkey%5D%20%3D%20transform(key%2C%20dict%5Bkey%5D)%3B%0D%0A%20%20%20%20%7D%0D%0A%0D%0A%20%20%20%20return%20result%3B%0D%0A%7D%0D%0A%0D%0Amap(Fruits%2C%20(key%2C%20value)%20%3D%3E%20%7B%0D%0A%20%20%20%20value.toLowerCase()%3B%0D%0A%7D)%3B%0D%0A%0D%0A%0D%0Amap(Fruits%20as%20StringDict%2C%20(key%2C%20value)%20%3D%3E%20%7B%0D%0A%20%20%20%20value.toLowerCase()%3B%0D%0A%7D)%3B%0D%0A%0D%0A)\r\n\r\n**Related Issues:**\r\n#20011, #18029, #16760","author":{"url":"https://github.com/appsforartists","@type":"Person","name":"appsforartists"},"datePublished":"2018-03-26T23:29:51Z","url":"https://github.com/microsoft/TypeScript/issues/22892"}

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:a4bcc8dc-d951-904c-605a-51b8def1353a
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA17A:1F2E:4706F1:61AF39:6B0451B7
html-safe-noncece4c7a93bb33332792058c6dc25c4fdc2c1011f52ebb0536820ebc877decf36c
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTdBOjFGMkU6NDcwNkYxOjYxQUYzOTo2QjA0NTFCNyIsInZpc2l0b3JfaWQiOiI1NzUyNjAxNTY2NTIzOTY5OTc1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac7270f932f9a05a86dc706754deed031cee03ed31afe8dbfeec0812719518f504
hovercard-subject-tagissue:308770247
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/22892/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d68205d6f4de416fddbe7ae129724ffef2fa1080d075b0b8a480d1ebe5f4378b/microsoft/TypeScript/issues/22892
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d68205d6f4de416fddbe7ae129724ffef2fa1080d075b0b8a480d1ebe5f4378b/microsoft/TypeScript/issues/22892
og:image:altTypeScript Version: 2.9.0-dev.20180325 Search Terms: string enum index signature cast Code enum Fruits { MANGO = 'MANGO', BANANA = 'BANANA', } type StringDict = { [key: string]: string }; function ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameappsforartists
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/22892#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F22892
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%2F22892
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/22892
Reloadhttps://github.com/microsoft/TypeScript/issues/22892
Reloadhttps://github.com/microsoft/TypeScript/issues/22892
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/22892
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/22892
Using string enum as key in {[key]: Type} throws not an index signaturehttps://github.com/microsoft/TypeScript/issues/22892#top
Working as IntendedThe behavior described is the intended behavior; this is not a bughttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Working%20as%20Intended%22
https://github.com/appsforartists
Brenton Simpson (appsforartists)https://github.com/appsforartists
on Mar 26, 2018https://github.com/microsoft/TypeScript/issues/22892#issue-308770247
Playground Linkhttp://www.typescriptlang.org/play/#src=enum%20Fruits%20%7B%0D%0A%20%20%20%20MANGO%20%3D%20'MANGO'%2C%0D%0A%20%20%20%20BANANA%20%3D%20'BANANA'%2C%0D%0A%7D%0D%0A%0D%0Atype%20StringDict%20%3D%20%7B%20%5Bkey%3A%20string%5D%3A%20string%20%7D%3B%0D%0A%0D%0Afunction%20map(dict%3A%20StringDict%2C%20transform%3A%20(key%3A%20string%2C%20value%3A%20string)%20%3D%3E%20void)%20%7B%0D%0A%20%20%20%20const%20result%20%3D%20%7B%7D%3B%0D%0A%0D%0A%20%20%20%20for%20(const%20key%20of%20Object.keys(dict))%20%7B%0D%0A%20%20%20%20%20%20%20%20result%5Bkey%5D%20%3D%20transform(key%2C%20dict%5Bkey%5D)%3B%0D%0A%20%20%20%20%7D%0D%0A%0D%0A%20%20%20%20return%20result%3B%0D%0A%7D%0D%0A%0D%0Amap(Fruits%2C%20(key%2C%20value)%20%3D%3E%20%7B%0D%0A%20%20%20%20value.toLowerCase()%3B%0D%0A%7D)%3B%0D%0A%0D%0A%0D%0Amap(Fruits%20as%20StringDict%2C%20(key%2C%20value)%20%3D%3E%20%7B%0D%0A%20%20%20%20value.toLowerCase()%3B%0D%0A%7D)%3B%0D%0A%0D%0A
#20011https://github.com/microsoft/TypeScript/issues/20011
#18029https://github.com/microsoft/TypeScript/pull/18029
#16760https://github.com/microsoft/TypeScript/issues/16760
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Mar 26, 2018https://github.com/microsoft/TypeScript/issues/22892#issuecomment-376347875
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
Working as IntendedThe behavior described is the intended behavior; this is not a bughttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Working%20as%20Intended%22
on Mar 26, 2018https://github.com/microsoft/TypeScript/issues/22892#event-1542082147
https://github.com/appsforartists
Brenton Simpson (appsforartists)https://github.com/appsforartists
on Mar 26, 2018https://github.com/microsoft/TypeScript/issues/22892#issuecomment-376348913
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Mar 27, 2018https://github.com/microsoft/TypeScript/issues/22892#issuecomment-376351464
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
Working as IntendedThe behavior described is the intended behavior; this is not a bughttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Working%20as%20Intended%22
on Mar 27, 2018https://github.com/microsoft/TypeScript/issues/22892#event-1542103511
https://github.com/appsforartists
Brenton Simpson (appsforartists)https://github.com/appsforartists
on Mar 27, 2018https://github.com/microsoft/TypeScript/issues/22892#issuecomment-376353492
https://github.com/dardino
Gabriele (dardino)https://github.com/dardino
on Mar 27, 2018https://github.com/microsoft/TypeScript/issues/22892#issuecomment-376505867
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Mar 27, 2018https://github.com/microsoft/TypeScript/issues/22892#issuecomment-376598078
Gabriele (@dardino)https://github.com/dardino
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Working as IntendedThe behavior described is the intended behavior; this is not a bughttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Working%20as%20Intended%22
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
on Aug 6, 2018https://github.com/microsoft/TypeScript/issues/22892#event-1774076573
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Aug 6, 2018https://github.com/microsoft/TypeScript/issues/22892#issuecomment-410887804
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Aug 6, 2018https://github.com/microsoft/TypeScript/issues/22892#event-1774078044
https://github.com/royling
Roy Ling (royling)https://github.com/royling
on Feb 3, 2021https://github.com/microsoft/TypeScript/issues/22892#issuecomment-772302314
template literal typeshttps://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-1.html#template-literal-types
microsofthttps://github.com/microsoft
on Oct 21, 2025https://github.com/microsoft/TypeScript/issues/22892#event-20415627967
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/22892
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/22892
Working as IntendedThe behavior described is the intended behavior; this is not a bughttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Working%20as%20Intended%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.