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
- Your code has no type errors
- A string is accepted
- null is rejected
- 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.
Press Run to see the page.
Console
Nothing printed yet.