cf.completefrontend

Write the codeMedium

Write UnwrapPromise<T>: the value a promise resolves to, however deeply it's nested.

This version only unwraps one level, so UnwrapPromise<Promise<Promise<number>>> is Promise<number>. Fix it so it unwraps every level, unwraps each member of a union, and returns any type that isn't a promise unchanged.

Write this
type UnwrapPromise<T> = T extends Promise<infer Value> ? Value : T; // UnwrapPromise<Promise<string>>           // string// UnwrapPromise<Promise<Promise<number>>>  // should be number// UnwrapPromise<Promise<string> | boolean> // string | boolean

Solve it in the editor

The answer

Write it yourself first. Then compare it with a reference solution and the checks it passes.

Checking your sign-in…