Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#70446 feat(rdfjs/fetch-lite): allow body by
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode authored Sep 4, 2024
1 parent a5476a8 commit 704fd4b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
5 changes: 3 additions & 2 deletions types/rdfjs__fetch-lite/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Formats } from "@rdfjs/formats";
import { BaseQuad, DatasetCore, DatasetCoreFactory, Quad, Stream } from "@rdfjs/types";

export interface FormatsInit extends RequestInit {
formats: Formats;
export interface FormatsInit extends Omit<RequestInit, "body"> {
formats?: Formats;
fetch?: typeof fetch | undefined;
body?: RequestInit["body"] | Iterable<BaseQuad> | Stream;
}

export interface FactoryInit<
Expand Down
27 changes: 27 additions & 0 deletions types/rdfjs__fetch-lite/rdfjs__fetch-lite-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,33 @@ async function fetchQuadStream(): Promise<Stream> {
return response.quadStream();
}

async function sendQuadArray(): Promise<void> {
const quads: Quad[] = <any> {};

const response: Response = await fetch("http://example.com", {
method: "POST",
body: quads,
});
}

async function sendDataset(): Promise<void> {
const dataset: DatasetCore = <any> {};

const response: Response = await fetch("http://example.com", {
method: "POST",
body: dataset,
});
}

async function sendQuadStream(): Promise<void> {
const stream: Stream = <any> {};

const response: Response = await fetch("http://example.com", {
method: "POST",
body: stream,
});
}

interface QuadExt extends Quad {
toCanonical(): string;
}
Expand Down

0 comments on commit 704fd4b

Please sign in to comment.