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

Typing issue: headers in DispatchOptions should use OutgoingHttpHeaders #3840

Open
paucabuti opened this issue Nov 18, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@paucabuti
Copy link

paucabuti commented Nov 18, 2024

Bug Description

The headers property in the DispatchOptions interface currently uses IncomingHttpHeaders. Since this property is used for outgoing HTTP requests, it would be more appropriate to type it as OutgoingHttpHeaders.

In addition to the typing issue, there is an inconsistency between the documentation and the actual TypeScript definitions in the code. According to the documentation (see screenshot below), the headers property is described as:

headers: UndiciHeaders | string[] (optional)

imatge

In contrast, the TypeScript definition for DispatchOptions in the codebase defines headers as:

headers?: IncomingHttpHeaders | string[] | Iterable<[string, string]> | null;

Additional Observation

While reviewing the typing of headers in DispatchOptions, I noticed a similar issue in the ConnectOptions interface, where the headers are also typed as IncomingHttpHeaders. This makes me wonder if there might be a broader issue with the typing of headers across the library. Perhaps there was an intention to use a generic type for headers, but it seems like only one of the possible types (likely IncomingHttpHeaders) has been applied throughout

@paucabuti paucabuti added the bug Something isn't working label Nov 18, 2024
@mcollina
Copy link
Member

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests. We use tsd to test our types.

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