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

Add Supplemental Documentation for TypeScript #72

Open
chacha912 opened this issue Apr 20, 2023 · 1 comment
Open

Add Supplemental Documentation for TypeScript #72

chacha912 opened this issue Apr 20, 2023 · 1 comment
Labels
documentation 📔 Improvements or additions to documentation good first issue 🐤 Good for newcomers

Comments

@chacha912
Copy link
Contributor

Description:

While the yorkie documentation includes information on TypeScript, it would be helpful to provide an explanation on the usage of JSONElement types. Yorkie-js-sdk uses a proxy, and to use methods like array.insertAfter and array.insertBefore that are not available in the native JS type, specifying the type as JSONElement is necessary.

type DocType = {
  list: JSONArray<number>;
};

const doc = new yorkie.Document<DocType>('sample-doc');
doc.update((root) => {
  root.list = [0, 1]; 
  root.list.push(2);  
});
doc.update((root) => {
  // to use methods like `getElementByIndex` and `moveAfter`, the type should be specified as `JSONArray`
  const prev = root.list.getElementByIndex(0);
  const item = root.list.getElementByIndex(1);
  root.list.moveAfter(prev.getID(), item.getID());
});
@hackerwins hackerwins added documentation 📔 Improvements or additions to documentation good first issue 🐤 Good for newcomers labels Oct 26, 2023
@hackerwins
Copy link
Member

I recently heard about a bug with Array.Move that doesn't seem to be converging. It would be good to fix the bug and then add it to the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 📔 Improvements or additions to documentation good first issue 🐤 Good for newcomers
Projects
Status: Backlog
Development

No branches or pull requests

2 participants