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

Move ctor param info from global map to metadata. Fixes #161 #204

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

florian-g2
Copy link

@florian-g2 florian-g2 commented Jun 28, 2022

Hi there.

This PR moves the paramInfos acquired by the injectable() decorator from the global typeInfo map to constructor/class metadata.

That fixes a TypeInfo not known for ... bug occurring in an environment where a library with injectable dependencies is linked using symlinks (npm-link).

In this special environment, globals are not shared between the library and the main project, therefore the typeInfos populated by the injectable() decorator weren't accessible before to the main project.

Due to this unfavorable side-effect of the npm-link, the registry() and autoInjectable() decorators will still be broken because their functionalities require direct access to the global container instance.

Minimal repo reproducing the issue in the initial commit: https://github.com/florian-g2/npm-link-missing-globals

@ghost
Copy link

ghost commented Jun 28, 2022

CLA assistant check
All CLA requirements met.

@florian-g2
Copy link
Author

Another important note to take here is that no reflection polyfill is allowed to be imported inside the linked library.
This would lead to the same fact that the polyfills also use a global map to store the metadata.

If reflection methods are required by the library itself, the types can be declared like in https://github.com/rbuckton/reflect-metadata/blob/master/Reflect.d.ts

@florian-g2
Copy link
Author

Hey @Xapphire13 @MeltingMosaic, any chances this could get merged?

@endurance
Copy link

Definitely would like to get this merged in.

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

Successfully merging this pull request may close these issues.

None yet

3 participants