-
Notifications
You must be signed in to change notification settings - Fork 34
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
BindAll: Class constructor cannot be invoked without 'new' #47
Comments
Digging further, it appears the decorator works fine in production which would seem to indicate where to look further. Going to keep digging. |
Update from above reference: I can reproduce this with react-testing-library as well but am still not yet convinced it's an issue with this library. |
Another update: I tried with core-decorators instead of lodash-decorators and the tests pass just fine. So now I'm back to square one and can't say for sure that there's not an issue w/ lodash-decorators. |
This could be an issue with lodash-decorators implementation. core-decorators swaps out the method on the prototype with a getter that binds upon accessing the property on the instance. lodash-decorators tries to replace the constructor with one that binds upon construction (I don't think this works with all transpilers). I like the core-decorators approach to this. I'll try and find some time to create a similar implementation using lodash. |
@steelsojka I have a concern about the core-decorators approach and I'm not convinced it has to be this way (but my JS-fu is not strong): It's going to execute that Whereas, your solution is what React even recommends for |
The problem with my approach is that we hi jack the constructor and invoke the original with |
@icfantv So the error occurs when using native classes.
I'll try and find a way to make it work. |
@icfantv I think I have a fix. I will try and get it out in the next day or so. |
@steelsojka awesome and thanks! glad to hear it and happy to take a look. |
Since this is a breaking change in behavior, this is in version 6.0.0. |
This is probably the same issue as #26 but I have a repo that reproduces the issue.
Repo: https://github.com/icfantv/lodash-decorator-issue
Just run
yarn install
followed byyarn test
If you run
tsc
you can see the generated output in thebuild
directory. I freely admit I don't understand decorators and the generated code well enough to diagnose this as an issue w/ this lib or perhaps ts-jest. Happy to provide assistance if/where I can.The text was updated successfully, but these errors were encountered: