-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix #31155 - Remove assignability cases in getNarrowedType #32443
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
Fix #31155 - Remove assignability cases in getNarrowedType #32443
Conversation
} | ||
s; // Set<number> | ||
>s : Set<number> | ||
>s : Set<number> & Set<any> |
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.
Are these cases where TS would widen to be an any
instead of the original number
, this feels like something we don't want
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.
Yes, when accessing the parametrising type you'll end up getting number & any
which is going to swallow number
- this is definitely a bad change. The problem is that before it was relying on the assignability check to strip out the any
case, but now we don't have that.
I think I remember that there was a similar issue that came up in conditional type simplification, where T extends Foo<any> ? A : B
was simplified to T & Foo<any>
, causing similar problems. @weswigham what was the solution here?
This would probably benefit from #30161. |
@typescript-bot run dt |
Heya @jack-williams, I've started to run the parallelized Definitely Typed test suite on this PR at b6026c2. You can monitor the build here. It should now contribute to this PR's status checks. |
Heya @jack-williams, I've started to run the extended test suite on this PR at b6026c2. You can monitor the build here. It should now contribute to this PR's status checks. |
Heya @jack-williams, I've started to run the parallelized community code test suite on this PR at b6026c2. You can monitor the build here. It should now contribute to this PR's status checks. |
I've added an additional subtype check to tame the issues of |
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 think this is good - briefly cc @ahejlsberg as this is the kind of change to run by you before we merge, if only so everyone's on the same page so we don't reintroduce a similar bug with a different narrowing in the future~
Ping @ahejlsberg |
The old test runs have expired. Running again so I can take a look. @typescript-bot test this |
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at d91d445. You can monitor the build here. It should now contribute to this PR's status checks. |
Heya @ahejlsberg, I've started to run the extended test suite on this PR at d91d445. You can monitor the build here. It should now contribute to this PR's status checks. |
Heya @ahejlsberg, I've started to run the parallelized community code test suite on this PR at d91d445. You can monitor the build here. It should now contribute to this PR's status checks. |
You're gunna need to merge this with |
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
@ahejlsberg, @weswigham: I’ll merge and run those tests later today |
d91d445
to
b24dbe6
Compare
@typescript-bot test this |
Heya @jack-williams, I've started to run the extended test suite on this PR at b24dbe6. You can monitor the build here. It should now contribute to this PR's status checks. |
Heya @jack-williams, I've started to run the parallelized Definitely Typed test suite on this PR at b24dbe6. You can monitor the build here. It should now contribute to this PR's status checks. |
Heya @jack-williams, I've started to run the parallelized community code test suite on this PR at b24dbe6. You can monitor the build here. It should now contribute to this PR's status checks. |
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
DTS failures look to be import/declaration related. Are these noise? Not entirely sure how to interpret user test failures. |
The DT failures are noise. Not sure how to look at the user test failures either. |
There're a little fail-y on |
I think the diffs look clean. Only thing that looks significant is a load of errors in src/language-yaml/printer-yaml.js now removed in master - might be unrelated? |
@typescript-bot user test this |
Heya @jack-williams, I've started to run the parallelized community code test suite on this PR at b24dbe6. You can monitor the build here. It should now contribute to this PR's status checks. |
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
I think the vscode change looks related to this:
|
Minimal repro: interface IAction {
x: string;
}
declare const arg: IAction | ReadonlyArray<IAction>;
const x = Array.isArray(arg) ? arg : [arg]; Previously TLDR: I feel slightly reluctant to make any changes to the solution here for a type-guard that has multiple issues open about improving it; though, I don't think this break is acceptable to push into master. Need to come up with some sort of resolution here, which may be trying to resolve |
I think this is potentially blocked on #17002. |
This PR hasn't seen any activity for quite a while, so I'm going to close it to keep the number of open PRs manageable. Feel free to open a fresh PR or continue the discussion here. |
Fixes #31155
/cc @orta @weswigham