This solution is generated by ChatGPT, correctness is not guaranteed.
AI solution for TypeScript puzzle on BFE.dev
30. implement IsAny<T>
type IsAny<T> = false extends (T extends any ? (T extends never ? true : false) : true) ? true : false;
Explanation:
- We use a ternary operator to check if T extends
any
, if it does then returntrue
else returnfalse
- Within the ternary, we perform another check using
never
to make surefalse
is returned when T extendsunknown
ornever
and only returnstrue
when the typeany
is extended.