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
20: implement IsNever<T>
type IsNever<T> = [T] extends [never] ? true : false;
In the above code, we define a generic type IsNever<T>
that checks if the input type T
is of type never
. We do this by creating a conditional type that checks if T
is assignable to never
. If the result is true, then we return true
. Otherwise, we return false
. We use the square bracket syntax to force the compiler to perform a distributive conditional type.