automerge / automerge-classic

A JSON-like data structure (a CRDT) that can be modified concurrently by different users, and merged again automatically.
http://automerge.org/
MIT License
14.75k stars 466 forks source link

Include `elemId` into TypeScript definition of `Op` #424

Closed begor closed 3 years ago

begor commented 3 years ago

Hey!

It looks like elemId is missing from TypeScript definition of Op.

What's weird is that it's actually included in the JS object, e.g. if you do JSON.stringify(operation):

{"obj":"2@c8016fb46d8a4093aebefa23af4b6af1","elemId":"4@c8016fb46d8a4093aebefa23af4b6af1","action":"makeMap","insert":true,"pred":[]}

But you can't access it in TypeScript, because it's missing from Op.

Ideally, we'd like to have an access to elemId to be able to "interpret" changes without using automerge methods (e.g. in a different runtime). Without elementID it becomes problematic (if not impossible).

So in this PR I've added elemId property to the list of attributes for a TS representation of Op.

ept commented 3 years ago

Thanks @begor! I think that was just an accidental omission from the type definition.