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

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

Open
rogorman9 opened this issue May 22, 2023 · 1 comment
Open

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

rogorman9 opened this issue May 22, 2023 · 1 comment

Comments

@rogorman9
Copy link

rogorman9 commented May 22, 2023

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)[]'.
@tsekiguchi
Copy link

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.

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

2 participants