diff --git a/fastify.d.ts b/fastify.d.ts index aa0cc012d2..759090cd9a 100644 --- a/fastify.d.ts +++ b/fastify.d.ts @@ -183,6 +183,7 @@ type TrustProxyFunction = (address: string, hop: number) => boolean declare module '@fastify/error' { interface FastifyError { validation?: ValidationResult[]; + validationContext?: 'body' | 'headers' | 'parameters' | 'querystring'; } } diff --git a/test/types/fastify.test-d.ts b/test/types/fastify.test-d.ts index 63f65360c6..eac0a77e4d 100644 --- a/test/types/fastify.test-d.ts +++ b/test/types/fastify.test-d.ts @@ -10,7 +10,8 @@ import fastify, { InjectOptions, FastifyBaseLogger, RouteGenericInterface, ValidationResult, - FastifyErrorCodes + FastifyErrorCodes, + FastifyError } from '../../fastify' import { ErrorObject as AjvErrorObject } from 'ajv' import * as http from 'http' @@ -235,6 +236,12 @@ const ajvErrorObject: AjvErrorObject = { } expectAssignable(ajvErrorObject) +expectAssignable([ajvErrorObject]) +expectAssignable('body') +expectAssignable('headers') +expectAssignable('parameters') +expectAssignable('querystring') + const routeGeneric: RouteGenericInterface = {} expectType(routeGeneric.Body) expectType(routeGeneric.Headers)