How to extend Dispatcher.HttpMethod typescript definition? #2262
-
Hello, I want to use this library to perform HTTP calls to WebDAV. What I already tried:
import { request } from 'undici';
request('https://some.webdav.com', {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
method: 'MKCOL' as any
});
declare module 'undici' {
namespace Dispatcher {
interface DispatchOptions {
method?: HttpMethod;
}
type HttpMethod = string;
}
} Could you help me? |
Beta Was this translation helpful? Give feedback.
Answered by
metcoder95
Sep 12, 2023
Replies: 1 comment 1 reply
-
Hey! You need to augment the import { request } from 'undici';
declare module 'undici' {
namespace Dispatcher {
interface RequestOptions {
method: HttpMethod | 'MKCOL';
}
}
}
request('http://localhost:3000', {
method: 'MKCOL',
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
dkatashev
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey! You need to augment the
RequestOptions
interface, not theDispatchOptions
one. As follows: