-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Improve handling of corner cases in narrowTypeByInstanceof
#52592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@typescript-bot test this |
Heya @ahejlsberg, I've started to run the diff-based top-repos suite on this PR at 1337f28. You can monitor the build here. Update: The results are in! |
Heya @ahejlsberg, I've started to run the diff-based user code test suite on this PR at 1337f28. You can monitor the build here. |
Heya @ahejlsberg, I've started to run the abridged perf test suite on this PR at 1337f28. You can monitor the build here. Update: The results are in! |
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 1337f28. You can monitor the build here. |
Heya @ahejlsberg, I've started to run the extended test suite on this PR at 1337f28. You can monitor the build here. |
@ahejlsberg Here are the results of running the user test suite comparing Something interesting changed - please have a look. Details
|
@ahejlsberg Here are some more interesting changes from running the user test suite Details
|
Heya @ahejlsberg, I've run the RWC suite on this PR - assuming you're on the TS core team, you can view the resulting diff here. |
@ahejlsberg Here they are:Comparison Report - main..52592
System
Hosts
Scenarios
Developer Information: |
@ahejlsberg Here are the results of running the top-repos suite comparing Everything looks good! |
@typescript-bot user test this inline |
Heya @ahejlsberg, I've started to run the diff-based user code test suite on this PR at 13bd783. You can monitor the build here. Update: The results are in! |
@ahejlsberg Here are the results of running the user test suite comparing Everything looks good! |
@typescript-bot run dt |
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 2577f94. You can monitor the build here. |
Tests are clean and performance unaffected. This one is ready to merge. |
} | ||
|
||
function foo(x: A | B | C, A: AA, B: BB, AB: AA | BB) { | ||
if (x instanceof A) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was really confused while reading this test because I was trying to understand how we weren't getting an error for trying to instanceof
an interface, before I realized that A
was being passed as a parameter and shadowed the outer declaration. If there's a different way to construct this that avoids that, that might be helpful for future reading / baseline reading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is actually intended since this is precisely the "shadowing" that happens when you declare a class, i.e. for class Foo {}
you end up with a value Foo
(the constructor function) and a type Foo
(the instance type). There isn't really any shadowing going on because the two namespaces are separate and determined by context.
Fixes #52571.