Skip to content

fix(openapi-fetch): don't rely on DOM types #1827

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

Merged
merged 1 commit into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/smooth-actors-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"openapi-fetch": patch
---

Fix typing for environments without DOM lib
2 changes: 1 addition & 1 deletion packages/openapi-fetch/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface ClientOptions extends Omit<RequestInit, "headers"> {
}

export type HeadersOptions =
| HeadersInit
| Required<RequestInit>["headers"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change pulls a reference to HeadersInit from RequestInit rather than relying on the global declaration, which only exists in the DOM lib. In projects with the DOM lib, this reference will resolve to HeadersInit declared in lib.dom.d.ts. In projects with Node types and no DOM lib, this reference will resolve to HeadersInit from undici-types/fetch.d.ts as referenced from @types/node/globals.d.ts.

| Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined>;

export type QuerySerializer<T> = (
Expand Down