just icon indicating copy to clipboard operation
just copied to clipboard

Types of just-diff and just-diff-apply do not match

Open rogorman9 opened this issue 2 years ago • 1 comments

If I use the diff function from just-diff with the jsonPatchPathConverter function provided there, and then use diffApply from just-diff-apply on the result with its jsonPathPathConverter, I receive a TypeError on path.

Minimal example:

const obj1 = {};
const obj2 = {};
const diffObj = diff(obj1, obj2, jsonPatchPathConverter);
diffApply(obj1, diffObj, jsonPatchPathConverter);

With this code, I receive the following error in TypeScript 5.0.4:

Type '{ op: Operation; path: string; value: any; }[]' is not assignable to type 'DiffOps'.
  Type '{ op: Operation; path: string; value: any; }' is not assignable to type '{ op: Operation; path: (string | number)[]; value?: any; }'.
    Types of property 'path' are incompatible.
      Type 'string' is not assignable to type '(string | number)[]'.

rogorman9 avatar May 22 '23 23:05 rogorman9

I also came here to report this bug. Seems like the types are spec'd differently for jsonPatchPathConverter between just-diff and just-diff-apply.

tsekiguchi avatar Jan 17 '24 20:01 tsekiguchi