-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Widen boolean literals when contextual type is full boolean type #48368
Conversation
@typescript-bot test this |
Heya @ahejlsberg, I've started to run the extended test suite on this PR at b54de54. You can monitor the build here. |
Heya @ahejlsberg, I've started to run the abridged perf test suite on this PR at b54de54. 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 b54de54. You can monitor the build here. |
Heya @ahejlsberg, I've started to run the diff-based community code test suite on this PR at b54de54. You can monitor the build here. Update: The results are in! |
@ahejlsberg Here they are:Comparison Report - main..48368
System
Hosts
Scenarios
Developer Information: |
@ahejlsberg |
Apart from lots of let x: { kind: false, x: number } | { kind: boolean, x: string } = { kind: false, x: 42 }; Previously this would match against the first variant and succeed. It now matches against the second variant (because the The other change is in declare function foldLeft<U>(z: U, f: (acc: U, t: boolean) => U): U;
let res: boolean = foldLeft(true, (acc, t) => acc && t); // Was error, now ok Previously the |
@typescript-bot run dt |
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at af5bd9e. You can monitor the build here. |
Someone brought this up in Discord: let foo: boolean = false; With the change in this PR, does this no longer narrow-on-assignment to |
Several Definitely Typed packages are adversely affected. Closing this PR and putting up #48380 with less impact. |
Fixes #48363.
Also fixes issue mentioned here because boolean literals contextually typed by
boolean
are now widened.