Open glmdgrielson opened 6 years ago
We’ve had some problems recently with the typescript bindings; they’re not written or maintained by the core maintainers (@hardmath123 and I).
Is this a bug in the generator, or in the typescript bindings? Thanks.
Sent with GitHawk
I think it's in the bindings:
export interface Lexer {reset:(chunk:string, info:any) => void; next:() => Token | undefined; save:() => any; formatError:(token:Token) => string; has:(tokenType:string) => boolean};
The error I got came when I made StreamLexer implement Lexer. Also, about the TypeScript stuff: If you need help with that, I'd be willing to lend a hand! (p.s. I'm not entirely sure what you mean by generator/typescript bindings but it's in the generate.typescript function)
Sorry. By the typescript bindings, I meant the @types/nearley
package: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/nearley
If you’ve found a bug in generate.js
, feel free to send a PR :-)
Sent with GitHawk
Okay, yeah it's definitely a bug in generate.js
. I'll try to send a PR soon, because both the default lexer AND the recommended one - yours, moo - fail to match the type specified by the Lexer definition.
What you have is:
formatError(token: Token, message?: string): string;
What you require is:
formatError(token: Token): string;
The pull request is up. :tada:
As a fun little thing I tried porting this to Typescript and I found a big hole in the Typescript generation, namely StreamLexer doesn't match the Lexer interface you provided. Oops...