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

HTTP_METHODS_PARTIAL_LOWERCASE is missing head #4492

Closed
edoardo-bluframe opened this issue Mar 20, 2024 · 1 comment · Fixed by #4493
Closed

HTTP_METHODS_PARTIAL_LOWERCASE is missing head #4492

edoardo-bluframe opened this issue Mar 20, 2024 · 1 comment · Fixed by #4493
Assignees
Labels
bug Bug or defect types TypeScript type definitions
Milestone

Comments

@edoardo-bluframe
Copy link

Runtime

node.js

Runtime version

18

Module version

21

Last module version without issue

No response

Used with

No response

Any other relevant information

No response

What are you trying to achieve or the steps to reproduce?

We have a controller that must only respond to the head method

Hapi works with it by creating a get route and then checking request.method for method === "head"

But types from @hapi/hapi do not support head!

In lib/types/utils.d.ts line 14:

export type HTTP_METHODS_PARTIAL_LOWERCASE = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'options';

All we need to do to fix this is add | 'head' to the list!

What was the result you got?

if(method === "head") {

typescript: This comparison appears to be unintentional because the types 'HTTP_METHODS_PARTIAL_LOWERCASE' and '"head"' have no overlap. [2367]

What result did you expect?

Expected it to work!

I can raise a PR if you want?

@edoardo-bluframe edoardo-bluframe added the bug Bug or defect label Mar 20, 2024
@kanongil kanongil added the types TypeScript type definitions label Mar 21, 2024
@kanongil
Copy link
Contributor

Thanks for the report.

I understand the issue, but your proposed fix is not suitable, as we don't want to allow head to be allowed in the route method field. I have looked further into it, and revised the method typings to be correct for all method fields in #4493. The exact typings for each method turns out to be unique for all of them.

@Marsup Marsup added this to the 21.3.8 milestone Apr 3, 2024
@Marsup Marsup self-assigned this Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug or defect types TypeScript type definitions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants