Skip to content

Commit

Permalink
🏷️ Fix Quill.getText() arguments
Browse files Browse the repository at this point in the history
`Quill.getText()` is allowed to be called with no arguments, since it
[defaults][1] to returning the whole document.

However, the overload declarations require arguments, resulting in a
compilation error when trying to call `getText()` with no arguments:

```
(method) Quill.getText(range: {
    index: number;
    length: number;
}): string (+1 overload)
Expected 1-2 arguments, but got 0.ts(2554)
```

This change makes all the arguments in the overloads optional to match
the implementation.

[1]: https://github.com/quilljs/quill/blob/d2f689fb4744cdada96c632a8bccf6d476932d7b/core/quill.ts#L501-L502
  • Loading branch information
alecgibson committed Feb 7, 2023
1 parent d2f689f commit fc397a9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/quill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,8 @@ class Quill {
return this.editor.getHTML(index, length);
}

getText(range: { index: number; length: number }): string;
getText(index: number, length?: number): string;
getText(range?: { index: number; length: number }): string;
getText(index?: number, length?: number): string;
getText(
index: { index: number; length: number } | number = 0,
length?: number,
Expand Down

0 comments on commit fc397a9

Please sign in to comment.