René's URL Explorer Experiment


Title: Cannot define getter and setter, getting an error: "circularly references itself in mapped type" · Issue #44906 · microsoft/TypeScript · GitHub

Open Graph Title: Cannot define getter and setter, getting an error: "circularly references itself in mapped type" · Issue #44906 · microsoft/TypeScript

X Title: Cannot define getter and setter, getting an error: "circularly references itself in mapped type" · Issue #44906 · microsoft/TypeScript

Description: Cannot define getter and setter, getting an error: "Type of property '..' circularly references itself in mapped type ..." interface User { firstName: string, level: number, get bestFriend(): User set bestFriend(user: SerializablePartial...

Open Graph Description: Cannot define getter and setter, getting an error: "Type of property '..' circularly references itself in mapped type ..." interface User { firstName: string, level: number, get bestFriend(): User ...

X Description: Cannot define getter and setter, getting an error: "Type of property '..' circularly references itself in mapped type ..." interface User { firstName: string, level: number, get b...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cannot define getter and setter, getting an error: \"circularly references itself in mapped type\"","articleBody":"Cannot define getter and setter, getting an error: \"Type of property '..' circularly references itself in mapped type ...\"\r\n```\r\ninterface User {\r\n    firstName: string,\r\n    level: number,\r\n    get bestFriend(): User\r\n    set bestFriend(user: SerializablePartial\u003cUser>)\r\n}\r\n\r\ntype FilteredKeys\u003cT> = { [K in keyof T]: T[K] extends number ? K : T[K] extends string ? K : T[K] extends boolean ? K : never }[keyof T];\r\n\r\ntype SerializablePartial\u003cT> = {\r\n    [K in FilteredKeys\u003cT>]: T[K]\r\n};\r\n```\r\nError: `Type of property 'bestFriend' circularly references itself in mapped type '{ [K in keyof User]: User[K] extends number ? K : User[K] extends string ? K : User[K] extends boolean ? K : never; }'.(2615)`, [Link to playground](https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgKoGdrIN4ChkHIzBTpgBycAthAFzJlSgDmANPoQDYQBuEn9EAFcqAI2jtCyZhDDJxZAGJMIIACYAKAJT0M0DgUxyFYZcFWahmKPQDK0YHE7AAXnFHcACnChhHnAB49KAA+LVwAX1xcMABPAAcURWBOSCgINQBpCFj0AIAVEOQAXhxkAG1M5FBkAGscgHsYZHyAXXp8ytbkCAAPSHV0ZGExLAB+ZCqOrp7+iyHGFmQJqZaZvoG1IdEGhu44EGXJ5EFeLAjy+timltaAbmi4xOR7JidXdy8fPycCotK8FJKtVDslUtAMtlcn92mtMq1IncgA)\r\n\r\nAnd here is almost the same valid example without error where I only changed getter `get bestFriend(): User` to method `getBestFriend(): User` and setter `set bestFriend(user: SerializablePartial\u003cUser>)` to method `setBestFriend(user: SerializablePartial\u003cUser>): void`. [Link to playground](https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgKoGdrIN4ChkHIzBTpgBycAthAFzJlSgDmANPoQDYQBuEn9EAFcqAI2jtCyZhDAAhCGQBiTCCAAmACgCU9DNA4FM8xWBXA1WoZij0AytGBxOwAF5xR3AApwoYJ5wAPPpQAHy6yDwA9sDquAC+uLhgAJ4ADihKwJyQUBDqANIQKeiBACqhyAC8OMgA2gXIoMgA1sVRMMhlALr0ZQ3dyBAAHpAa6MjCYlgA-MiNfQNDo5YTjCzIcwtdSyNj6hOiUVHccCCb88iCvFjxdW0pHV3dANxJqRnIDkzObh7evn8znKlRqeCkDSa5yyOWg+SKJRBvR2BW6CReQA)\r\n```\r\ninterface User {\r\n    firstName: string,\r\n    level: number,\r\n    getBestFriend(): User\r\n    setBestFriend(user: SerializablePartial\u003cUser>): void\r\n}\r\n\r\ntype FilteredKeys\u003cT> = { [K in keyof T]: T[K] extends number ? K : T[K] extends string ? K : T[K] extends boolean ? K : never }[keyof T];\r\n\r\ntype SerializablePartial\u003cT> = {\r\n    [K in FilteredKeys\u003cT>]: T[K]\r\n};\r\n```\r\nSo semantically it's all the same, the difference is only in syntactic sugar - using getter and setter instead of \"getX\" and \"setX\" methods and seems like it should have the same type checking path\r\n\r\n### 🔎 Search Terms\r\n\r\n`circularly references itself in mapped type`\r\n\r\n### 🕗 Version & Regression Information\r\n\r\nv4.3.5\r\n\r\n### ⏯ Playground Link\r\n\r\n[Playground link with bug](https://www.typescriptlang.org/play?ts=4.3.5#code/JYOwLgpgTgZghgYwgAgKoGdrIN4ChkHIzBTpgBycAthAFzJlSgDmANPoQDYQBuEn9EAFcqAI2jtCyZhDDJxZAGJMIIACYAKAJT0M0DgUxyFYZcFWahmKPQDK0YHE7AAXnFHcACnChhHnAB49KAA+LVwAX1xcMABPAAcURWBOSCgINQBpCFj0AIAVEOQAXhxkAG1M5FBkAGscgHsYZHyAXXp8ytbkCAAPSHV0ZGExLAB+ZCqOrp7+iyHGFmQJqZaZvoG1IdEGhu44EGXJ5EFeLAjy+timltaAbmi4xOR7JidXdy8fPycCotK8FJKtVDslUtAMtlcn92mtMq1IncgA)\r\n\r\n[Playground link with working get-set-methods version](https://www.typescriptlang.org/play?ts=4.3.5#code/JYOwLgpgTgZghgYwgAgKoGdrIN4ChkHIzBTpgBycAthAFzJlSgDmANPoQDYQBuEn9EAFcqAI2jtCyZhDAAhCGQBiTCCAAmACgCU9DNA4FM8xWBXA1WoZij0AytGBxOwAF5xR3AApwoYJ5wAPPpQAHy6yDwA9sDquAC+uLhgAJ4ADihKwJyQUBDqANIQKeiBACqhyAC8OMgA2gXIoMgA1sVRMMhlALr0ZQ3dyBAAHpAa6MjCYlgA-MiNfQNDo5YTjCzIcwtdSyNj6hOiUVHccCCb88iCvFjxdW0pHV3dANxJqRnIDkzObh7evn8znKlRqeCkDSa5yyOWg+SKJRBvR2BW6CReQA)\r\n\r\n\r\n### 🙁 Actual behavior\r\n\r\ngetting an error\r\n\r\n\r\n### 🙂 Expected behavior\r\n\r\nno error\r\n\r\n### Relevant issue \r\n\r\nThere already was some issue with \"circularly references itself in mapped type\" in https://github.com/microsoft/TypeScript/issues/38279 and it was fixed in https://github.com/microsoft/TypeScript/pull/38653 but seems like it was the fix only for methods not for getter/setters","author":{"url":"https://github.com/bgnx","@type":"Person","name":"bgnx"},"datePublished":"2021-07-06T06:05:50Z","url":"https://github.com/microsoft/TypeScript/issues/44906"}

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:7b238085-26f7-b971-d321-8e1834f5ae60
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAF52:1C6C3E:D481A5:1194666:6B00F968
html-safe-nonceb73281c16912411a8c2a532a5e558b2ee57a8b0a458786e0635318f573693836
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjUyOjFDNkMzRTpENDgxQTU6MTE5NDY2Njo2QjAwRjk2OCIsInZpc2l0b3JfaWQiOiIzODg5ODI3NDA5MzM1MjIwNTg0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac8f98ba345952eff6e9280e6bcd8bf24952b90e62a92ae516c3e8c905e449e3f8
hovercard-subject-tagissue:937549040
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/44906/issue_layout
twitter:imagehttps://opengraph.githubassets.com/79ca8c4bdb4ac80100c1edac55781e32376265b1a409ae38e8f162cbda0ef56e/microsoft/TypeScript/issues/44906
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/79ca8c4bdb4ac80100c1edac55781e32376265b1a409ae38e8f162cbda0ef56e/microsoft/TypeScript/issues/44906
og:image:altCannot define getter and setter, getting an error: "Type of property '..' circularly references itself in mapped type ..." interface User { firstName: string, level: number, get bestFriend(): User ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebgnx
hostnamegithub.com
expected-hostnamegithub.com
Nonee208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187
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
release7dafd017fb7809a839c443dba08622af38e63c09
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/44906#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F44906
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%2F44906
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/44906
Reloadhttps://github.com/microsoft/TypeScript/issues/44906
Reloadhttps://github.com/microsoft/TypeScript/issues/44906
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests309 (309)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/44906
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/44906
#47818https://github.com/microsoft/TypeScript/pull/47818
Cannot define getter and setter, getting an error: "circularly references itself in mapped type"https://github.com/microsoft/TypeScript/issues/44906#top
#47818https://github.com/microsoft/TypeScript/pull/47818
https://github.com/andrewbranch
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
Fix AvailableA PR has been opened for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fix%20Available%22
RescheduledThis issue was previously scheduled to an earlier milestonehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Rescheduled%22
TypeScript 4.6.1https://github.com/microsoft/TypeScript/milestone/158
https://github.com/bgnx
bgnxhttps://github.com/bgnx
on Jul 6, 2021https://github.com/microsoft/TypeScript/issues/44906#issue-937549040
Link to playgroundhttps://www.typescriptlang.org/play#code/JYOwLgpgTgZghgYwgAgKoGdrIN4ChkHIzBTpgBycAthAFzJlSgDmANPoQDYQBuEn9EAFcqAI2jtCyZhDDJxZAGJMIIACYAKAJT0M0DgUxyFYZcFWahmKPQDK0YHE7AAXnFHcACnChhHnAB49KAA+LVwAX1xcMABPAAcURWBOSCgINQBpCFj0AIAVEOQAXhxkAG1M5FBkAGscgHsYZHyAXXp8ytbkCAAPSHV0ZGExLAB+ZCqOrp7+iyHGFmQJqZaZvoG1IdEGhu44EGXJ5EFeLAjy+timltaAbmi4xOR7JidXdy8fPycCotK8FJKtVDslUtAMtlcn92mtMq1IncgA
Link to playgroundhttps://www.typescriptlang.org/play#code/JYOwLgpgTgZghgYwgAgKoGdrIN4ChkHIzBTpgBycAthAFzJlSgDmANPoQDYQBuEn9EAFcqAI2jtCyZhDAAhCGQBiTCCAAmACgCU9DNA4FM8xWBXA1WoZij0AytGBxOwAF5xR3AApwoYJ5wAPPpQAHy6yDwA9sDquAC+uLhgAJ4ADihKwJyQUBDqANIQKeiBACqhyAC8OMgA2gXIoMgA1sVRMMhlALr0ZQ3dyBAAHpAa6MjCYlgA-MiNfQNDo5YTjCzIcwtdSyNj6hOiUVHccCCb88iCvFjxdW0pHV3dANxJqRnIDkzObh7evn8znKlRqeCkDSa5yyOWg+SKJRBvR2BW6CReQA
Playground link with bughttps://www.typescriptlang.org/play?ts=4.3.5#code/JYOwLgpgTgZghgYwgAgKoGdrIN4ChkHIzBTpgBycAthAFzJlSgDmANPoQDYQBuEn9EAFcqAI2jtCyZhDDJxZAGJMIIACYAKAJT0M0DgUxyFYZcFWahmKPQDK0YHE7AAXnFHcACnChhHnAB49KAA+LVwAX1xcMABPAAcURWBOSCgINQBpCFj0AIAVEOQAXhxkAG1M5FBkAGscgHsYZHyAXXp8ytbkCAAPSHV0ZGExLAB+ZCqOrp7+iyHGFmQJqZaZvoG1IdEGhu44EGXJ5EFeLAjy+timltaAbmi4xOR7JidXdy8fPycCotK8FJKtVDslUtAMtlcn92mtMq1IncgA
Playground link with working get-set-methods versionhttps://www.typescriptlang.org/play?ts=4.3.5#code/JYOwLgpgTgZghgYwgAgKoGdrIN4ChkHIzBTpgBycAthAFzJlSgDmANPoQDYQBuEn9EAFcqAI2jtCyZhDAAhCGQBiTCCAAmACgCU9DNA4FM8xWBXA1WoZij0AytGBxOwAF5xR3AApwoYJ5wAPPpQAHy6yDwA9sDquAC+uLhgAJ4ADihKwJyQUBDqANIQKeiBACqhyAC8OMgA2gXIoMgA1sVRMMhlALr0ZQ3dyBAAHpAa6MjCYlgA-MiNfQNDo5YTjCzIcwtdSyNj6hOiUVHccCCb88iCvFjxdW0pHV3dANxJqRnIDkzObh7evn8znKlRqeCkDSa5yyOWg+SKJRBvR2BW6CReQA
#38279https://github.com/microsoft/TypeScript/issues/38279
#38653https://github.com/microsoft/TypeScript/pull/38653
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
on Jul 7, 2021https://github.com/microsoft/TypeScript/issues/44906#event-4991499890
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Andrew Branch (andrewbranch)https://github.com/andrewbranch
on Jul 7, 2021https://github.com/microsoft/TypeScript/issues/44906#event-4991500153
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 4.5.0https://github.com/microsoft/TypeScript/milestone/147
on Jul 7, 2021https://github.com/microsoft/TypeScript/issues/44906#event-4991500271
Andrew Branch (andrewbranch)https://github.com/andrewbranch
TypeScript 4.5.0https://github.com/microsoft/TypeScript/milestone/147
TypeScript 4.5.1https://github.com/microsoft/TypeScript/milestone/150
on Oct 8, 2021https://github.com/microsoft/TypeScript/issues/44906#event-5435955575
Andrew Branch (andrewbranch)https://github.com/andrewbranch
RescheduledThis issue was previously scheduled to an earlier milestonehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Rescheduled%22
on Dec 7, 2021https://github.com/microsoft/TypeScript/issues/44906#event-5729224574
Andrew Branch (andrewbranch)https://github.com/andrewbranch
TypeScript 4.5.1https://github.com/microsoft/TypeScript/milestone/150
TypeScript 4.6.0https://github.com/microsoft/TypeScript/milestone/151
on Dec 7, 2021https://github.com/microsoft/TypeScript/issues/44906#event-5729226602
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 4.6.0https://github.com/microsoft/TypeScript/milestone/151
TypeScript 4.6.1https://github.com/microsoft/TypeScript/milestone/158
on Feb 3, 2022https://github.com/microsoft/TypeScript/issues/44906#event-6005675943
TypeScript Bot (typescript-bot)https://github.com/typescript-bot
Fix AvailableA PR has been opened for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fix%20Available%22
on Feb 9, 2022https://github.com/microsoft/TypeScript/issues/44906#event-6036380940
Andrew Branch (andrewbranch)https://github.com/andrewbranch
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#47818https://github.com/microsoft/TypeScript/pull/47818
on Feb 9, 2022https://github.com/microsoft/TypeScript/issues/44906#event-6036658292
microsofthttps://github.com/microsoft
on Oct 21, 2025https://github.com/microsoft/TypeScript/issues/44906#event-20417423113
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/44906
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/44906
Andrew Branch (andrewbranch)https://github.com/andrewbranch
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
Fix AvailableA PR has been opened for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fix%20Available%22
RescheduledThis issue was previously scheduled to an earlier milestonehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Rescheduled%22
TypeScript 4.6.1https://github.com/microsoft/TypeScript/milestone/158
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.