TypeScript · Senior · Question 5 of 75

Why does type IsNever<T> = T extends never ? true : false give never for IsNever<never>?

Explanation

A distributive conditional type applies to each union member, and never has no members - the result is never. The correct check is [T] extends [never] ? true : false.

Further reading

Problem with a question

TypeScript · Senior · question 5

Test yourself

Take the TypeScript · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz