undici icon indicating copy to clipboard operation
undici copied to clipboard

Improve request options docs and typings

Open ronag opened this issue 2 years ago • 1 comments

https://github.com/nodejs/undici/discussions/1168#discussioncomment-1991327

https://undici.nodejs.org/#/?id=undicirequesturl-options-promise status that options RequestOptions and links to https://undici.nodejs.org/#/docs/api/Dispatcher?id=parameter-requestoptions for which there's a teensy little ditty about Extends: DispatchOptions. That could be made much more visible and verbose. e.g. The options object may also contain options from DispatchOptions so that it doesn't go missed. Documentation doesn't have be terse and can be a lovely experience to read.

There's also the matter of the typings. The request typings read:

options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions, 'origin' | 'path'>, That's an intersection, not an extension. So the documentation isn't correct that the options for request are RequestOptions. Semantic hubalaboo but it's still not correct. It can however, lead to confusion when reading the typings within an editor.

With the typings there's some inconsistency between fetch options and request options: request options require passing the method: HttpMethod property, fetch doesn't require this.

ronag avatar Jan 18 '22 15:01 ronag

Taking this one on. If more than a week goes by, please ping me.

shellscape avatar Jan 18 '22 15:01 shellscape