Answers for "type a promise"

1

type a promise

/*The generic type of the Promise should correspond to the 
non-error return-type of the function. The error is implicitly 
of type any and is not specified in the Promise generic type. */
function test(arg: string): Promise<number> {
    return new Promise<number>((resolve, reject) => {
        if (arg === "a") {
            resolve(1);
        } else {
            reject("1");
        }
    });
}
Posted by: Guest on November-12-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language