切换到流量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) {
行,我似乎无法弄清楚错误是什么?
答案 0 :(得分:11)
看起来它想知道的是承诺所包含的值的类型。在这种情况下,它看起来只是prim.y
,因为成功案例没有给出任何价值。您可以注释返回此函数的函数,即返回library(dplyr)
full_join(txie,grny,by="site") %>%
mutate(year = coalesce(year.x,.$year.y),
yield = coalesce(yield.x,yield.y),
prim = coalesce(prim.x,prim.y)) %>%
select(-c(year.x,year.y,yield.x,yield.y,prim.x,prim.y))
site lat year yield prim
1 smithfield 59.71994 1999 7.920844 nt
2 smithfield 59.71994 2000 10.122713 nt
3 belleville 34.93358 1992 8.622351 nt
4 belleville 34.93358 1993 7.360470 nt
5 belleville 34.93358 1994 NA nt
6 nashua 49.10000 1990 9.083390 ct
7 nashua 49.10000 1991 8.073866 nt
8 nashua 49.10000 1992 8.725625 nt
或类似的东西,以使此错误消失。
奇怪的是,这发生在0.54而不是之前。
答案 1 :(得分:7)
Promise<void>
函数中的runKarmaTest
注释解决了这个问题:
function runKarmaTest(): Promise<void> {
const KARMA_CONFIG = {};
return new Promise(function (resolve, reject) {
new karma.Server(KARMA_CONFIG, function (exitCode) {
if (exitCode === 0) {
resolve();
} else {
reject(exitCode);
}
}).start();
});
}
我还不确定:
Type Inference
无法从解析