-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Remove undefined from optional properties when inferring to index signatures #43086
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
let a1 = foo(x1); // string | number | ||
let a2 = foo(x2); // string | number | undefined | ||
let a3 = foo(x3); // string | number | ||
let a4 = foo(x4); // string | number |
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.
Hm - seems like this is the only questionable one.
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.
Effectively, because we don't have a separate missing
type, undefined
represents the missing state in optional properties, so we really should remove undefined
when we're inferring to an index signature as index signatures represent the type of those properties that are present.
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.
Feels like things are getting a bit untenable without missing
; any plausible implementation of foo
with a legal x4
could return undefined
. We should revisit it.
@typescript-bot test this |
Heya @DanielRosenwasser, I've started to run the parallelized Definitely Typed test suite on this PR at 85815b0. You can monitor the build here. |
Heya @DanielRosenwasser, I've started to run the extended test suite on this PR at 85815b0. You can monitor the build here. |
Heya @DanielRosenwasser, I've started to run the parallelized community code test suite on this PR at 85815b0. You can monitor the build here. |
Heya @DanielRosenwasser, I've started to run the perf test suite on this PR at 85815b0. You can monitor the build here. Update: The results are in! |
Heya @DanielRosenwasser, I've started to run the abridged perf test suite on this PR at 85815b0. You can monitor the build here. Update: The results are in! |
Check with @andrewbranch too since he made the corresponding change. |
@DanielRosenwasser Here they are:Comparison Report - master..43086
System
Hosts
Scenarios
Developer Information: |
@DanielRosenwasser Here they are:Comparison Report - master..43086
System
Hosts
Scenarios
Developer Information: |
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
Fixes #43045.