cf.completefrontend

Write the codeHard

Write MyAwaited<T> so it unwraps any thenable the way await does, not only a Promise.

This version unwraps nested Promises, but await works on any object with a promise-style then method, such as a PromiseLike from a library or a hand-written thenable. Make MyAwaited unwrap those too, through any number of levels, and return a type that isn't thenable unchanged. Don't use the built-in Awaited.

Write this
type MyAwaited<T> = T extends Promise<infer V> ? MyAwaited<V> : T; // Promise only type Thenable = { then(onfulfilled: (value: boolean) => void): void }; // MyAwaited<Promise<Promise<number>>>  // number// MyAwaited<PromiseLike<Date>>         // should be Date// MyAwaited<Thenable>                  // should be boolean// MyAwaited<number>                    // number

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…