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

register type error #4163

Closed
chengfengfengwang opened this issue May 2, 2024 · 1 comment
Closed

register type error #4163

chengfengfengwang opened this issue May 2, 2024 · 1 comment
Labels
bug:types issues that are only related to declarations

Comments

@chengfengfengwang
Copy link

chengfengfengwang commented May 2, 2024

function Counter(quill:Quill, options:{unit:string,container:string}) {
  const container = document.querySelector(options.container) as HTMLDivElement;
  quill.on(Quill.events.TEXT_CHANGE, () => {
    const text = quill.getText();
    if (options.unit === 'word') {
      container.innerText = text.split(/\s+/).length + ' words';
    } else {
      container.innerText = text.length + ' characters';
    }

  });
}

Quill.register('modules/counter', Counter); // type error 
new Quill('#editor', {
  modules: {
    counter: {
      container: '#counter',
      unit: 'word'
    }
  }
});

The above code come from quill's offical website.
But, typescript has error: Argument of type '(quill: Quill, options: { unit: string; container: string; }) => void' is not assignable to parameter of type 'boolean | BlotConstructor | Attributor | undefined'.
How can I fix it ?

@luin luin added the bug:types issues that are only related to declarations label May 2, 2024
@luin
Copy link
Member

luin commented May 2, 2024

Might be fixed with #4127

@luin luin closed this as completed May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:types issues that are only related to declarations
Projects
None yet
Development

No branches or pull requests

2 participants