Skip to content

TS2322: Type '[number, number] | null' is not assignable to type 'void | [number, number]' #4

Open
@jantimon

Description

@jantimon

the shortestEdit function return type is [number, number] | void however it returns null in line 335:

json-delta/index.ts

Lines 300 to 336 in 41275a6

let shortestEdit: [number, number] | void = (function() {
for (var d = 0; d <= tolerance; ++d) {
for (var k = -d; k <= d; k += 2) {
let aIdx: number;
let takeB = aOfDiagonal[k + 1 + tolerance];
let takeA = aOfDiagonal[k - 1 + tolerance];
if (k === -d || (k !== d && takeA < takeB)) {
aIdx = takeB;
} else {
aIdx = takeA + 1;
}
let bIdx = aIdx - k;
while (
aIdx < aLen &&
bIdx < bLen &&
deepEqual(a[aIdx], b[bIdx])
) {
aIdx++;
bIdx++;
}
aOfDiagonal[k + tolerance] = aIdx;
if (aIdx >= aLen && bIdx >= bLen) {
aOfDiagonalForEditSize[d] = aOfDiagonal.slice();
return [d, k] as [number, number];
}
}
aOfDiagonalForEditSize[d] = aOfDiagonal.slice();
}
return null;
})();

I can prepare a PR if it helps

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions