Skip to content

Add missing property validationContext on error object#3354

Closed
ariesclark wants to merge 3 commits intofastify:mainfrom
ariesclark:patch-1
Closed

Add missing property validationContext on error object#3354
ariesclark wants to merge 3 commits intofastify:mainfrom
ariesclark:patch-1

Conversation

@ariesclark
Copy link
Copy Markdown

@ariesclark ariesclark commented Oct 2, 2021

Checklist

@github-actions github-actions bot added the typescript TypeScript related label Oct 2, 2021
Copy link
Copy Markdown
Member

@climba03003 climba03003 left a comment

Choose a reason for hiding this comment

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

Can you add an unit test for the changes?

It should be added in this folder https://github.com/fastify/fastify/tree/main/test/types

declare module 'fastify-error' {
interface FastifyError {
validation?: ValidationResult[];
validationContext?: string;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it not possible to define the values it can assume?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think it's safer to just type as a string instead of a union.

@ariesclark
Copy link
Copy Markdown
Author

ariesclark commented Oct 2, 2021

Can you add an unit test for the changes?

It should be added in this folder https://github.com/fastify/fastify/tree/main/test/types

The change is already tested by this line.
https://github.com/rubybb/fastify/blob/907c2e274bb9cc77695add824a7f285df2f1b87c/test/types/hooks.test-d.ts#L99

Also we can add the hacktoberfest tag to this repository?
For more information: https://hacktoberfest.digitalocean.com/

@mcollina
Copy link
Copy Markdown
Member

mcollina commented Oct 2, 2021

If it's already tested there is no need for this change. I think it's a worthwhile change.

@climba03003
Copy link
Copy Markdown
Member

climba03003 commented Oct 2, 2021

Can you add an unit test for the changes?
It should be added in this folder https://github.com/fastify/fastify/tree/main/test/types

The change is already tested by this line. https://github.com/rubybb/fastify/blob/907c2e274bb9cc77695add824a7f285df2f1b87c/test/types/hooks.test-d.ts#L99

Also we can add the hacktoberfest tag to this repository? For more information: https://hacktoberfest.digitalocean.com/

The test should be something like

expectType<string | undefined>(error.validationContext)

because the test you mention will always pass for any changes in FastifyError.

@ariesclark
Copy link
Copy Markdown
Author

because the test you mention will always pass for any changes in FastifyError.

There is no check for any other properties in the error object, why should this one be unique?

@climba03003
Copy link
Copy Markdown
Member

climba03003 commented Oct 2, 2021

because the test you mention will always pass for any changes in FastifyError.

There is no check for any other properties in the error object, why should this one be unique?

Test should be exist to ensure no regression in future. The current test is not enough for this purpose.

@climba03003
Copy link
Copy Markdown
Member

@RubyBB Can you fix the missing import for the test? I think it is the last pieces before merge.

@Eomm
Copy link
Copy Markdown
Member

Eomm commented Jan 29, 2022

Friendly ping @RubyBB

Would you like to push this PR over the line?

@github-actions
Copy link
Copy Markdown

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

typescript TypeScript related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants