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

Getting error Type peg$SyntaxError is missing the following properties from type Error #583

Open
NogaMan opened this issue Mar 10, 2025 · 2 comments

Comments

@NogaMan
Copy link

NogaMan commented Mar 10, 2025

When using Syntax error in tests like so

expect(() => service.parse(code)).toThrowError(SyntaxError);

I get error

Argument of type typeof peg$SyntaxError is not assignable to parameter of type new (...args: any[]) => Error
Type peg$SyntaxError is missing the following properties from type Error: name, message

It worked properly when I was using peg.js

How can I fix this?

@hildjj
Copy link
Contributor

hildjj commented Mar 10, 2025

This is a consequence of the nonsense we've got to deal with IE10, which doesn't support any modern forms of JS. When we fix the code generation, this will get cleaned up, so that peg$SyntaxError will be a straight subclass of Error.

In the meantime, if anyone wants to take a crack at fixing the ES5 code generation, it's here.

@NogaMan
Copy link
Author

NogaMan commented Mar 11, 2025

I don't see a straightforward solution rather than rolling back the code to from 4 year ago, which was changed for some reason here

For now I just used a hack .toThrowError(SyntaxError as any)

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