Quiz · Async code and outside data · lesson 4 of 10Quiz — callback or promiseHow do you type a callback-based API versus a Promise-based one?[A]A callback API declares its result as its own return type, and the callback only reports progress along the way, so (err, data) => void describes the steps, not the outcome. A Promise API is that same signature wrapped in a class, with the result type stored in its then.[B]A callback API puts the result in the callback's parameters, such as (err: Error | null, data?: T) => void, and returns void. A Promise API returns Promise<T>: the result is the type in the brackets, and the error has no slot, so .catch receives a rejection as any.[C]Both styles put the result in the callback's parameters, since Promise<T> is only another name for (cb: (v: T) => void) => void. The error type is the second type in the brackets, Promise<T, E>, so tsc checks what .catch receives, and a callback API differs only in returning void.[D]The two are typed the same way, because tsc rewrites callbacks into promises when it writes the JavaScript. The result becomes the function's own return type in both styles, and under strict mode err gets the type never, so a failure shows up in that type too.← BackPromise.all and callbacksNext →The error in catch is unknown