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

refactor(common,core): use shared utils whenever possible #8797

Merged
merged 1 commit into from
Dec 16, 2021
Merged

refactor(common,core): use shared utils whenever possible #8797

merged 1 commit into from
Dec 16, 2021

Conversation

micalevisk
Copy link
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • 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?

In several places, utilities functions declared at https://github.com/nestjs/nest/blob/939f2d56d1c9ec25108ada7053dfc51cbc6be7c2/packages/common/utils/shared.utils.ts are not used when they could be used

What is the new behavior?

Every typeof x === y and typeof x !== y was replaced with some method from @nestjs/common/utils/shared.utils.ts file

The only line I didn't change was the following:

if (typeof routeOrType === 'function') {

for whatever reason, using isFunction(routeOrType) introduces a compile error:

packages/core/router/router-module.ts(49,23): error TS2339: Property 'children' does not exist on type 'Type<any> | RouteTree'.
  Property 'children' does not exist on type 'Type<any>'.
  
packages/core/router/router-module.ts(52,54): error TS2339: Property 'children' does not exist on type 'Type<any> | RouteTree'.
  Property 'children' does not exist on type 'Type<any>'.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

I choose to didn' t touch any .spec.ts file, and only files under packages directory.

Use every util defined at `shared.utils.ts` from `@nestjs/common`, when
possible. Only spec files aren't touched.
@coveralls
Copy link

Pull Request Test Coverage Report for Build 640b0495-a3cd-41ce-81e5-19830578f43a

  • 23 of 23 (100.0%) changed or added relevant lines in 13 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.007%) to 94.087%

Totals Coverage Status
Change from base Build 41b0d386-1506-44ca-bc4f-822370edf048: 0.007%
Covered Lines: 5665
Relevant Lines: 6021

💛 - Coveralls

@kamilmysliwiec
Copy link
Member

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants