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

LoroCounter cannot go inside a Container? #626

Closed
canadaduane opened this issue Jan 17, 2025 · 0 comments · Fixed by #627
Closed

LoroCounter cannot go inside a Container? #626

canadaduane opened this issue Jan 17, 2025 · 0 comments · Fixed by #627

Comments

@canadaduane
Copy link

I'm trying to understand if I've made a mistake here, or if the library does not yet support LoroCounter inside a map:

// sandbox.ts
import { LoroCounter, LoroMap, LoroText, type Container } from "loro-crdt";

export function createItem(label: string, checked: boolean) {
  const item = new LoroMap<Record<string, Container>>();

  const $label = new LoroText();
  $label.insert(0, label);

  const $checked = new LoroCounter();
  if (checked) $checked.increment(1);

  item.setContainer("label", $label);
  item.setContainer("checked", $checked);

  return item;
}

const item = createItem("hello", true);

console.log(item.get("label").toString());
console.log(item.get("checked").value);

Typescript reports:

ts: Argument of type 'LoroCounter' is not assignable to parameter of type 'Container'.
  Type 'LoroCounter' is missing the following properties from type 'LoroMovableList<unknown>': getCursor, toArray, insertContainer, pushContainer, and 17 more.

And when I run the script, I get the following runtime error:

$ bun sandbox.ts
error: No kind method found or not a function
No kind method found or not a function

Bun v1.1.43 (Linux x64)
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 a pull request may close this issue.

1 participant