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

add autocompletable header types #3462

Merged
merged 1 commit into from
Aug 16, 2024
Merged

Conversation

KhafraDev
Copy link
Member

the header keys were taken from MDN and the values for the content-type header were taken from hono

@KhafraDev
Copy link
Member Author

The types only work for the object param of the constructor. It would be possible to add support for the other methods, but would require a generic which would interfere with the DOM types.

@@ -67,7 +67,7 @@ export interface SpecIterable<T> {
[Symbol.iterator](): SpecIterator<T>;
}

export type HeadersInit = string[][] | Record<string, string | ReadonlyArray<string>> | Headers
export type HeadersInit = [string, string][] | HeaderRecord | Headers
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReadonlyArray is just not correct. If we were to follow the logic in the PR that added it, the type should be any.

Any array pair that doesn't contain exactly 2 strings throws an error too, so string[][] is not strict enough.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should discuss this a little bit before merging.

Copy link
Collaborator

@Ethan-Arrowood Ethan-Arrowood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@KhafraDev KhafraDev merged commit 14ba3e8 into nodejs:main Aug 16, 2024
32 checks passed
@KhafraDev KhafraDev deleted the headers-types branch August 16, 2024 18:26
@github-actions github-actions bot mentioned this pull request Dec 3, 2024
This was referenced Dec 16, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants