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

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

Open
ronag opened this issue Apr 26, 2024 · 1 comment
Open

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

ronag opened this issue Apr 26, 2024 · 1 comment
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.

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

No branches or pull requests

2 participants