-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(context): check constructor/method override for @inject #1596
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
Conversation
virkt25
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to set options.ownMetadataOnly? Should this behaviour be documented?
|
@virkt25 If you're asking whether users should have the option to look for the just the subclass' metadata, I think we should but maybe in a separate PR as a feature later on. |
|
Sort of, Just wanted to know if the user had any control over setting this flag or not. Also this behaviour should be documented somewhere in the docs so users know what to expect when extending a class using DI. |
| if (target.toString().match(/\s+constructor\s*\([^\)]*\)\s+\{/m)) { | ||
| options.ownMetadataOnly = true; | ||
| } | ||
| } else if (target.hasOwnProperty(method)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this code block covered in a test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Coveralls, this branch is executed several times (14x) by our test suite. However, I cannot tell if there is a test that would fail if this branch was not present.
@raymondfeng could you please add an explicit test for this branch?
|
@bajtos Any opinions? |
bajtos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@raymondfeng the test case is legitimate. The implementation is a bit hacky, but I am ok with that since the ugliness is limited to a single place.
Fixes #1565
Checklist
npm testpasses on your machinepackages/cliwere updatedexamples/*were updated