4

在下面得到这个错误,
error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'.



HandEvaluator.prototype.evaluateStraight = function (hand) {
    var consecutives = [];
    var length = hand.ranks.length;
    // for A2345 we put the A already in the consecutive array
    if (hand.hasRank(Rank.ACE))
        consecutives.push(hand.ranks[Rank.ACE][0]);  **<=// LINE 173**
    // we loop through each rank in hand, if we find a group of card
    // we push the first one of the group into consecutives
    // if there is no card at said rank we reset consecutives.
    for (var i = 0; i < length; i++) {
        // we are only sure there is at least one card at that rank
        if (hand.hasRank(i))
            consecutives.push(hand.ranks[i][0]);  <=// LINE 180
        else
            consecutives = [];
        // if we have 5 consecutives cards we still need to check
        // that there isn't anymore after
        if (consecutives.length >= 5) {
            var nextCards = hand.ranks[i + 1];
            if (nextCards && nextCards.length === 0) {
                break;
            }
        }
    }

我在第 173 行和第 180 行都收到此错误

TypeScript“类型”错误的任何方向?

4

0 回答 0