There are numerous questions as to why any
cannot be narrowed from. Despite being natural and intuitive this feature was rejected due to being a serious breaking change to poorly written yet massive code bases.
Please consider putting it behind a flag provided the evident need for it.
TLDR
any
is not what you think it is (poor naming at play)type unknown = {} | undefined | null | void
instead*.d.ts
by handsUPDATE
@yortus made a branch per #9999 (comment) where narrowing from any
works!
try it: npm install typescript-narrowany
yortus, Seikho, svieira, glen-84, HerringtonDarkholme and 1 moreyortus and HerringtonDarkholme
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4