René's URL Explorer Experiment


Title: Propagate Never Types to Parents · Issue #26537 · microsoft/TypeScript · GitHub

Open Graph Title: Propagate Never Types to Parents · Issue #26537 · microsoft/TypeScript

X Title: Propagate Never Types to Parents · Issue #26537 · microsoft/TypeScript

Description: Search Terms never type inference, never parent, never property, never narrowing Suggestion TypeScript's type system helpfully eliminates never patterns from unions. This could be even more helpful if it were able to infer that types con...

Open Graph Description: Search Terms never type inference, never parent, never property, never narrowing Suggestion TypeScript's type system helpfully eliminates never patterns from unions. This could be even more helpful...

X Description: Search Terms never type inference, never parent, never property, never narrowing Suggestion TypeScript's type system helpfully eliminates never patterns from unions. This could be even more hel...

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

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.112.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Propagate Never Types to Parents","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. Please read the FAQ first, especially the \"Common Feature Requests\" section.\r\n\r\n-->\r\n\r\n## Search Terms\r\n\r\n[never type inference](https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue+never+type+inference), [never parent](https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue+never+parent), [never property](https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue+never+property), [never narrowing](https://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue+never+narrowing+)\r\n\r\n\r\n\u003c!-- List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily -->\r\n\r\n## Suggestion\r\n\r\n\u003c!-- A summary of what you'd like to see added or changed -->\r\n\r\nTypeScript's type system helpfully eliminates `never` patterns from unions. This could be even more helpful if it were able to infer that types containing `never` types can not exist at runtime, and must themselves also be `never`. \r\n\r\nAny types which contain a not-null, not-undefined, not-unioned value of the `never` type would themselves be reduced to a `never` type, since they can also never exist.\r\n\r\nThis applies when `never` is used as a property value, array type, or tuple value...\r\n\r\n- `{x: never, y: number}` becomes `never`\r\n- `never[]` becomes `never`\r\n- `(never, 1)` becomes `never`\r\n\r\nbut not when `never` is used as a return value, or part of a union...\r\n\r\n- `() => never` is unchanged \r\n- `(never) => void` is unchanged\r\n- `never|String` already becomes `String`\r\n\r\nWould this be a reasonable transformation to perform?\r\n\r\nThis is inspired by [part of this never type handling proposal for Rust](http://smallcultfollowing.com/babysteps/blog/2018/08/13/never-patterns-exhaustive-matching-and-uninhabited-types-oh-my/#implications-for-safe-code).\r\n\r\n## Example\r\n\r\nConsider using a generic `Result\u003cT, U>` type, which contains a value of type `T` in case of success or one of type `U` in case of failure. If we need to return a `Result`, but know that no error can occur for our implementation, we might use the type `Result\u003cString, never>`.\r\n\r\nIf we use an untagged union, TypeScript recognizes that the error case can never occur and knows we can safely treat it as the success type.\r\n\r\n```typescript\r\ntype Result\u003cT, U> = T | U;\r\n\r\nconst s1 = \"hello\" as Result\u003cString, Error>;\r\ns1.slice();\r\n// Property 'slice' does not exist on type 'Result\u003cString, Error>'.\r\n//   Property 'slice' does not exist on type 'Error'.\r\n\r\nconst s2 = \"hello\" as Result\u003cString, never>;\r\ns2.slice();\r\n// \"hello\"\r\n```\r\n\r\nHowever, if we used a tagged union instead, TypeScript can't eliminate the failure type:\r\n\r\n```typescript\r\ntype Result\u003cT, U> = {ok: T} | {err: U};\r\n\r\nconst s1 = {ok: \"hello\"} as Result\u003cString, Error>;\r\ns1.ok.slice();\r\n// Property 'ok' does not exist on type 'Result\u003cString, Error>'.  \r\n//   Property 'ok' does not exist on type '{ err: Error; }'.\r\n\r\nconst s2 = {ok: \"hello\"} as Result\u003cString, never>;\r\ns2.ok.slice();\r\n// Property 'ok' does not exist on type 'Result\u003cString, never>'.  \r\n//   Property 'ok' does not exist on type '{ err: never; }'.\r\n```\r\n\r\nIf the `never` type were propagated up in  `{ err: never }`, the compiler could eliminate it from the union and recognize that this code was safe.\r\n\r\n## Compatibility\r\n\r\nCode that operates on structures containing never values could start raising new errors. For example, the following currently [compiles without error](https://www.typescriptlang.org/play/index.html#src=declare%20const%20never%3A%20never%3B%0D%0A%0D%0Aconst%20p%20%3D%20%7Bx%3A%20never%2C%20y%3A%200%7D%0D%0Aconst%20q%20%3D%20p.y%3B%0D%0Aconsole.log(p)%3B%0D%0A), but after this change it would raise an error:\r\n\r\n```rust\r\ndeclare const never: never;\r\nconst p = {x: never, y: 0}\r\nconst q = p.y;\r\n// Property 'y' does not exist on type '{x: never, y: 0}'.\r\n//   Property 'y' does not exist on type 'never'.\r\n```\r\n\r\nSuch code is necessarily already dead, so this case shouldn't be very common.\r\n\r\nThe change wouldn't introduce errors in generic code that just might be populated with `never`, like the motivating example above.\r\n\r\n\r\n## Checklist\r\n\r\nMy suggestion meets these guidelines:\r\n* [ ] This wouldn't be a breaking change in existing TypeScript / JavaScript code\r\n  - This **is** a breaking change for some existing TypeScript code, but it might only affect dead code.\r\n* [x] This wouldn't change the runtime behavior of existing JavaScript code\r\n* [x] This could be implemented without emitting different JS based on the types of the expressions\r\n* [x] This isn't a runtime feature (e.g. new expression-level syntax)\r\n","author":{"url":"https://github.com/jeremyBanks","@type":"Person","name":"jeremyBanks"},"datePublished":"2018-08-18T17:23:45Z","url":"https://github.com/microsoft/TypeScript/issues/26537"}

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:adcc7b97-fdf6-ef78-0732-2e8348b5a7f1
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE502:3DD456:412CC:58443:6B04A81C
html-safe-nonce208a5ec6be0f620db65f4c5c3af87dc63e6614890e39d49dd9e44457803f6971
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNTAyOjNERDQ1Njo0MTJDQzo1ODQ0Mzo2QjA0QTgxQyIsInZpc2l0b3JfaWQiOiI3NDY1ODYwNjM2NDY0MTYyODQ0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacf9449e4460e17be9b3f27650032600a4d28b0b15fd306ec651f8afedeb35e1b1
hovercard-subject-tagissue:351837210
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/26537/issue_layout
twitter:imagehttps://opengraph.githubassets.com/2a030bf5cc85f2d65d52a2eba4e4f7872da0e6ef2a97358dffc4d519c9cae6b1/microsoft/TypeScript/issues/26537
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/2a030bf5cc85f2d65d52a2eba4e4f7872da0e6ef2a97358dffc4d519c9cae6b1/microsoft/TypeScript/issues/26537
og:image:altSearch Terms never type inference, never parent, never property, never narrowing Suggestion TypeScript's type system helpfully eliminates never patterns from unions. This could be even more helpful...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejeremyBanks
hostnamegithub.com
expected-hostnamegithub.com
None188497a0f45a7aa8f7c866faa1950d1a7f8d82b59416adf549b222ad1d1dd19b
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
release557cfbac6cdb532730c95c90f2cefdc0c4128029
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/26537#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F26537
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%2F26537
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/26537
Reloadhttps://github.com/microsoft/TypeScript/issues/26537
Reloadhttps://github.com/microsoft/TypeScript/issues/26537
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests318 (318)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/26537
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/26537
Propagate Never Types to Parentshttps://github.com/microsoft/TypeScript/issues/26537#top
Declinedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Declined%22
Suggestionhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
https://github.com/jeremyBanks
Jeremy Banks (jeremyBanks)https://github.com/jeremyBanks
on Aug 18, 2018https://github.com/microsoft/TypeScript/issues/26537#issue-351837210
never type inferencehttps://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue+never+type+inference
never parenthttps://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue+never+parent
never propertyhttps://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue+never+property
never narrowinghttps://github.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93&q=is%3Aissue+never+narrowing+
part of this never type handling proposal for Rusthttp://smallcultfollowing.com/babysteps/blog/2018/08/13/never-patterns-exhaustive-matching-and-uninhabited-types-oh-my/#implications-for-safe-code
compiles without errorhttps://www.typescriptlang.org/play/index.html#src=declare%20const%20never%3A%20never%3B%0D%0A%0D%0Aconst%20p%20%3D%20%7Bx%3A%20never%2C%20y%3A%200%7D%0D%0Aconst%20q%20%3D%20p.y%3B%0D%0Aconsole.log(p)%3B%0D%0A
https://github.com/ahejlsberg
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
on Aug 18, 2018https://github.com/microsoft/TypeScript/issues/26537#issuecomment-414091148
Anders Hejlsberg (ahejlsberg)https://github.com/ahejlsberg
Suggestionhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
on Aug 18, 2018https://github.com/microsoft/TypeScript/issues/26537#event-1796142847
https://github.com/jeremyBanks
Jeremy Banks (jeremyBanks)https://github.com/jeremyBanks
on Aug 19, 2018https://github.com/microsoft/TypeScript/issues/26537#issuecomment-414100776
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Declinedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Declined%22
on Aug 20, 2018https://github.com/microsoft/TypeScript/issues/26537#event-1798540625
https://github.com/RyanCavanaugh
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
on Aug 20, 2018https://github.com/microsoft/TypeScript/issues/26537#issuecomment-414439586
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
completedhttps://github.com/microsoft/TypeScript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Aug 20, 2018https://github.com/microsoft/TypeScript/issues/26537#event-1798542604
Sebastian "Sebbie" Silbermann (eps1lon)https://github.com/eps1lon
on Jan 6, 2026https://github.com/microsoft/TypeScript/issues/26537#event-21872743804
[strict-route-types] Enforce common React Component return types in A…https://github.com/vercel/next.js/commit/0f2bbc9a2d07adbcfa5ec1ebe22e3e2f61a2a63a
0f2bbc9https://github.com/vercel/next.js/commit/0f2bbc9a2d07adbcfa5ec1ebe22e3e2f61a2a63a
Masashi Kawafuji (m-kawafuji)https://github.com/m-kawafuji
on Aug 8, 2026https://github.com/microsoft/TypeScript/issues/26537#event-29152243743
[strict-route-types] Enforce common React Component return types in A…https://github.com/m-kawafuji/next.js/commit/5ad6b9d89ba4dfad71b1e1f40d1cd43d8d0ac541
5ad6b9dhttps://github.com/m-kawafuji/next.js/commit/5ad6b9d89ba4dfad71b1e1f40d1cd43d8d0ac541
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/26537
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/26537
Declinedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Declined%22
Suggestionhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%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.