Skip to content

Conversation

@marcolink
Copy link

@marcolink marcolink commented Dec 18, 2021

Add type definition for JSON Patch formatter matching official Operation definition from http://jsonpatch.com

@marcolink
Copy link
Author

@benjamine what do you think? are we good?

@Vinz93
Copy link

Vinz93 commented Jul 14, 2022

Any updates here? :)

@sghoweri
Copy link

sghoweri commented Aug 4, 2023

BUMP - any updates on this?

@marcolink
Copy link
Author

@sghoweri we eventually created a fork with more typescript support: https://github.com/contentful/jsondiffpatch

I also started an independent project to create patches:

https://github.com/marcolink/generate-json-patch

@sghoweri
Copy link

sghoweri commented Aug 4, 2023

@marcolink oh my gosh you're a lifesaver (was just dealing with the Typescript typing issues with this package) 🙏🏼

@sghoweri
Copy link

sghoweri commented Aug 4, 2023

Elegant array diffing by providing an objectHash to match array elements

Oh snap. This is precisely why we started digging into this library to begin with (array diffing combined with JSON patches). 👀

Copy link
Collaborator

@Methuselah96 Methuselah96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay review. Don't feel you need to update this PR, we plan on converting the codebase to TypeScript soon anyway, so these changes will likely get overridden, but feel free to update the PR with the requested changes and we can get it merged.

src/index.d.ts Outdated
}

type AddOperation = {
opp: string;
Copy link
Collaborator

@Methuselah96 Methuselah96 Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like these should be op and not opp (on all the operations)?


export type Operation = AddOperation | RemoveOperation | ReplaceOperation | MoveOperation

export interface JSONPatchFormatter {
Copy link
Collaborator

@Methuselah96 Methuselah96 Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally JSONPatchFormatter would inherit from Formatter, but we can handle that in a future PR.

@marcolink
Copy link
Author

@Methuselah96 for now we found our way around - looking forward to see the migration happening :)
... Not fully typed but we also started the migration to TS here

@marcolink marcolink closed this Aug 23, 2023
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

Successfully merging this pull request may close these issues.

4 participants