Skip to content

Commit 0c370ea

Browse files
authored
🤖 Merge PR DefinitelyTyped#71490 [moo] Fix formatError type by @jdesrosiers
1 parent 3dc1931 commit 0c370ea

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

types/moo/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export interface Lexer {
7070
/**
7171
* Returns a string with a pretty error message.
7272
*/
73-
formatError(token: Token, message?: string): string;
73+
formatError(token?: Token, message?: string): string;
7474
/**
7575
* @deprecated since 0.5.0. Now just returns true
7676
*/

types/moo/moo-tests.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,15 @@ moo.compile({
102102
],
103103
// ...
104104
});
105+
106+
// formatError
107+
lexer.reset(`"foo"`);
108+
109+
let token = lexer.next();
110+
if (!token) {
111+
lexer.formatError(token);
112+
lexer.formatError(token, "No more tokens");
113+
} else {
114+
lexer.formatError(token);
115+
lexer.formatError(token, "Error message");
116+
}

0 commit comments

Comments
 (0)