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

fix(core) add a replacer to handle functions/classes when creating mo… #2457

Merged
merged 1 commit into from
Jun 28, 2019

Conversation

zen0wu
Copy link
Contributor

@zen0wu zen0wu commented Jun 26, 2019

…dule tokens

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: #2379

What is the new behavior?

ModuleTokenFactory now correctly handles metadata with class/function objects in.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@coveralls
Copy link

coveralls commented Jun 26, 2019

Pull Request Test Coverage Report for Build 3344

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.004%) to 94.962%

Totals Coverage Status
Change from base Build 3329: 0.004%
Covered Lines: 3468
Relevant Lines: 3652

💛 - Coveralls

Copy link
Member

@BrunnerLivio BrunnerLivio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZenoZen Great PR, well done!

Can you try to run at least the integration/injector integration tests? That should run without any Docker container running. Use mocha integration/injector/**/*.spec.ts --reporter spec --require ts-node/register --require 'node_modules/reflect-metadata/Reflect.js'

If you get it running, could you also add a new test case into the integration/injector folder to mimic your case of having a Dynamic Module with providers - so we do not break it again?

@@ -50,4 +50,12 @@ export class ModuleTokenFactory {
const scope = Reflect.getMetadata(SHARED_MODULE_METADATA, metatype);
return scope ? scope : 'global';
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment about why this replacer function exists in the first place? So future contributors won't get confused and delete this function :)

@zen0wu
Copy link
Contributor Author

zen0wu commented Jun 26, 2019

@BrunnerLivio Ah, will do. I tried to run all integration test suite and failed with some syntax error. Your command does successfully run the injector integration tests. Will make the change tonight after getting off work, thanks for the review :)

return value.name;
} else {
return value;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 tip: You dont need this else statement.

    if (typeof value === 'function') {
      return value.name;
    }
    return value;

@kamilmysliwiec kamilmysliwiec merged commit 5fca173 into nestjs:master Jun 28, 2019
@kamilmysliwiec
Copy link
Member

I have added a comment :) Amazing contribution, thank you!

@zen0wu zen0wu deleted the module-token-factory-replacer branch July 2, 2019 01:13
@lock
Copy link

lock bot commented Sep 30, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants