All academies
All challenges

Implement ReturnType with infer

hardadvanced-types200 XP

Problem

Rebuild the built-in ReturnType utility: MyReturnType<T> must extract the return type from any function type using a conditional type with infer. MyReturnType<() => number> must be number, and applying it to typeof createUser must produce the exact object type that createUser returns.

Expected output

Grace
15

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.