René's URL Explorer Experiment


Title: Property type update not continued inside next block after checking · Issue #48183 · microsoft/TypeScript · GitHub

Open Graph Title: Property type update not continued inside next block after checking · Issue #48183 · microsoft/TypeScript

X Title: Property type update not continued inside next block after checking · Issue #48183 · microsoft/TypeScript

Description: Bug Report When an object contains an optional property that could either be an array or undefined. Checking that property exists as an array changes its type to only an array instead of optional. Later on, inside a .some of another arra...

Open Graph Description: Bug Report When an object contains an optional property that could either be an array or undefined. Checking that property exists as an array changes its type to only an array instead of optional. ...

X Description: Bug Report When an object contains an optional property that could either be an array or undefined. Checking that property exists as an array changes its type to only an array instead of optional. ...

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

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.113.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Property type update not continued inside next block after checking","articleBody":"# Bug Report\r\n\r\nWhen an object contains an optional property that could either be an array or undefined. Checking that property exists as an array changes its type to only an array instead of optional. Later on, inside a `.some` of another array, the first array goes back to being possibly undefined. If I destructure the item before checking it's value, ts works perfectly but the destructure would be unnecessary in this case.\r\n\r\n### 🔎 Search Terms\r\n\r\n\"Object is possibly 'undefined'.\"\r\n\"type guard not applied\"\r\n\"possibly undefined inside method\"\r\n\r\n### 🕗 Version & Regression Information\r\n\r\nThis is the behavior in every version of the playground and could not find anything in the FAQ's that related.\r\nI did find this issue but I'm unsure if it's related - https://github.com/microsoft/TypeScript/issues/10530\r\n\r\n### ⏯ Playground Link\r\n[Playground link with relevant code](https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgKoGdrIN4FgBQyyADtALbDrrAD2I6A-AFzLphSgDmA2gLoDcBAL4ECMAK4gEYWiGQIAFhAQBrAArlK1OugAUBIuMxQWGaABoDyKBACO44DYAmGqBSqzGLNhxA9elvgAlDhWAPRhyAByNCSaHjrIcDbWdg7OVsAwyLoAhDb2jhAu8dr0DAB0ADYQfmAKITZg4lBy7OIQgvjhkWZQyApw6MggsaRuWp7IAEbiYHETCfRJKQXpxZkweQCCUFBwAJ4VlLv7B7pG0BXj7mXoIQA+D8i5l1DXpZ7VtZz1IVZEJotOTwKqYLo9ZDbeY1IbzOgoNZFJwLW6yZBkIzzaYoMhwMCKDaEVLNVqpQrOVxonQVdA0MgQXRIymfOjIAC8AD5QsSiBEoXJqH4aqjJmyEHA5DiMfjCU4AcgsjlmcUqWK5OzNcgAOSQNjakJ4XlEEnA5BvD6LO7HKRVcROCB6FUlK2yIJdE3IETdY1Asmg8FWITu4RAA)\r\n\r\n### 💻 Code\r\n\r\n\u003c!-- Please post the relevant code sample here as well-->\r\n```ts\r\ninterface User {\r\n  permissions?: string[];\r\n}\r\n\r\nfunction checkPermissions(\r\n  user: User,\r\n  requiredPermissions?: string[],\r\n) {\r\n  if (!requiredPermissions?.length) return true;\r\n\r\n  // destructure user.permissions here fixes the errors\r\n  // const { permissions } = user; \r\n\r\n  if(!Array.isArray(user.permissions) || !user.permissions.length) \r\n    return false;\r\n\r\n  return requiredPermissions.some(requiredPermission => {\r\n    if (requiredPermission === 'test') {\r\n      return user.permissions.includes(requiredPermission);\r\n    }\r\n\r\n    return false;\r\n  });\r\n}\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nError: Object is possibly 'undefined'. \r\nAbove error is shown for user.permissions inside the `some` function. \r\n\r\n### 🙂 Expected behavior\r\n\r\nThe `user.permissions` object should be an array inside the some. It is an array in the second condition of the if statement above it.\r\n","author":{"url":"https://github.com/silverlight513","@type":"Person","name":"silverlight513"},"datePublished":"2022-03-09T11:16:32Z","url":"https://github.com/microsoft/TypeScript/issues/48183"}

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:d8a7f2be-cecb-e44d-0073-b17982506f0e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id93D6:3F9CD1:67D3A9:893EAD:6B04C582
html-safe-nonce8c3462a27c32e220de99988996819969083e76c29a9d34206e2145d1a292bbf4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5M0Q2OjNGOUNEMTo2N0QzQTk6ODkzRUFEOjZCMDRDNTgyIiwidmlzaXRvcl9pZCI6Ijg4MjI3NzA5MzQxODk3MDQ1NzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacca5e7fdf76e725aede709610409fece7320f9c83074a9f1a9cdb7c86fb7b7e88
hovercard-subject-tagissue:1163806724
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/48183/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4cb6c508c11ff8fa5a148da24710ce783b0b9f77aa1405d724a94e64a336ef44/microsoft/TypeScript/issues/48183
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4cb6c508c11ff8fa5a148da24710ce783b0b9f77aa1405d724a94e64a336ef44/microsoft/TypeScript/issues/48183
og:image:altBug Report When an object contains an optional property that could either be an array or undefined. Checking that property exists as an array changes its type to only an array instead of optional. ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesilverlight513
hostnamegithub.com
expected-hostnamegithub.com
None85dd75377eb77313206b8fc108bcee6a3a029286d94bf32bf9b4426e4d92e0c4
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
release0d64fa748a2bab9a5b587a967ac4da1cfa8da6dd
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/48183#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F48183
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%2F48183
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/48183
Reloadhttps://github.com/microsoft/TypeScript/issues/48183
Reloadhttps://github.com/microsoft/TypeScript/issues/48183
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests316 (316)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/48183
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/48183
Property type update not continued inside next block after checkinghttps://github.com/microsoft/TypeScript/issues/48183#top
Duplicatehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Duplicate%22
https://github.com/silverlight513
Jack Rimell (silverlight513)https://github.com/silverlight513
on Mar 9, 2022https://github.com/microsoft/TypeScript/issues/48183#issue-1163806724
#10530https://github.com/microsoft/TypeScript/issues/10530
Playground link with relevant codehttps://www.typescriptlang.org/play#code/JYOwLgpgTgZghgYwgAgKoGdrIN4FgBQyyADtALbDrrAD2I6A-AFzLphSgDmA2gLoDcBAL4ECMAK4gEYWiGQIAFhAQBrAArlK1OugAUBIuMxQWGaABoDyKBACO44DYAmGqBSqzGLNhxA9elvgAlDhWAPRhyAByNCSaHjrIcDbWdg7OVsAwyLoAhDb2jhAu8dr0DAB0ADYQfmAKITZg4lBy7OIQgvjhkWZQyApw6MggsaRuWp7IAEbiYHETCfRJKQXpxZkweQCCUFBwAJ4VlLv7B7pG0BXj7mXoIQA+D8i5l1DXpZ7VtZz1IVZEJotOTwKqYLo9ZDbeY1IbzOgoNZFJwLW6yZBkIzzaYoMhwMCKDaEVLNVqpQrOVxonQVdA0MgQXRIymfOjIAC8AD5QsSiBEoXJqH4aqjJmyEHA5DiMfjCU4AcgsjlmcUqWK5OzNcgAOSQNjakJ4XlEEnA5BvD6LO7HKRVcROCB6FUlK2yIJdE3IETdY1Asmg8FWITu4RAA
https://github.com/MartinJohns
Martin Johns (MartinJohns)https://github.com/MartinJohns
on Mar 9, 2022https://github.com/microsoft/TypeScript/issues/48183#issuecomment-1062883798
#9998https://github.com/microsoft/TypeScript/issues/9998
https://github.com/silverlight513
Jack Rimell (silverlight513)https://github.com/silverlight513
on Mar 9, 2022https://github.com/microsoft/TypeScript/issues/48183#issuecomment-1062941696
Martin Johns (@MartinJohns)https://github.com/MartinJohns
https://github.com/MartinJohns
Martin Johns (MartinJohns)https://github.com/MartinJohns
on Mar 9, 2022https://github.com/microsoft/TypeScript/issues/48183#issuecomment-1062966563
https://user-images.githubusercontent.com/5269069/157459406-b0a0b472-caf2-4fdd-aaa9-ead96809405e.png
https://github.com/Microsoft/TypeScript-wikihttps://github.com/Microsoft/TypeScript-wiki
https://github.com/jcalz
Joe Calzaretta (jcalz)https://github.com/jcalz
on Mar 9, 2022https://github.com/microsoft/TypeScript/issues/48183#issuecomment-1062999746
Common "Bugs" That Aren't Bugshttps://github.com/Microsoft/TypeScript/wiki/FAQ#common-bugs-that-arent-bugs
bug report templatehttps://raw.githubusercontent.com/microsoft/TypeScript/main/.github/ISSUE_TEMPLATE/Bug_report.md
touched since 2019https://github.com/microsoft/TypeScript-wiki/commit/b7c0733a94174b5bac042348ef3a1afbf75c00d9
#9998https://github.com/microsoft/TypeScript/issues/9998
#9998https://github.com/microsoft/TypeScript/issues/9998
https://github.com/MartinJohns
Martin Johns (MartinJohns)https://github.com/MartinJohns
on Mar 9, 2022https://github.com/microsoft/TypeScript/issues/48183#issuecomment-1063073327
#9998https://github.com/microsoft/TypeScript/issues/9998
thishttps://twitter.com/atcb/status/1449148857800019971
https://user-images.githubusercontent.com/5269069/157478404-79fa1a2b-cf46-48a6-9638-3987f8701164.png
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Mar 9, 2022https://github.com/microsoft/TypeScript/issues/48183#issuecomment-1063196640
https://user-images.githubusercontent.com/6685088/157501002-95dcd664-5a66-416b-a38f-796ce213d616.png
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Duplicatehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Duplicate%22
on Mar 9, 2022https://github.com/microsoft/TypeScript/issues/48183#event-6211906551
https://github.com/MartinJohns
Martin Johns (MartinJohns)https://github.com/MartinJohns
on Mar 9, 2022https://github.com/microsoft/TypeScript/issues/48183#issuecomment-1063376381
https://github.com/fatcerberus
Bruce Pascoe (fatcerberus)https://github.com/fatcerberus
on Mar 10, 2022https://github.com/microsoft/TypeScript/issues/48183#issuecomment-1063621896
#48148https://github.com/microsoft/TypeScript/issues/48148
TypeScript Bot (typescript-bot)https://github.com/typescript-bot
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Mar 12, 2022https://github.com/microsoft/TypeScript/issues/48183#event-6230053706
https://github.com/typescript-bot
TypeScript Bot (typescript-bot)https://github.com/typescript-bot
on Mar 12, 2022https://github.com/microsoft/TypeScript/issues/48183#issuecomment-1065931484
https://github.com/MartinJohns
Martin Johns (MartinJohns)https://github.com/MartinJohns
on Mar 14, 2022https://github.com/microsoft/TypeScript/issues/48183#issuecomment-1067227439
#48261https://github.com/microsoft/TypeScript/pull/48261
microsofthttps://github.com/microsoft
on Oct 22, 2025https://github.com/microsoft/TypeScript/issues/48183#event-20417507319
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/48183
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/48183
Duplicatehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Duplicate%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

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.