angus-c / angus-c/just

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

Open
#560 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
6.2k
Forks
209
PR merge metrics
No merged PRs in 30d

Description

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:
```ts
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)[]'.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.