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
typeHash=string&{__hash: true};functiongetHashLength(hash: Hash): number{// A best effort check in case our function is used by people writing JSif(typeofhash!==`string`)thrownewError(`This doesn't look like a hash`);returnhash.length;}
π Actual behavior
The hash variable is incorrectly refined to never.
π Expected behavior
The hash variable should remain Hash, since the typeof check is coherent with Hash.
The text was updated successfully, but these errors were encountered:
Hmm, yes this is an effect of #43131. The fixes to getTypeFacts are in principle correct, except that here we think that typeof is both "string" and "object", which is impossible and therefore gets us to never. In tagged primitive types like this we should really consider the primitive type be to dominant. I'll put up a PR to that effect.
Bug Report
π Search Terms
refine regression 4.3 refine never
π Version & Regression Information
Worked with 4.2, stopped working with 4.3 beta
β― Playground Link
https://www.typescriptlang.org/play?ts=4.3.0-dev.20210402#code/C4TwDgpgBAEghgZwBZQLxQcATgSwHYDmUAZFAN4D6FSiSAXFNgK4QC+A3AFCcBmTeAY2A4A9nigEIweMgAyEQsCQAKGsgYykASgZ4mAWwBGELOU5QLUAPRWoAQSjHMUCDx4iswKAKQQBAayh8b0RoESZTPkFhMSCEKCYECAATRxAoSBEwABtoAHdcYUIoACkAZXNLHB4oZVBMmrUUAEJUdAADTFxCdq1Ky0YkLBE8qDwIUYBRLGGsZXaAFSQceOSRCAQ8AHIvbJERQOycf2g4KCbern6oLCkI8SaAOlzFJC5WTiA
π» Code
π Actual behavior
The
hash
variable is incorrectly refined tonever
.π Expected behavior
The
hash
variable should remainHash
, since thetypeof
check is coherent withHash
.The text was updated successfully, but these errors were encountered: