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

fix: make res.statusCode optional #4471

Merged
merged 2 commits into from Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
Copy link
Member

Choose a reason for hiding this comment

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

It does not seem the test above verifies this is optional.

Copy link
Member

Choose a reason for hiding this comment

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

The test does reflect it is optional since statusCode is not return inside res.
Not a direct assertion but just same outcome.

[key: string]: unknown;
};
};
Expand Down