René's URL Explorer Experiment


Title: Sub-type type · Issue #6218 · microsoft/TypeScript · GitHub

Open Graph Title: Sub-type type · Issue #6218 · microsoft/TypeScript

X Title: Sub-type type · Issue #6218 · microsoft/TypeScript

Description: I have two use cases that I cannot seem to type correctly in TypeScript. Both use cases involve functions that take a parameter of type "an object with any subset of the members of interface X". Use case 1: options merging interface Opti...

Open Graph Description: I have two use cases that I cannot seem to type correctly in TypeScript. Both use cases involve functions that take a parameter of type "an object with any subset of the members of interface X". Us...

X Description: I have two use cases that I cannot seem to type correctly in TypeScript. Both use cases involve functions that take a parameter of type "an object with any subset of the members of interface X...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Sub-type type","articleBody":"I have two use cases that I cannot seem to type correctly in TypeScript. Both use cases involve functions that take a parameter of type \"an object with any subset of the members of interface X\".\n\n**Use case 1: options merging**\n\n```\ninterface Options {\n  a: string;\n  b: string;\n}\n\nconst defaults: Options = {\n  a: \"a\",\n  b: \"b\"\n}\n\nfunction merge\u003cT>(base: T, additional: \u003csubtype of T>): T {\n  // clone all members of 'additional' onto 'base'\n}\n\nlet opts: Options = merge\u003cOptions>(defaults, { b: \"some other b\" });\n```\n\n**Use case 2: React state**\nSee also https://facebook.github.io/react/docs/component-api.html\n\nA React component is a class with three generic parameters Props, State and Context. The base class defines a setState(newState: State) method. In reality though, the setState() method accepts any sub-type of State.\n\nThis becomes particularly painful when having multiple layers of inheritance in React components:\n\nBaseWidget.tsx\n\n```\n// one React component\nclass BaseWidget\u003cP extends BaseWidget.Props, S extends BaseWidget.State, C extends BaseWidget.Context> extends ReactComponent\u003cP, S, C> {\n\n    public componentWillMount()\n                 // valid React call, TypeScript error 'argument of type foo is not assignable to parameter bar'\n        this.setState({ a: \"string\" });\n    }\n}\n\nmodule BaseWidget {\n    \"use strict\";\n\n        export interface Props extends React.Props\u003cBaseWidget\u003cProps, State, Context>> {\n    }\n\n        // note that all members must have ? on them to work\n    export interface State {\n            a?: string;\n    }\n\n    export interface Context {\n    }\n}\n\nexport = BaseWidget\n```\n","author":{"url":"https://github.com/rogierschouten","@type":"Person","name":"rogierschouten"},"datePublished":"2015-12-23T10:15:51Z","url":"https://github.com/microsoft/TypeScript/issues/6218"}

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:625b9c22-6170-8454-ecbd-f529bfe294a3
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCF56:3C0CB1:1E12D6:280933:6AFBE12D
html-safe-nonce558759c6d519e2fdc6bcf28710786963a7cf78d3c39419cfc4c3ff0e0314ba7b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRjU2OjNDMENCMToxRTEyRDY6MjgwOTMzOjZBRkJFMTJEIiwidmlzaXRvcl9pZCI6IjMzMTc3NDA4NTM1ODkxNzI1MjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacac2af54bb3c4e4adccab5c43203d7440e27855f6d3835071f75963b60f913175
hovercard-subject-tagissue:123633967
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/6218/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d2baf8cd01564092e2c5c10ead375597e433756bc47ea3de8301b8f68640704c/microsoft/TypeScript/issues/6218
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d2baf8cd01564092e2c5c10ead375597e433756bc47ea3de8301b8f68640704c/microsoft/TypeScript/issues/6218
og:image:altI have two use cases that I cannot seem to type correctly in TypeScript. Both use cases involve functions that take a parameter of type "an object with any subset of the members of interface X". Us...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamerogierschouten
hostnamegithub.com
expected-hostnamegithub.com
None744d4381b1c4dbd6d8736c7d7e5bbe7dc11217584e457a3555020c631764e8ec
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
releasedf859c48a4c8b4c0009c19bb4e82101aacb4b998
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/6218#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F6218
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%2F6218
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/6218
Reloadhttps://github.com/microsoft/TypeScript/issues/6218
Reloadhttps://github.com/microsoft/TypeScript/issues/6218
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests334 (334)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/pulse
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/6218
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/6218
Sub-type typehttps://github.com/microsoft/TypeScript/issues/6218#top
QuestionAn issue which isn't directly actionable in codehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Question%22
https://github.com/rogierschouten
Rogier Schouten (rogierschouten)https://github.com/rogierschouten
on Dec 23, 2015https://github.com/microsoft/TypeScript/issues/6218#issue-123633967
https://facebook.github.io/react/docs/component-api.htmlhttps://facebook.github.io/react/docs/component-api.html
https://github.com/DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
on Dec 23, 2015https://github.com/microsoft/TypeScript/issues/6218#issuecomment-166979089
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
QuestionAn issue which isn't directly actionable in codehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Question%22
on Dec 23, 2015https://github.com/microsoft/TypeScript/issues/6218#event-499720118
https://github.com/rogierschouten
Rogier Schouten (rogierschouten)https://github.com/rogierschouten
on Dec 28, 2015https://github.com/microsoft/TypeScript/issues/6218#issuecomment-167512893
Daniel Rosenwasser (@DanielRosenwasser)https://github.com/DanielRosenwasser
https://github.com/lbguilherme
Guilherme Bernal (lbguilherme)https://github.com/lbguilherme
on Dec 28, 2015https://github.com/microsoft/TypeScript/issues/6218#issuecomment-167596220
Rogier Schouten (@rogierschouten)https://github.com/rogierschouten
https://github.com/DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
on Dec 28, 2015https://github.com/microsoft/TypeScript/issues/6218#issuecomment-167606048
Rogier Schouten (@rogierschouten)https://github.com/rogierschouten
https://github.com/rogierschouten
Rogier Schouten (rogierschouten)https://github.com/rogierschouten
on Dec 28, 2015https://github.com/microsoft/TypeScript/issues/6218#issuecomment-167625124
Guilherme Bernal (@lbguilherme)https://github.com/lbguilherme
https://github.com/rogierschouten
Rogier Schouten (rogierschouten)https://github.com/rogierschouten
on Dec 28, 2015https://github.com/microsoft/TypeScript/issues/6218#issuecomment-167625370
Daniel Rosenwasser (@DanielRosenwasser)https://github.com/DanielRosenwasser
https://github.com/lbguilherme
Guilherme Bernal (lbguilherme)https://github.com/lbguilherme
on Dec 28, 2015https://github.com/microsoft/TypeScript/issues/6218#issuecomment-167654003
Rogier Schouten (@rogierschouten)https://github.com/rogierschouten
https://github.com/rogierschouten
Rogier Schouten (rogierschouten)https://github.com/rogierschouten
on Jan 14, 2016https://github.com/microsoft/TypeScript/issues/6218#issuecomment-171610318
Guilherme Bernal (@lbguilherme)https://github.com/lbguilherme
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Jan 14, 2016https://github.com/microsoft/TypeScript/issues/6218#issuecomment-171765681
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jan 14, 2016https://github.com/microsoft/TypeScript/issues/6218#event-515427053
https://github.com/flyon
René Verheij (flyon)https://github.com/flyon
on Jan 24, 2016https://github.com/microsoft/TypeScript/issues/6218#issuecomment-174339648
https://github.com/mDibyo
Dibyo Majumdar (mDibyo)https://github.com/mDibyo
on Nov 17, 2016https://github.com/microsoft/TypeScript/issues/6218#issuecomment-261135286
#12114https://github.com/microsoft/TypeScript/pull/12114
microsofthttps://github.com/microsoft
on Jun 19, 2018https://github.com/microsoft/TypeScript/issues/6218#event-1689630163
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/6218
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/6218
QuestionAn issue which isn't directly actionable in codehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Question%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.