gpt4 book ai didi

javascript - flowjs 0.54.0 中的新 "Missing annotation"错误

转载 作者:搜寻专家 更新时间:2023-10-31 22:55:48 24 4
gpt4 key购买 nike

切换到flow 0.54.0后如下代码片段:

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();
});
}

报如下错误:

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

return new Promise(function (resolve, reject) { 行中,我似乎无法弄清楚哪里出了问题?

最佳答案

看起来它想知道的是 promise 包装的值的类型。在这种情况下,它看起来只是 undefined ,因为成功案例没有任何值(value)。您可以将返回 this 的函数注释为返回 Promise<void>或类似的东西来消除这个错误。

奇怪的是,这发生在 0.54 而不是之前。

关于javascript - flowjs 0.54.0 中的新 "Missing annotation"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45996511/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com