Bug Report: ESLint @typescript-eslint/no-unsafe-argument with serializerCompiler
Environment:
- fastify-type-provider-zod: 6.0.0
- Fastify: 5.6.0
- TypeScript: 5.x
- ESLint: typescript-eslint strict config
Issue:
When using serializerCompiler from fastify-type-provider-zod, ESLint throws: Unsafe argument of type error typed assigned to a parameter of type FastifySerializerCompiler
Code that triggers the issue:
import { validatorCompiler, serializerCompiler } from 'fastify-type-provider-zod';
function routesPlugin(fastify: FastifyInstance) {
fastify.setValidatorCompiler(validatorCompiler); // ✅ Works fine
fastify.setSerializerCompiler(serializerCompiler); // ❌ ESLint error
}
Root cause:
The issue stems from the union type in serializerCompiler:
FastifySerializerCompiler<$ZodType | { properties: $ZodType; }>
While validatorCompiler uses a simple type:
FastifySchemaCompiler<$ZodType>
Workarounds:
- Disable ESLint rule:
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
- Type assertion:
serializerCompiler as FastifySerializerCompiler<any>
Expected behavior:
serializerCompiler should work without ESLint warnings, similar to validatorCompiler.
Bug Report: ESLint @typescript-eslint/no-unsafe-argument with serializerCompiler
Environment:
Issue:
When using
serializerCompilerfrom fastify-type-provider-zod, ESLint throws: Unsafe argument of type error typed assigned to a parameter of type FastifySerializerCompilerCode that triggers the issue:
Root cause:
The issue stems from the union type in serializerCompiler:
While validatorCompiler uses a simple type:
Workarounds:
// eslint-disable-next-line @typescript-eslint/no-unsafe-argumentserializerCompiler as FastifySerializerCompiler<any>Expected behavior:
serializerCompilershould work without ESLint warnings, similar tovalidatorCompiler.