类型“ any”的参数不能分配给类型“ never”的参数

时间:2018-10-01 13:38:23

标签: typescript types typescript-typings typescript3.0

在下面得到了这个错误,
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“类型”错误的说明?

0 个答案:

没有答案