René's URL Explorer Experiment


Title: `keyof` should always include remapped keys by weswigham · Pull Request #45923 · microsoft/TypeScript · GitHub

Open Graph Title: `keyof` should always include remapped keys by weswigham · Pull Request #45923 · microsoft/TypeScript

X Title: `keyof` should always include remapped keys by weswigham · Pull Request #45923 · microsoft/TypeScript

Description: Fixes #45825 To do this, I've extracted some of the functionality of resolvemappedTypeMembers into a common helper and reused it in getIndexTypeForMappedType. Doing this correctly necessitates looking at the apparent keys of the input MappedType's modifiersType if present, which causes new circularity issues in some edge cases involving infer conditionals - to avoid those, we defer expanding the keyof in cases where the constraint remains generic, and instead handle membership testing later in relationship checking, with a new relationship rule that can pull the concrete key names out of a target generic keyof MappedType type. If you have something that is generic (because, eg, it has a homomorphic mapping over the properties of a type with both generic and nongeneric parts), you can still assign to the known bits of the (remapped) key list. In this way a still-generic keyof {[X in keyof (Whatever & T) as Modify]: Stuff} can behave like a foreach K in (keyof Whatever | Keyof T) -> Modify on the target side. Eg, function func() { type Composite = T & { "a key": any; [idx: string]: any }; type Modify = [X]extends ["a key"] ? "b key" : never; const key: keyof {[X in keyof Composite as Modify]: any} = "b key"; } now works, while it did not before. As a nice side effect of reusing more mapped type member machinery, this discussion is pretty neatly resolved - since the string indexer is mapped to never, the number type is no longer included.

Open Graph Description: Fixes #45825 To do this, I've extracted some of the functionality of resolvemappedTypeMembers into a common helper and reused it in getIndexTypeForMappedType. Doing this correctly necessitates ...

X Description: Fixes #45825 To do this, I've extracted some of the functionality of resolvemappedTypeMembers into a common helper and reused it in getIndexTypeForMappedType. Doing this correctly necessita...

Opengraph URL: https://github.com/microsoft/TypeScript/pull/45923

X: @github

direct link

Domain: github.com

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/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:af3584a3-9331-20d6-a995-384c121550d2
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idCF10:8AE25:8B8BFF:B8DFC8:6B01B388
html-safe-noncee83051dedd7ee7f546a0e24fbd90bad97b6cabc4a9742b16b38a707c73ca3ff4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRjEwOjhBRTI1OjhCOEJGRjpCOERGQzg6NkIwMUIzODgiLCJ2aXNpdG9yX2lkIjoiMTI1MjgyNzQ5NjU4ODYyMDY4MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac7fcd0bc706dcc3784a3d07afcff8311a92a0714bec82ebc05d8a681870782195
hovercard-subject-tagpull_request:735947464
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/microsoft/TypeScript/pull/45923/files
twitter:imagehttps://avatars.githubusercontent.com/u/2932786?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/2932786?s=400&v=4
og:image:altFixes #45825 To do this, I've extracted some of the functionality of resolvemappedTypeMembers into a common helper and reused it in getIndexTypeForMappedType. Doing this correctly necessitates ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
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 full-width
disable-turbotrue
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

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/pull/45923/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fpull%2F45923%2Ffiles
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%2Fpull%2F45923%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=microsoft%2FTypeScript
Reloadhttps://github.com/microsoft/TypeScript/pull/45923/files
Reloadhttps://github.com/microsoft/TypeScript/pull/45923/files
Reloadhttps://github.com/microsoft/TypeScript/pull/45923/files
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
Sign up for GitHub https://github.com/signup?return_to=%2Fmicrosoft%2FTypeScript%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmicrosoft%2FTypeScript%2Fissues%2Fnew%2Fchoose
Wesley Wigham (weswigham)https://github.com/weswigham
microsoft:mainhttps://github.com/microsoft/TypeScript/tree/main
weswigham:name-remapping-includes-string-keys-when-symbol-presenthttps://github.com/weswigham/TypeScript/tree/name-remapping-includes-string-keys-when-symbol-present
Conversation 1 https://github.com/microsoft/TypeScript/pull/45923
Commits 3 https://github.com/microsoft/TypeScript/pull/45923/commits
Checks 0 https://github.com/microsoft/TypeScript/pull/45923/checks
Files changed https://github.com/microsoft/TypeScript/pull/45923/files
Please reload this pagehttps://github.com/microsoft/TypeScript/pull/45923/files
keyof should always include remapped keys https://github.com/microsoft/TypeScript/pull/45923/files#top
Show all changes 3 commits https://github.com/microsoft/TypeScript/pull/45923/files
19944df Loosen check in getIndexTypeForMappedType to directly map property na… weswigham Sep 16, 2021 https://github.com/microsoft/TypeScript/pull/45923/commits/19944dfafff8af4a7e7305d46dd2b1ebceb2b8eb
18285f7 Handle homomorphic mappings better in keyof, add specific relationshi… weswigham Sep 17, 2021 https://github.com/microsoft/TypeScript/pull/45923/commits/18285f7f6b0a420c19199beca87cfeeb58eeaf09
6327c7b Remove trailing whitespace weswigham Sep 24, 2021 https://github.com/microsoft/TypeScript/pull/45923/commits/6327c7b7dcd39393e8212efe18530c329a10ef7a
Clear filters https://github.com/microsoft/TypeScript/pull/45923/files
Please reload this pagehttps://github.com/microsoft/TypeScript/pull/45923/files
Please reload this pagehttps://github.com/microsoft/TypeScript/pull/45923/files
checker.ts https://github.com/microsoft/TypeScript/pull/45923/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8
computedTypesKeyofNoIndexSignatureType.types https://github.com/microsoft/TypeScript/pull/45923/files#diff-eb98351632f8622d44e94ee83acefb2349a39e74ee06c66716bc7f398ec7bf8a
keyRemappingKeyofResult.js https://github.com/microsoft/TypeScript/pull/45923/files#diff-575005b958bd69516e647812b49369020266bb7a1c93441af8e4c92a8f56d9d2
keyRemappingKeyofResult.symbols https://github.com/microsoft/TypeScript/pull/45923/files#diff-5ce98bf587b6960a06b7797f3a0cba86b3b7f91f10469280898e4382f8f76f0b
keyRemappingKeyofResult.types https://github.com/microsoft/TypeScript/pull/45923/files#diff-a29f12feeeb4d7d36c4f7d3cb50cf4825795ed3a55374ed49220d4198bbda634
mappedTypeAsClauses.types https://github.com/microsoft/TypeScript/pull/45923/files#diff-3834579966c9d8cca336189df57d27d74a539768bb6f8b5728eaf08bcb149da1
keyRemappingKeyofResult.ts https://github.com/microsoft/TypeScript/pull/45923/files#diff-7c3609bf5fb72f19421a8224f5eb12202338bf245af07570a109eda154b4f092
src/compiler/checker.tshttps://github.com/microsoft/TypeScript/pull/45923/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8
View file https://github.com/weswigham/TypeScript/blob/6327c7b7dcd39393e8212efe18530c329a10ef7a/src/compiler/checker.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/microsoft/TypeScript/pull/45923/{{ revealButtonHref }}
https://github.com/microsoft/TypeScript/pull/45923/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8
https://github.com/microsoft/TypeScript/pull/45923/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8
https://github.com/microsoft/TypeScript/pull/45923/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8
https://github.com/microsoft/TypeScript/pull/45923/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8
https://github.com/microsoft/TypeScript/pull/45923/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8
https://github.com/microsoft/TypeScript/pull/45923/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8
https://github.com/microsoft/TypeScript/pull/45923/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8
https://github.com/microsoft/TypeScript/pull/45923/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8
https://github.com/microsoft/TypeScript/pull/45923/files#diff-d9ab6589e714c71e657f601cf30ff51dfc607fc98419bf72e04f6b0fa92cc4b8
tests/baselines/reference/computedTypesKeyofNoIndexSignatureType.typeshttps://github.com/microsoft/TypeScript/pull/45923/files#diff-eb98351632f8622d44e94ee83acefb2349a39e74ee06c66716bc7f398ec7bf8a
View file https://github.com/weswigham/TypeScript/blob/6327c7b7dcd39393e8212efe18530c329a10ef7a/tests/baselines/reference/computedTypesKeyofNoIndexSignatureType.types
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/microsoft/TypeScript/pull/45923/{{ revealButtonHref }}
https://github.com/microsoft/TypeScript/pull/45923/files#diff-eb98351632f8622d44e94ee83acefb2349a39e74ee06c66716bc7f398ec7bf8a
tests/baselines/reference/keyRemappingKeyofResult.jshttps://github.com/microsoft/TypeScript/pull/45923/files#diff-575005b958bd69516e647812b49369020266bb7a1c93441af8e4c92a8f56d9d2
View file https://github.com/weswigham/TypeScript/blob/6327c7b7dcd39393e8212efe18530c329a10ef7a/tests/baselines/reference/keyRemappingKeyofResult.js
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/microsoft/TypeScript/pull/45923/{{ revealButtonHref }}
Please reload this pagehttps://github.com/microsoft/TypeScript/pull/45923/files
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.