Support typeof
typeguards for .every()
#23799
Labels
Duplicate
An existing issue was already created
typeof
typeguards for .every()
#23799
TypeScript Version: 2.9.0-dev.20180426
Search Terms:
predicate callback .every typeguards typeof
Code
Expected behavior:
No type error
Actual behavior:
Error:
Playground Link:
https://www.typescriptlang.org/play/#src=interface%20Foo%20%7B%0D%0A%20%20%20%20id%3A%20string%7Cnumber%0D%0A%7D%0D%0A%0D%0Afunction%20doSome(stuff%3A%20Foo%5B%5D)%3A%20false%7C%5Bnumber%2C%20number%5D%20%7B%0D%0A%20%20%20%20if%20(stuff.every(s%20%3D%3E%20typeof%20s.id%20%3D%3D%3D%20%22number%22))%20%7B%0D%0A%20%20%20%20%20%20%20%20var%20minId%20%3D%20-Infinity%3B%0D%0A%20%20%20%20%20%20%20%20var%20maxId%20%3D%20Infinity%3B%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A%20%20%20%20%20%20%20%20for%20(let%20stf%20of%20stuff)%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(maxId%20%3C%20stf.id)%20maxId%20%3D%20stf.id%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(minId%20%3E%20stf.id)%20minId%20%3D%20stf.id%3B%0D%0A%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20return%20%5BminId%2C%20maxId%5D%3B%0D%0A%20%20%20%20%7D%0D%0A%20%20%20%20return%20false%3B%0D%0A%7D
Related Issues:
The text was updated successfully, but these errors were encountered: