You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionf1<T>(x: T&string|T&undefined){if(x){x;// Should narrow to T & string}}functionf2<T>(x: T&string|T&undefined){if(x!==undefined){x;// Should narrow to T & string}else{x;// Should narrow to T & undefined}}functionf3<T>(x: T&string|T&number){if(typeofx==="string"){x;// Should narrow to T & string}else{x;// Should narrow to T & number}}functionf4<T>(x: T&1|T&2){switch(x){case1: x;break;// T & 1case2: x;break;// T & 2default: x;// Should narrow to never}}functionf5<Textendsstring|number>(x: T&number){constt1=x==="hello";// Should be an error}
π Actual behavior
No narrowing or errors where expected.
π Expected behavior
Narrowing and errors as indicated above.
The text was updated successfully, but these errors were encountered:
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABMAjAHgCoD4AUAPALkQ0QDJEBnKAJxjAHNEAfYsxcAEwFNg6uOAlIgDeAWABQiKYhjBE+IWMnSVeANxSA9JsQBlABZwQAGw6IwAQ2rU4Ad0RQ4rclVoMJKgL4Tv4iaEhYBGQAJkxcQmdKGjpGFhJyTh4+QREPaVl5PEQAQgBePPYwbl4wfkV0lSl1LR0DI1NzKxt7RyjXWMrEXxUuYwouNOUqxBrEbT1DEzNLazsHJwSikpSu319-cGh4JGAAZnD8IiWOhmYosBAAWwAjLmoK4Zk5HCgATwAHLjg5bILCgBEp3oAMeI2qGnGdSmjVmLQW7Ri7iePWkfQGQ3Bo0hE3q0yac1aizYl1u9zWPgkm0CO2QABZDpElihzksQmDpBRbDAoBB9FkOSMIBYMSgiDUbtQuBYANY4nTMroqYUYkLijSS6Vy2pREJK6QlCwmKDqnV42HNeZtMoAN3JKMpfnEAW2wWAAFZMIguHgoFxihRom44uZrndqBFjiSw-dBYgIAgqA4WYU-gVEAD9H1jHAAfLJg0zHdEBYkPcbNRHUA
π» Code
π Actual behavior
No narrowing or errors where expected.
π Expected behavior
Narrowing and errors as indicated above.
The text was updated successfully, but these errors were encountered: