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(common): type narrowing context parameter on createParamDecorator's callback #14126

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

EeeasyCode
Copy link
Contributor

@EeeasyCode EeeasyCode commented Nov 10, 2024

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?

Issue Number: #14093

The context parameter in createParamDecorator callback currently has an any type, which reduces type safety. Developers are unable to leverage the type-checking benefits of TypeScript when working with this parameter.

What is the new behavior?

The context parameter in the createParamDecorator callback now has a narrower type of ExecutionContext. This allows developers to benefit from TypeScript’s type-checking capabilities, improving code quality and reducing potential errors when using this parameter in decorators.

image

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This change improves type safety and aligns with TypeScript best practices by eliminating unnecessary any types. Tests have been added to validate that the context parameter is indeed typed as ExecutionContext. Additional documentation has been updated to reflect this enhancement.

@coveralls
Copy link

coveralls commented Nov 10, 2024

Pull Request Test Coverage Report for Build 7eb12452-b4ee-4030-b499-95a1c23491be

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 92.243%

Totals Coverage Status
Change from base Build 72f148bc-4145-44b3-a3c4-06a616307114: 0.0%
Covered Lines: 6754
Relevant Lines: 7322

💛 - Coveralls

@EeeasyCode EeeasyCode changed the title fix: type narrowing ctx fix(common): type narrowing context parameter on createParamDecorator's callback Nov 10, 2024
@@ -1,7 +1,9 @@
import { ExecutionContext } from '..';
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 please import this from the file instead of from the barrel file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@micalevisk
Sure, I have just updated the code with the mentioned changes. Please check!

Thank you for the feedback.

@kamilmysliwiec kamilmysliwiec added this to the 11.0.0 milestone Nov 12, 2024
@kamilmysliwiec kamilmysliwiec changed the base branch from master to 11.0.0 November 12, 2024 08:36
@kamilmysliwiec
Copy link
Member

LGTM

@kamilmysliwiec kamilmysliwiec merged commit 945d134 into nestjs:11.0.0 Nov 12, 2024
3 checks passed
@kamilmysliwiec kamilmysliwiec mentioned this pull request Nov 20, 2024
12 tasks
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.

4 participants