Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jantimon opened this issue Jan 6, 2023 · 0 comments

Comments

@jantimon
Copy link

jantimon commented Jan 6, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant