← All Exercises

Conditional Types

advancedtypescript~30min

Background

Conditional types enable powerful type-level programming for library authors and advanced TypeScript users.

Problem

Create conditional types that extract or transform types based on conditional logic at the type level.

Input

Type definitions

Output

Conditionally selected types

Sample tests

Sample 1

Input: NonNullable<string | null>
Expected: string

Your solution

Learning objective

Master type-level programming and conditional types