Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New "Missing annotation" error in flowjs 0.54.0

After switching to flow 0.54.0 the following code fragment:

function runKarmaTest() {
    const KARMA_CONFIG = {};
    return new Promise(function (resolve, reject) {
        new karma.Server(KARMA_CONFIG, function (exitCode) {
            if (exitCode === 0) {
                resolve();
            } else {
                reject(exitCode);
            }
        }).start();
    });
}

reports the following error:

Error: scripts/runKarma.js:76
               v----------------------------------------
 76:    return new Promise(function (resolve, reject) {
 77:            new karma.Server(KARMA_CONFIG, function (exitCode) {
 78:                    if (exitCode === 0) {
...:
 84:    });
        -^ type parameter `R` of constructor call. Missing annotation

in the line return new Promise(function (resolve, reject) { and I cannot seem to figure out what's wrong ?

like image 464
doberkofler Avatar asked Dec 02 '22 11:12

doberkofler


1 Answers

It looks like the thing it wants to know is the type of value wrapped by the promise. In this case it looks like it's just undefined, since the success case doesn't give any value. You can probably annotate the function that returns this as returning a Promise<void> or something like that to make this error go away.

It is curious that this happens in 0.54 and not before, though.

like image 146
Adam Avatar answered Dec 05 '22 18:12

Adam