-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
[WIP] Contextual narrowing to object #48576
Conversation
@typescript-bot pack this |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Seems like there's a slowdown from this - maybe a fluke? @typescript-bot perf test faster |
Heya @DanielRosenwasser, I've started to run the abridged perf test suite on this PR at 1e2eb03. You can monitor the build here. Update: The results are in! |
src/compiler/checker.ts
Outdated
someType(type, isGenericTypeWithUnionConstraint) || | ||
// When the contextual type is 'unknown', we may need to narrow for compatibility with non-null targets. | ||
// This allows some parity with a constraint of '{} | null | undefined'. | ||
(type.flags & TypeFlags.Instantiable) && contextualType && isEmptyObjectType(contextualType); |
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.
Should this be gated on strictNullChecks
?
@DanielRosenwasser Here they are:Comparison Report - main..48576
System
Hosts
Scenarios
Developer Information: |
1e2eb03
to
ab3f21e
Compare
@typescript-bot pack this |
This comment was marked as outdated.
This comment was marked as outdated.
Heya @DanielRosenwasser, I've started to run the parallelized Definitely Typed test suite on this PR at ab3f21e. You can monitor the build here. |
Heya @DanielRosenwasser, I've started to run the extended test suite on this PR at ab3f21e. You can monitor the build here. |
Heya @DanielRosenwasser, I've started to run the tarball bundle task on this PR at ab3f21e. You can monitor the build here. |
Heya @DanielRosenwasser, I've started to run the parallelized community code test suite on this PR at ab3f21e. You can monitor the build here. |
@DanielRosenwasser Here they are:Comparison Report - main..48576
System
Hosts
Scenarios
Developer Information: |
ab3f21e
to
0ed8bff
Compare
RWC reveals a few interesting things:
Going to rerun with latest changes. |
Hmm, yeah, I don't much like the error message changes in the RWC baselines. The |
Discussed with @ahejlsberg offline - this PR is a bit too corner-casey and produces worse messages when a type isn't narrowed. We're interested in seeing if we can leverage smarter intersection types with |
Related: #48468