Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Type 'string' is not assignable to type 'HttpMethod'.ts(2345) #3168

Closed
ronag opened this issue Apr 26, 2024 · 1 comment · Fixed by #3457
Closed

Type 'string' is not assignable to type 'HttpMethod'.ts(2345) #3168

ronag opened this issue Apr 26, 2024 · 1 comment · Fixed by #3457
Labels
bug Something isn't working

Comments

@ronag
Copy link
Member

ronag commented Apr 26, 2024

Can we change the type of method to just regular string? I keep getting this ts warning.

@ronag ronag added the bug Something isn't working label Apr 26, 2024
@Uzlopak
Copy link
Contributor

Uzlopak commented Apr 26, 2024

This is actually a bug in your implementation and not of undici tylings. Meaning that you are not narrowing down the type to an intersection of HTTPmethod. You have to typecast it to any, or typecast it to HTTPMethod, or the interface were you defined method as string to HTTPMethod.

If we set it to string, it would mean we accept any method name, even custom ones, like ronag method or aras method. Are we doing that? If so, then there is a special notation to keep the code completion ability and allow any string value.
If not I would highly recommend to consider it a bug in userland.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants