René's URL Explorer Experiment


Title: Generic lookup type wrongly narrowed to `never` with strictNullChecks · Issue #26130 · microsoft/TypeScript · GitHub

Open Graph Title: Generic lookup type wrongly narrowed to `never` with strictNullChecks · Issue #26130 · microsoft/TypeScript

X Title: Generic lookup type wrongly narrowed to `never` with strictNullChecks · Issue #26130 · microsoft/TypeScript

Description: I ran across this while migrating my project to strictNullChecks and it's positively bizarre. TypeScript Version: master (50f442f) Search Terms: mapped type narrow narrowing null strictNullChecks never Code (with strictNullChecks) let ma...

Open Graph Description: I ran across this while migrating my project to strictNullChecks and it's positively bizarre. TypeScript Version: master (50f442f) Search Terms: mapped type narrow narrowing null strictNullChecks n...

X Description: I ran across this while migrating my project to strictNullChecks and it's positively bizarre. TypeScript Version: master (50f442f) Search Terms: mapped type narrow narrowing null strictNullChec...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Generic lookup type wrongly narrowed to `never` with strictNullChecks","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n  * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n  * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n-->\r\n\r\nI ran across this while migrating my project to `strictNullChecks` and it's positively bizarre.\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:**  master (50f442f)\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** mapped type narrow narrowing null strictNullChecks never\r\n\r\n**Code** (with `strictNullChecks`)\r\n\r\n```ts\r\nlet mappedObject: {[K in \"foo\"]: null | {x: string}} = {foo: {x: \"hello\"}};\r\ndeclare function foo\u003cT>(x: T): null | T;\r\n\r\nfunction bar\u003cK extends \"foo\">(key: K) {\r\n  const element = foo(mappedObject[key]);\r\n  if (element == null)\r\n    return;\r\n  const x = element.x;\r\n}\r\n```\r\n\r\n**Expected behavior:** Compile without error.\r\n\r\n**Actual behavior:** Error: Property 'x' does not exist on type 'never'.\r\n\r\n**Playground Link:** [link](https://www.typescriptlang.org/play/#src=let%20mappedObject%3A%20%7B%5BK%20in%20%22foo%22%5D%3A%20null%20%7C%20%7Bx%3A%20string%7D%7D%20%3D%20%7Bfoo%3A%20%7Bx%3A%20%22hello%22%7D%7D%3B%0D%0Adeclare%20function%20foo%3CT%3E(x%3A%20T)%3A%20null%20%7C%20T%3B%0D%0A%0D%0Afunction%20bar%3CK%20extends%20%22foo%22%3E(key%3A%20K)%20%7B%0D%0A%20%20const%20element%20%3D%20foo(mappedObject%5Bkey%5D)%3B%0D%0A%20%20if%20(element%20%3D%3D%20null)%0D%0A%20%20%20%20return%3B%0D%0A%20%20const%20x%20%3D%20element.x%3B%0D%0A%7D%0D%0A) (remember to enable strictNullChecks)\r\n\r\n**Related Issues:** Didn't find any.\r\n","author":{"url":"https://github.com/mattmccutchen","@type":"Person","name":"mattmccutchen"},"datePublished":"2018-08-01T21:39:06Z","url":"https://github.com/microsoft/TypeScript/issues/26130"}

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:f7348cd2-7ac7-7b6a-ae51-06998d00c436
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA652:213839:2C2BFB1:3876419:6B01A710
html-safe-nonceee0d2502770b4c9919446b819a3b7e915e5a90a8a6b3d713db22305c3df2f642
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjUyOjIxMzgzOToyQzJCRkIxOjM4NzY0MTk6NkIwMUE3MTAiLCJ2aXNpdG9yX2lkIjoiNzEwNjk5MTE5OTQ4MjkxNDU3NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacdcf13f1d6f237d172876d0ad8bccf5d1bd3c7f6287f9cff0367a864d4a3868ae
hovercard-subject-tagissue:346779348
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/26130/issue_layout
twitter:imagehttps://opengraph.githubassets.com/674dd74d6347acce93e1ab8d56bf4b2b4627e4c5b1dc112c78ac6b1989cae4bd/microsoft/TypeScript/issues/26130
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/674dd74d6347acce93e1ab8d56bf4b2b4627e4c5b1dc112c78ac6b1989cae4bd/microsoft/TypeScript/issues/26130
og:image:altI ran across this while migrating my project to strictNullChecks and it's positively bizarre. TypeScript Version: master (50f442f) Search Terms: mapped type narrow narrowing null strictNullChecks n...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemattmccutchen
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-targetcanary-2
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/26130#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F26130
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%2F26130
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/26130
Reloadhttps://github.com/microsoft/TypeScript/issues/26130
Reloadhttps://github.com/microsoft/TypeScript/issues/26130
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/26130
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/26130
Generic lookup type wrongly narrowed to never with strictNullCheckshttps://github.com/microsoft/TypeScript/issues/26130#top
https://github.com/ahejlsberg
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
TypeScript 3.1https://github.com/microsoft/TypeScript/milestone/74
https://github.com/mattmccutchen
Matt McCutchen (mattmccutchen)https://github.com/mattmccutchen
on Aug 1, 2018https://github.com/microsoft/TypeScript/issues/26130#issue-346779348
50f442fhttps://github.com/microsoft/TypeScript/commit/50f442f9fffcba9ad5a62a62dd6c931db083c890
linkhttps://www.typescriptlang.org/play/#src=let%20mappedObject%3A%20%7B%5BK%20in%20%22foo%22%5D%3A%20null%20%7C%20%7Bx%3A%20string%7D%7D%20%3D%20%7Bfoo%3A%20%7Bx%3A%20%22hello%22%7D%7D%3B%0D%0Adeclare%20function%20foo%3CT%3E(x%3A%20T)%3A%20null%20%7C%20T%3B%0D%0A%0D%0Afunction%20bar%3CK%20extends%20%22foo%22%3E(key%3A%20K)%20%7B%0D%0A%20%20const%20element%20%3D%20foo(mappedObject%5Bkey%5D)%3B%0D%0A%20%20if%20(element%20%3D%3D%20null)%0D%0A%20%20%20%20return%3B%0D%0A%20%20const%20x%20%3D%20element.x%3B%0D%0A%7D%0D%0A
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
on Aug 1, 2018https://github.com/microsoft/TypeScript/issues/26130#event-1766369967
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Aug 1, 2018https://github.com/microsoft/TypeScript/issues/26130#issuecomment-409741699
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Aug 1, 2018https://github.com/microsoft/TypeScript/issues/26130#event-1766371108
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
TypeScript 3.1https://github.com/microsoft/TypeScript/milestone/74
on Aug 1, 2018https://github.com/microsoft/TypeScript/issues/26130#event-1766371144
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Aug 1, 2018https://github.com/microsoft/TypeScript/issues/26130#issuecomment-409741809
https://github.com/weswigham
Wesley Wigham (weswigham)https://github.com/weswigham
on Aug 2, 2018https://github.com/microsoft/TypeScript/issues/26130#issuecomment-409763584
#16945https://github.com/microsoft/TypeScript/issues/16945
https://github.com/mattmccutchen
Matt McCutchen (mattmccutchen)https://github.com/mattmccutchen
on Aug 2, 2018https://github.com/microsoft/TypeScript/issues/26130#issuecomment-409787978
Matt McCutchen (mattmccutchen)https://github.com/mattmccutchen
on Aug 2, 2018https://github.com/microsoft/TypeScript/issues/26130#event-1766694686
Have getAssignmentReducedType use the comparable relation instead ofhttps://github.com/mattmccutchen/TypeScript/commit/d45e422b4625ce58d744f58c082654d614da7488
https://docs.github.com/articles/closing-issues-via-commit-messages
d45e422https://github.com/mattmccutchen/TypeScript/commit/d45e422b4625ce58d744f58c082654d614da7488
https://github.com/mattmccutchen
Matt McCutchen (mattmccutchen)https://github.com/mattmccutchen
on Aug 2, 2018https://github.com/microsoft/TypeScript/issues/26130#issuecomment-409794544
#26143https://github.com/microsoft/TypeScript/pull/26143
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#26143https://github.com/microsoft/TypeScript/pull/26143
on Aug 9, 2018https://github.com/microsoft/TypeScript/issues/26130#event-1780388580
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
on Aug 9, 2018https://github.com/microsoft/TypeScript/issues/26130#event-1780389805
Matt McCutchen (mattmccutchen)https://github.com/mattmccutchen
on Aug 13, 2018https://github.com/microsoft/TypeScript/issues/26130#event-1786441926
Have getAssignmentReducedType use a new relation that checks for weakhttps://github.com/mattmccutchen/TypeScript/commit/c4b13fd2729434e20b1a50215b2530f500ff4be7
c4b13fdhttps://github.com/mattmccutchen/TypeScript/commit/c4b13fd2729434e20b1a50215b2530f500ff4be7
Go back to the old narrowing algorithm (pre microsoft#26143) and avoid …https://github.com/mattmccutchen/TypeScript/commit/cc1c2ab6b2c2165b393b8aa3397e3a7a11b8f33b
microsoft#26143https://github.com/microsoft/TypeScript/pull/26143
…https://github.com/microsoft/TypeScript/issues/26130
cc1c2abhttps://github.com/mattmccutchen/TypeScript/commit/cc1c2ab6b2c2165b393b8aa3397e3a7a11b8f33b
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Aug 20, 2018https://github.com/microsoft/TypeScript/issues/26130#event-1798827427
Merge pull request #26425 from mattmccutchen/issue-26405https://github.com/microsoft/TypeScript/commit/103f894d38f2f3220df046f31269e7885ae9e76b
#26425https://github.com/microsoft/TypeScript/pull/26425
103f894https://github.com/microsoft/TypeScript/commit/103f894d38f2f3220df046f31269e7885ae9e76b
microsofthttps://github.com/microsoft
on Oct 21, 2025https://github.com/microsoft/TypeScript/issues/26130#event-20415756507
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/26130
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/26130
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
BugA bug in TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Bug%22
FixedA PR has been merged for this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Fixed%22
TypeScript 3.1https://github.com/microsoft/TypeScript/milestone/74
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.