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
declarefunctiontakeC(x: "c"): void;declareletisAB: (x: "a"|"b"|"c")=>x is "a"|"b";declareletisA: (x: "a"|"b"|"c")=>x is "a";isAB=isA;declareletx: "a"|"b"|"c";if(isAB(x)){x;// "a" | "b", but can actually only be "a"}else{x;// "c", but can actually be "c" | "b"takeC(x);// This is bad}
π Actual behavior
Assignment isAB = isA doesn't error.
π Expected behavior
Assignment isAB = isA errors because it is unsound.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
π Search Terms
type predicate comparison, type predicate variance
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?ts=5.5.0-dev.20240416#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXwygGsQBhACgA8AueAIjDoEpaA3HLYAbgCgfRIsBBBAZ4WAM4BBAEK0qtOlDrwAPvQBGK9Q2bwAvAD54lcRPrK1murwHQ48EWMlT5NC9utXdTA8dOSHrw8LjIGZlLBdkKOoiaKljpa3oy8WIjw5KFUTL4A3jzwRSZc8AD0ZR7eWgA08BrIYmBQ+FCYyFAQEACe8Hg99QhKdDwAvjwgEBIIBcUl5ZW6dQ1NLfBtGB1dvRpDjNUjc4QkFJRMpRXwACoAFoGBGlDAY3xAA
π» Code
π Actual behavior
Assignment
isAB = isA
doesn't error.π Expected behavior
Assignment
isAB = isA
errors because it is unsound.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: