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

Class 'SyntaxError' incorrectly implements interface 'Error' #155

Closed
hildjj opened this issue May 25, 2021 · 2 comments
Closed

Class 'SyntaxError' incorrectly implements interface 'Error' #155

hildjj opened this issue May 25, 2021 · 2 comments

Comments

@hildjj
Copy link
Contributor

hildjj commented May 25, 2021

With the current peg.d.ts, I get this error when compiling typescript that uses peggy:

../../lib/peg.d.ts:345:9 - error TS2420: Class 'SyntaxError' incorrectly implements interface 'Error'.
  Type 'SyntaxError' is missing the following properties from type 'Error': name, message

345   class SyntaxError implements Error {
            ~~~~~~~~~~~


Found 1 error.

I think we might need to add:

    name: string;
    message: string;
    stack?: string;

to the class, or change it to an interface?

@Mingun
Copy link
Member

Mingun commented May 25, 2021

Just need to change implements to extends -- this is one of special cases in TypeScript, where you should extend interface with class instead of implementing it.

@hildjj
Copy link
Contributor Author

hildjj commented May 25, 2021

Yes, that works. I'll put a fix into the type testing patch I'm finishing up.

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

No branches or pull requests

2 participants