René's URL Explorer Experiment


Title: Problem with inference for this['prop'] with conditional types · Issue #27014 · microsoft/TypeScript · GitHub

Open Graph Title: Problem with inference for this['prop'] with conditional types · Issue #27014 · microsoft/TypeScript

X Title: Problem with inference for this['prop'] with conditional types · Issue #27014 · microsoft/TypeScript

Description: TypeScript Version: typescript@3.1.0-dev.20180907 Search Terms: this type, conditional type Code type Wrapped = { ___secret: T }; type Unwrap = T extends Wrapped ? U : T; declare function set(obj: T, ...

Open Graph Description: TypeScript Version: typescript@3.1.0-dev.20180907 Search Terms: this type, conditional type Code type Wrapped = { ___secret: T }; type Unwrap = T extends Wrapped ? U : T; declare fun...

X Description: TypeScript Version: typescript@3.1.0-dev.20180907 Search Terms: this type, conditional type Code type Wrapped<T> = { ___secret: T }; type Unwrap<T> = T extends Wrapped<infer U> ? ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Problem with inference for this['prop'] with conditional types","articleBody":"**TypeScript Version:**  typescript@3.1.0-dev.20180907\r\n**Search Terms:** this type, conditional type\r\n\r\n**Code**\r\n\r\n```ts\r\ntype Wrapped\u003cT> = { ___secret: T };\r\ntype Unwrap\u003cT> = T extends Wrapped\u003cinfer U> ? U : T;\r\n\r\ndeclare function set\u003cT, K extends keyof T>(obj: T, key: K, value: Unwrap\u003cT[K]>);\r\n\r\nclass Foo {\r\n    prop: Wrapped\u003cstring>;\r\n\r\n    method() {\r\n        set(this, 'prop', 'hi'); // \u003c-- type error\r\n    }\r\n}\r\n\r\nset(new Foo(), 'prop', 'hi'); // \u003c-- typechecks\r\n```\r\n\r\n**Expected behavior:**\r\nBoth calls to `set` (the one in the method with `this` and the external one with `new Foo()`) pass typechecking.\r\n\r\n**Actual behavior:**\r\nThe external call passes, but the one inside `method` fails with `Argument of type '\"hi\"' is not assignable to parameter of type 'Unwrap\u003cthis[\"prop\"]>'.`.\r\n\r\nIf I explicitly annotate `this: Foo` in the method signature or set the type parameters `set\u003cFoo, 'prop'>(...)`, everything passes.\r\n\r\nWe've run into this in the Ember type declarations, and have had to [weaken the types for the time being](https://github.com/typed-ember/ember-cli-typescript/issues/286#) to work around it.\r\n\r\n**Playground Link:** [available here](https://www.typescriptlang.org/play/#src=type%20Wrapped%3CT%3E%20%3D%20%7B%20___secret%3A%20T%20%7D%3B%0D%0Atype%20Unwrap%3CT%3E%20%3D%20T%20extends%20Wrapped%3Cinfer%20U%3E%20%3F%20U%20%3A%20T%3B%0D%0A%0D%0Adeclare%20function%20set%3CT%2C%20K%20extends%20keyof%20T%3E(obj%3A%20T%2C%20key%3A%20K%2C%20value%3A%20Unwrap%3CT%5BK%5D%3E)%3B%0D%0A%0D%0Aclass%20Foo%20%7B%0D%0A%20%20%20%20prop%3A%20Wrapped%3Cstring%3E%3B%0D%0A%0D%0A%20%20%20%20method()%20%7B%0D%0A%20%20%20%20%20%20%20%20set(this%2C%20'prop'%2C%20'hi')%3B%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A%0D%0Aset(new%20Foo()%2C%20'prop'%2C%20'hi')%3B)\r\n\r\n**Related Issues:** I wasn't able to find anything that seemed related to this issue.\r\n","author":{"url":"https://github.com/dfreeman","@type":"Person","name":"dfreeman"},"datePublished":"2018-09-10T23:38:00Z","url":"https://github.com/microsoft/TypeScript/issues/27014"}

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:d101fdd2-65e0-0a0a-0cb8-a47af9cf3c79
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9946:2463BD:1EE22D2:2772E89:6B01582E
html-safe-nonce922d53d38347e608d2932d2f865fb1f1fbc26c45a47c581e7e30d1abea151863
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTQ2OjI0NjNCRDoxRUUyMkQyOjI3NzJFODk6NkIwMTU4MkUiLCJ2aXNpdG9yX2lkIjoiNDQ5NDM0ODU3ODg0NzgwNzUzNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac32afad5b9e022d8306d5ba2c4ddebf3ad78e3eef886254890e2c847fc1f543ea
hovercard-subject-tagissue:358832996
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/27014/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4625dc5a648b3605e808bae6d84092371903d5246ed55594f8f5afd572bd3264/microsoft/TypeScript/issues/27014
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4625dc5a648b3605e808bae6d84092371903d5246ed55594f8f5afd572bd3264/microsoft/TypeScript/issues/27014
og:image:altTypeScript Version: typescript@3.1.0-dev.20180907 Search Terms: this type, conditional type Code type Wrapped = { ___secret: T }; type Unwrap = T extends Wrapped ? U : T; declare fun...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedfreeman
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/27014#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F27014
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%2F27014
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/27014
Reloadhttps://github.com/microsoft/TypeScript/issues/27014
Reloadhttps://github.com/microsoft/TypeScript/issues/27014
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests312 (312)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/27014
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/27014
Problem with inference for this['prop'] with conditional typeshttps://github.com/microsoft/TypeScript/issues/27014#top
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
Domain: Conditional TypesThe issue relates to conditional typeshttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Domain%3A%20Conditional%20Types%22
Backloghttps://github.com/microsoft/TypeScript/milestone/29
https://github.com/dfreeman
Dan Freeman (dfreeman)https://github.com/dfreeman
on Sep 10, 2018https://github.com/microsoft/TypeScript/issues/27014#issue-358832996
weaken the types for the time beinghttps://github.com/typed-ember/ember-cli-typescript/issues/286
available herehttps://www.typescriptlang.org/play/#src=type%20Wrapped%3CT%3E%20%3D%20%7B%20___secret%3A%20T%20%7D%3B%0D%0Atype%20Unwrap%3CT%3E%20%3D%20T%20extends%20Wrapped%3Cinfer%20U%3E%20%3F%20U%20%3A%20T%3B%0D%0A%0D%0Adeclare%20function%20set%3CT%2C%20K%20extends%20keyof%20T%3E(obj%3A%20T%2C%20key%3A%20K%2C%20value%3A%20Unwrap%3CT%5BK%5D%3E)%3B%0D%0A%0D%0Aclass%20Foo%20%7B%0D%0A%20%20%20%20prop%3A%20Wrapped%3Cstring%3E%3B%0D%0A%0D%0A%20%20%20%20method()%20%7B%0D%0A%20%20%20%20%20%20%20%20set(this%2C%20'prop'%2C%20'hi')%3B%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A%0D%0Aset(new%20Foo()%2C%20'prop'%2C%20'hi')%3B
Mike North (mike-north)https://github.com/mike-north
on Sep 15, 2018https://github.com/microsoft/TypeScript/issues/27014#event-1847691816
[ember] relax types around Ember.set,setPropertieshttps://github.com/mike-north/DefinitelyTyped/commit/952f3d3463fdadcbe48a3b3376ef566cb8a72169
952f3d3https://github.com/mike-north/DefinitelyTyped/commit/952f3d3463fdadcbe48a3b3376ef566cb8a72169
[ember] relax types around Ember.set,setPropertieshttps://github.com/mike-north/DefinitelyTyped/commit/cf85b01d7fd5c2950932d804fc4b78caeec07408
cf85b01https://github.com/mike-north/DefinitelyTyped/commit/cf85b01d7fd5c2950932d804fc4b78caeec07408
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Sep 17, 2018https://github.com/microsoft/TypeScript/issues/27014#event-1849008737
[ember] relax types around Ember.set & setProperties (#28915)https://github.com/DefinitelyTyped/DefinitelyTyped/commit/6c340ade7489f7785cd5969f03ba3120bb3f6ad6
#28915https://github.com/DefinitelyTyped/DefinitelyTyped/pull/28915
6c340adhttps://github.com/DefinitelyTyped/DefinitelyTyped/commit/6c340ade7489f7785cd5969f03ba3120bb3f6ad6
Wesley Wigham (weswigham)https://github.com/weswigham
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
on Sep 17, 2018https://github.com/microsoft/TypeScript/issues/27014#event-1850678258
https://github.com/weswigham
Wesley Wigham (weswigham)https://github.com/weswigham
on Sep 17, 2018https://github.com/microsoft/TypeScript/issues/27014#issuecomment-422146197
#27012https://github.com/microsoft/TypeScript/pull/27012
https://github.com/dfreeman
Dan Freeman (dfreeman)https://github.com/dfreeman
on Sep 18, 2018https://github.com/microsoft/TypeScript/issues/27014#issuecomment-422220224
Wesley Wigham (@weswigham)https://github.com/weswigham
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 3.1.3https://github.com/microsoft/TypeScript/milestone/80
on Oct 9, 2018https://github.com/microsoft/TypeScript/issues/27014#event-1894152569
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
TypeScript 3.1.3https://github.com/microsoft/TypeScript/milestone/80
TypeScript 3.1.4https://github.com/microsoft/TypeScript/milestone/81
on Oct 11, 2018https://github.com/microsoft/TypeScript/issues/27014#event-1898957760
Daniel Rosenwasser (DanielRosenwasser)https://github.com/DanielRosenwasser
Wesley Wigham (weswigham)https://github.com/weswigham
on Oct 11, 2018https://github.com/microsoft/TypeScript/issues/27014#event-1898958044
Wesley Wigham (weswigham)https://github.com/weswigham
Domain: Conditional TypesThe issue relates to conditional typeshttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Domain%3A%20Conditional%20Types%22
on Oct 16, 2018https://github.com/microsoft/TypeScript/issues/27014#event-1908019708
https://github.com/weswigham
Wesley Wigham (weswigham)https://github.com/weswigham
on Oct 16, 2018https://github.com/microsoft/TypeScript/issues/27014#issuecomment-430434689
Daniel Rosenwasser (@DanielRosenwasser)https://github.com/DanielRosenwasser
https://github.com/dfreeman
Dan Freeman (dfreeman)https://github.com/dfreeman
on Oct 18, 2018https://github.com/microsoft/TypeScript/issues/27014#issuecomment-430839556
https://github.com/weswigham
Wesley Wigham (weswigham)https://github.com/weswigham
on Oct 18, 2018https://github.com/microsoft/TypeScript/issues/27014#issuecomment-430840630
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 3.1.4https://github.com/microsoft/TypeScript/milestone/81
TypeScript 3.7.0https://github.com/microsoft/TypeScript/milestone/98
on Jul 16, 2019https://github.com/microsoft/TypeScript/issues/27014#event-2486982000
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 3.7.0https://github.com/microsoft/TypeScript/milestone/98
TypeScript 3.7.1https://github.com/microsoft/TypeScript/milestone/105
on Oct 14, 2019https://github.com/microsoft/TypeScript/issues/27014#event-2711297988
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 3.7.1https://github.com/microsoft/TypeScript/milestone/105
TypeScript 3.8.0https://github.com/microsoft/TypeScript/milestone/102
on Oct 29, 2019https://github.com/microsoft/TypeScript/issues/27014#event-2752908195
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 3.8.0https://github.com/microsoft/TypeScript/milestone/102
TypeScript 3.8.1https://github.com/microsoft/TypeScript/milestone/107
on Jan 8, 2020https://github.com/microsoft/TypeScript/issues/27014#event-2932101745
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 3.8.1https://github.com/microsoft/TypeScript/milestone/107
Backloghttps://github.com/microsoft/TypeScript/milestone/29
on Jan 23, 2020https://github.com/microsoft/TypeScript/issues/27014#event-2975658886
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Wesley Wigham (weswigham)https://github.com/weswigham
on Jan 23, 2020https://github.com/microsoft/TypeScript/issues/27014#event-2975658975
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Aug 26, 2026https://github.com/microsoft/TypeScript/issues/27014#issuecomment-5429734370
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Needs Human ReviewThis issue has a backlog check awaiting maintainer review.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Human%20Review%22
on Aug 26, 2026https://github.com/microsoft/TypeScript/issues/27014#event-30062468522
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Aug 26, 2026https://github.com/microsoft/TypeScript/issues/27014#event-30062470342
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Needs Human ReviewThis issue has a backlog check awaiting maintainer review.https://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Needs%20Human%20Review%22
on Sep 23, 2026https://github.com/microsoft/TypeScript/issues/27014#event-31702031946
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/27014
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/27014
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
Domain: Conditional TypesThe issue relates to conditional typeshttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Domain%3A%20Conditional%20Types%22
BacklogNo due datehttps://github.com/microsoft/TypeScript/milestone/29
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.