All academies
All challenges

Unwrap a Promise with Conditional Types

hardadvanced-types200 XP

Problem

Implement UnwrapPromise<T>: a conditional type that extracts U from Promise<U>, and leaves non-promise types unchanged (UnwrapPromise<string> is just string). Use the infer keyword. Then use it to type values derived from an async function's return type.

Expected output

50
plain

Hints

Stuck? Reveal hints one at a time.

Solution

Try solving it yourself first — revealing is always available.

Press Run in the editor — your console output is checked automatically.
No errors
Loading...

Console output appears here. Press Run or just type — the code compiles automatically.