Open utterances-bot opened 2 years ago
[T] extends [never]
stop it being distributive
➡Conditional Types - Checking extends never only works sometimes
@likui628 you are right. When I was solving the challenge I thought that is why it works. But later on I've figured out that using []
syntax dismisses the distributivity on type.
This should work with anything in place of 'foo' ( except never itself ) as never 'cancels out' of a union where any other type does not
type IsNever<T> = T | 'foo' extends 'foo' ? true : false
IsNever
This project is aimed at helping you better understand how the type system works, writing your own utilities, or just having fun with the challenges.
https://ghaiklor.github.io/type-challenges-solutions/en/medium-isnever.html