This solution is generated by ChatGPT, correctness is not guaranteed. You might also be able to find a solution fromcommunity posts.
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 returntrueelse returnfalse - Within the ternary, we perform another check using
neverto make surefalseis returned when T extendsunknownorneverand only returnstruewhen the typeanyis extended.