The way to check a type for being any
.
#8
Comments
Wow the repo ts-typedefs is awesome! Thanks a lot!! In fact I already know how to check However, I am stuck in microsoft/TypeScript#30794 now. I am trying another way to implement typesafe-joi with (maybe) less type recursion. BTW do you know how to force TypeScript to expand some complex deferred type? The evaluation of mapped types are sometimes (I don't know the exact point) deferred. Hovering on this kind of type looks horrible. |
@hjkcai Thank you too))
Same issue with
Unfortunately, I've never wondered about it. Most of the time complex types are expanded in-place when I hover over them, but not always. I didn't pay much attention to it because I consider forcing them expand to be impossible and not that important. Maybe you should create a |
@Veetaha I have published typesafe-joi 2.0.0 alpha version, which uses |
I've just read your
README.md
and haven't even downloaded your package yet, but I see you are confused stating the followingThere actually is a way to check for
any
type.Type expression
boolean extends (T extends never ? true : false) ? true : false
evaluates totrue
only whenT
is ofany
type, so that bothtrue
andfalse
branch in the inner conditions are matched and their union (namelyboolean
) is returned, which you ultimatelly check in the outer condition. You may use this definition or get an existing one fromts-typedefs
package that exposes such handy definitions asIs[Not]Any<>
,Is[Not]Unknown<>
,Is[Not]Never<>
and much more. Here is the code forIsAny<>
type.The text was updated successfully, but these errors were encountered: