Skip to content

Commit

Permalink
fix: make res.statusCode optional (#4471)
Browse files Browse the repository at this point in the history
* fix: make res.statusCode optional

* test: add tests

Co-authored-by: Поляков Владислав Михайлович <VMikPolyakov@sber.ru>
  • Loading branch information
polRk and polRk committed Dec 19, 2022
1 parent f0455e7 commit 35e7c1a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions test/types/logger.test-d.ts
Expand Up @@ -123,6 +123,21 @@ const serverAutoInferredFileOption = fastify({

expectType<FastifyBaseLogger>(serverAutoInferredFileOption.log)

const serverAutoInferredSerializerResponseObjectOption = fastify({
logger: {
serializers: {
res (ServerResponse) {
expectType<FastifyReply>(ServerResponse)
return {
status: '200'
}
}
}
}
})

expectType<FastifyBaseLogger>(serverAutoInferredSerializerResponseObjectOption.log)

const serverAutoInferredSerializerObjectOption = fastify({
logger: {
serializers: {
Expand Down
2 changes: 1 addition & 1 deletion types/logger.d.ts
Expand Up @@ -60,7 +60,7 @@ export interface FastifyLoggerOptions<
[key: string]: unknown;
};
res?: (res: RawReply) => {
statusCode: string | number;
statusCode?: string | number;
[key: string]: unknown;
};
};
Expand Down

0 comments on commit 35e7c1a

Please sign in to comment.