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

chore(common): Add type declaration for RawBody decorator with pipes #14256

Merged

Conversation

sapenlei
Copy link
Contributor

@sapenlei sapenlei commented Dec 3, 2024

Closes #14254

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: #14254

What is the new behavior?

The RawBody decorator now has proper TypeScript type declarations for pipe transformations. Users can now use pipes with the RawBody decorator with full type safety

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@coveralls
Copy link

coveralls commented Dec 3, 2024

Pull Request Test Coverage Report for Build f206fb07-9d65-44e5-aa8d-f3b37f665bb1

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 91.932%

Totals Coverage Status
Change from base Build f696b4b4-02b7-4b03-bd63-c077a97db9f0: 0.0%
Covered Lines: 6814
Relevant Lines: 7412

💛 - Coveralls

*
* @publicApi
*/
export function RawBody(): ParameterDecorator;
Copy link
Member

Choose a reason for hiding this comment

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

This is an overloaded method signature. Instead of removing it, we should just add one for the variant with pipes, right below this line

Copy link
Contributor Author

@sapenlei sapenlei Dec 3, 2024

Choose a reason for hiding this comment

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

The type declaration for RawBody(...args) already supports the empty parameter case RawBody(), so you can safely remove the separate empty parameter declaration.

the type declaration for RawBody(...args) already supports the empty parameter case RawBody(), so you can safely remove the separate empty parameter declaration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

This is just for better DX - we do it all around the ecosystem

@kamilmysliwiec kamilmysliwiec merged commit 265f6d0 into nestjs:master Dec 3, 2024
4 checks passed
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.

@RawBody(new ValidationPipe()) function signature is missing in type declaration file
3 participants