GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||
GeezerVison is showing github.com — Treat intersection types as potential `never` by lowr · Pull Request #47751 · microsoft/TypeScript Conversation
Contributor
Fixes #46032 This PR fixes crashes and improves error messages when a function is declared to return a type alias that names an intersection type of object-like types that reduces to Besides #46032, there have been certain circumstances under which using such type aliases as functions' return type emits error messages different from using
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsWhen the following conditions are satisfied, `isSimpleTypeRelatedTo(source, target)` returns true, which is false positive. - `strictNullChecks` is disabled - `source` is `undefined` - `target` is an empty intersection type which reduces to `never` by discriminants In this case, `isSimpleTypeRelatedTo()` should actually return `false`, which does *not* mean `source` doesn't relate to `target`, but rather tells the checker to further investigate their relation. When types are checked if they are `never` by their `TypeFlags`, they must first be reduced, because intersection types of object-like types which reduce to `never` don't have `TypeFlags.Never`. See microsoft#36696 for details. When a function is declared to return such type and it doesn't contain any return statement or it only contains return statements without expression, the error messages are incorrect as the checker sees its return type as non-`never`. This commit takes into account that intersection types potentially reduces to `never` and improves error messages.
LowR (lowr)
force-pushed
the
fix/46032
branch
from
9cf958b to
fa4c478
Compare
Ryan Cavanaugh (RyanCavanaugh)
requested a review
from Anders Hejlsberg (ahejlsberg)
Anders Hejlsberg (ahejlsberg)
requested changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't quite the right fix, I will put something up in a PR.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the review. Besides my fix not allowing empty array literals assigned to
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, one issue is that both unions and intersections can potentially reduce to
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! I'll think about those logic more carefully next time.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is best covered in a separate PR since it is really an unrelated fix.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
ReviewersUh oh!
There was an error while loading. Please reload this page. AssigneesLabels
For Backlog Bug
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Crash trying to assing undefined[] to never[]Uh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. | |||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |