-
Notifications
You must be signed in to change notification settings - Fork 721
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
TypeError: Cannot read properties of null (reading 'constructor') #1664
Comments
Hey @c100k, thank you for your report. Please submit a minimum recreation code via code sandbox or any other platform. A reproduction repository with the minimum reproduction code is a valid choice as well. |
I see the issue, on my way to patch it.
I wish there was a better way to provide an ESM build compatible with NodeJS, browsers and bundlers in any typescript config. Not my cup of tea as well, but I don't see a better approach.
I see, indeed, |
Fixed in #1665, released in |
Is there an existing issue for this?
Current behavior
When executing tests via vitest, I have the following failure (that is not present in 6.0.3):
Steps to reproduce
No response
Expected behavior
Ideally, the code shouldn't fail like this. Indeed, there is no problem with
6.0.3
. From6.1.0
and subsequent versions it fails. These changes introduced in6.1.0
in https://github.com/inversify/InversifyJS/blob/master/src/planning/reflection_utils.ts#L20 seem very hacky with theas
and the eslint rules disabled.On the other side, when the error occurs, the stacktrace should give the correct paths. Right now, it gives
node_modules/src/planning/reflection_utils.ts
which is not the correct path. I think there is a problem with the sourcemap generation which goes one directory too far because of../../../
.Additionnally, I'm not sure it's a good idea to ship
esm
already bundled. Indeed, it makes it almost impossible to debug internally in order to find out the underlying issue of such an error.Possible solution
I suspect there is an issue with constructor arguments that are not "injected". But I'm still digging to understand why it works on
6.0.3
and why it has stopped working with6.1.0
and subsequent versions.When I add
console.log
in the bundled ESM code, I'm getting this:Indeed, this function seem to be able to receive something else than a
Newable
so it must make additional checks and avoid at all prices "casting" the type.Package version
6.1.5
Node.js version
22
In which operating systems have you tested?
Stack trace
No response
Other
No response
The text was updated successfully, but these errors were encountered: