Command Palette

Search for a command to run...

Hectal
Phase 9: Conditional and Template Literal Types
TypeScript · Exercise 2 of 5 PreviousNext
Advanced

Remove null and undefined from a Union

Write NoNulls<T> that removes null and undefined from a union by using a distributive conditional type.

NoNulls<string | null | undefined> must be string.

What Check tests

  1. Your code has no type errors
  2. A string is accepted
  3. null is rejected
  4. undefined is rejected

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Console

Nothing printed yet.