René's URL Explorer Experiment


Title: Omit index signature with generic type constraints? · Issue #10941 · microsoft/TypeScript · GitHub

Open Graph Title: Omit index signature with generic type constraints? · Issue #10941 · microsoft/TypeScript

X Title: Omit index signature with generic type constraints? · Issue #10941 · microsoft/TypeScript

Description: TypeScript Version: nightly 2.1-20160914 I have a base class that takes a generic parameter with a constraint that is an index signature. Something like interface Constraint { [key: string]: number } class Base { en...

Open Graph Description: TypeScript Version: nightly 2.1-20160914 I have a base class that takes a generic parameter with a constraint that is an index signature. Something like interface Constraint { [key: string]: number...

X Description: TypeScript Version: nightly 2.1-20160914 I have a base class that takes a generic parameter with a constraint that is an index signature. Something like interface Constraint { [key: string]: number...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Omit index signature with generic type constraints?","articleBody":"**TypeScript Version:** nightly 2.1-20160914\n\nI have a base class that takes a generic parameter with a constraint that is an index signature. Something like\n\n``` ts\ninterface Constraint {\n    [key: string]: number\n}\n\nclass Base\u003cT extends Constraint> {\n    entity: T\n}\n```\n\nThis class is meant to be inherited from and provided with another type that satisfies the index signature but doesn't carry it itself. Something like\n\n``` ts\ninterface MyType {\n    prop: number;\n    label: number;\n    code: number\n}\n\nclass MyClass extends Base\u003cMyType> {\n    // Error: Index signature is missing from MyType\n}\n```\n\nI don't want to put the index signature on MyType because destructuring `entity` won't output an error when the property doesn't exist:\n\n``` ts\nconst {id} = this.entity // oops, no error\n```\n\nwhich is a critical feature for me.\n\nI don't want to remove the index signature from the constraint because the base class completely revolves around it and I would lose a lot of type safety.\n\nIs there something I missed? Should we have some new language feature to solve this issue?\n\n(Now that I think of it I suppose it's a generic assignability issue between types, not restricted of type constraints, and it's not solved by #7029 since it's only about actual litterals, not types)\n","author":{"url":"https://github.com/JabX","@type":"Person","name":"JabX"},"datePublished":"2016-09-15T17:27:44Z","url":"https://github.com/microsoft/TypeScript/issues/10941"}

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:59125447-27e2-2d29-bc89-ad830c39d49b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB8E8:2454CC:963E98:C08B38:6B00EFD5
html-safe-nonceb89e7ba583fad73be501245b9e8d091a93dfd26ee7837dc5eb5bab88bd224839
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOEU4OjI0NTRDQzo5NjNFOTg6QzA4QjM4OjZCMDBFRkQ1IiwidmlzaXRvcl9pZCI6IjEyMzUyNjA1MzQ4ODcwODM5ODkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac5ea4e3f6e1ad19402fd3c1f04eb0a8471b764c6ed8c0954bdcefd493e96efcb6
hovercard-subject-tagissue:177236884
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/10941/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f2ee031da25c7f374a849ceeabaf05bda2a389a0636e8706fe6b51fb3b81556d/microsoft/TypeScript/issues/10941
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f2ee031da25c7f374a849ceeabaf05bda2a389a0636e8706fe6b51fb3b81556d/microsoft/TypeScript/issues/10941
og:image:altTypeScript Version: nightly 2.1-20160914 I have a base class that takes a generic parameter with a constraint that is an index signature. Something like interface Constraint { [key: string]: number...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameJabX
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/10941#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F10941
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%2F10941
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/10941
Reloadhttps://github.com/microsoft/TypeScript/issues/10941
Reloadhttps://github.com/microsoft/TypeScript/issues/10941
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/10941
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/10941
Omit index signature with generic type constraints?https://github.com/microsoft/TypeScript/issues/10941#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/JabX
Damien Frikha (JabX)https://github.com/JabX
on Sep 15, 2016https://github.com/microsoft/TypeScript/issues/10941#issue-177236884
#7029https://github.com/microsoft/TypeScript/pull/7029
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Sep 15, 2016https://github.com/microsoft/TypeScript/issues/10941#issuecomment-247407657
https://github.com/JabX
Damien Frikha (JabX)https://github.com/JabX
on Sep 15, 2016https://github.com/microsoft/TypeScript/issues/10941#issuecomment-247426648
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Sep 15, 2016https://github.com/microsoft/TypeScript/issues/10941#issuecomment-247428291
https://github.com/JabX
Damien Frikha (JabX)https://github.com/JabX
on Sep 15, 2016https://github.com/microsoft/TypeScript/issues/10941#issuecomment-247461541
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Sep 15, 2016https://github.com/microsoft/TypeScript/issues/10941#event-791491476
https://github.com/Pajn
Emma (Pajn)https://github.com/Pajn
on Sep 16, 2016https://github.com/microsoft/TypeScript/issues/10941#issuecomment-247690872
https://github.com/rado-nikolov
rado-nikolovhttps://github.com/rado-nikolov
on Apr 14, 2017https://github.com/microsoft/TypeScript/issues/10941#issuecomment-294125419
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Needs InvestigationThis issue needs a team member to investigate its status.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Investigation%22
Needs InvestigationThis issue needs a team member to investigate its status.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Investigation%22
on May 24, 2017https://github.com/microsoft/TypeScript/issues/10941#event-1094703950
https://github.com/fxlrnrpt
Andrey Goncharov (fxlrnrpt)https://github.com/fxlrnrpt
on Jun 25, 2018https://github.com/microsoft/TypeScript/issues/10941#issuecomment-399816089
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
https://github.com/fxlrnrpt
Andrey Goncharov (fxlrnrpt)https://github.com/fxlrnrpt
on Jun 25, 2018https://github.com/microsoft/TypeScript/issues/10941#issuecomment-399979532
Damien Frikha (@JabX)https://github.com/JabX
rado-nikolovhttps://github.com/rado-nikolov
https://github.com/fxlrnrpt
Andrey Goncharov (fxlrnrpt)https://github.com/fxlrnrpt
on Jul 14, 2018https://github.com/microsoft/TypeScript/issues/10941#issuecomment-405052473
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
Damien Frikha (@JabX)https://github.com/JabX
Playgroundhttp://www.typescriptlang.org/play/#src=const%20func%20%3D%20%3CT%20extends%20%7B%20%5Bindex%3A%20string%5D%3A%20string%20%7D%3E(a%3A%20T)%20%3D%3E%20a%0D%0A%0D%0Afunc%3C%7B%20test%3A%20string%20%7D%3E(%7B%20test%3A%20'123'%20%7D)%20%2F%2F%20works%0D%0A%0D%0Ainterface%20A%20%7B%0D%0A%20%20test%3A%20string%0D%0A%7D%0D%0Afunc%3CA%3E(%7B%20test%3A%20'123'%20%7D)%20%2F%2F%20fails
https://github.com/fxlrnrpt
Andrey Goncharov (fxlrnrpt)https://github.com/fxlrnrpt
on Nov 3, 2018https://github.com/microsoft/TypeScript/issues/10941#issuecomment-435574161
Playgroundhttps://www.typescriptlang.org/play/#src=interface%20A%20%7B%0D%0A%20%20%20%20a%3A%20string%2C%0D%0A%20%20%20%20b%3A%20string%0D%0A%7D%0D%0Atype%20AConstraint%3CT%20extends%20A%3E%20%3D%20T%20%26%20%7B%20%5Bindex%3A%20string%5D%3A%20string%20%7D%0D%0Aconst%20a%20%3D%20%3CT%20extends%20A%3E(props%3A%20AConstraint%3CT%3E)%3A%20T%20%3D%3E%20props%20%0D%0A%0D%0Aconst%20propsTest1%3A%20A%20%3D%20%7B%20a%3A%20'1'%2C%20b%3A%20'2'%20%7D%0D%0Aa(propsTest1%20as%20AConstraint%3CA%3E)%0D%0A%0D%0Aconst%20propsTest2%20%3D%20%7B%20a%3A%20'1'%2C%20b%3A%20'2'%2C%20c%3A%20'ftdrff'%20%7D%0D%0Aa(propsTest2)%0D%0A%0D%0A
https://github.com/fxlrnrpt
Andrey Goncharov (fxlrnrpt)https://github.com/fxlrnrpt
on Nov 3, 2018https://github.com/microsoft/TypeScript/issues/10941#issuecomment-435574260
Andy (Andrewkraft) (@Andy-MS)https://github.com/Andy-MS
https://github.com/kristw
Krist Wongsuphasawat (kristw)https://github.com/kristw
on Mar 12, 2019https://github.com/microsoft/TypeScript/issues/10941#issuecomment-471913610
https://github.com/fxlrnrpt
Andrey Goncharov (fxlrnrpt)https://github.com/fxlrnrpt
on Mar 12, 2019https://github.com/microsoft/TypeScript/issues/10941#issuecomment-471927089
Krist Wongsuphasawat (@kristw)https://github.com/kristw
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Mar 12, 2019https://github.com/microsoft/TypeScript/issues/10941#event-2197730508
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
Needs InvestigationThis issue needs a team member to investigate its status.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Investigation%22
on Mar 12, 2019https://github.com/microsoft/TypeScript/issues/10941#event-2197731357
https://github.com/typescript-bot
TypeScript Bot (typescript-bot)https://github.com/typescript-bot
on Mar 14, 2019https://github.com/microsoft/TypeScript/issues/10941#issuecomment-473036882
TypeScript Bot (typescript-bot)https://github.com/typescript-bot
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Mar 14, 2019https://github.com/microsoft/TypeScript/issues/10941#event-2204644271
microsofthttps://github.com/microsoft
on Oct 21, 2025https://github.com/microsoft/TypeScript/issues/10941#event-20415342126
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/10941
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/10941
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

Viewport: width=device-width


URLs of crawlers that visited me.