我不知道我在做什麼錯在這裏:流量抱怨減少返回一個布爾
export function subscriptionsReady(handles: Array<Object>): boolean {
if (handles.length === 1) return handles[0].ready();
return handles.reduce((a: any, b: Object): boolean => {
return (typeof a === 'object' ? a.ready() : a) && b.ready();
});
}
流量錯誤:
9: return handles.reduce((a: any, b: Object): boolean => {
^call of method `reduce`
9: return handles.reduce((a: any, b: Object): boolean => {
^undefined (too few arguments, expected default/rest parameters). This type is incompatible with the expected return type of
6: export function subscriptionsReady(handles: Array<Object>): boolean {
^^^^^^^ boolean
這些類型記住,'reduce'可以在陣列中返回類型的值(在你的情況下'Object'型),如果有隻數組中的一個元素。我認爲這就是爲什麼流類型抱怨返回類型。也許提供'true'或'false'的初始值 – Doc