From f40cda45841e93b056c781c19651b54464f7346a Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Mon, 8 Jan 2024 13:08:48 +0100 Subject: [PATCH] remove references to "dom" ts lib (#11449) * remove references to "dom" ts lib * changeset * api extractor --- .api-reports/api-report-core.md | 4 ++-- .api-reports/api-report-link_batch-http.md | 2 +- .api-reports/api-report-link_http.md | 4 ++-- .api-reports/api-report.md | 4 ++-- .changeset/many-bottles-count.md | 5 +++++ src/link/http/__tests__/HttpLink.ts | 5 +---- src/link/http/checkFetcher.ts | 4 +--- src/link/http/selectHttpOptionsAndBody.ts | 2 +- src/tsconfig.json | 2 +- tsconfig.json | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) create mode 100644 .changeset/many-bottles-count.md diff --git a/.api-reports/api-report-core.md b/.api-reports/api-report-core.md index 7dd6cb37a62..ba90cf855d1 100644 --- a/.api-reports/api-report-core.md +++ b/.api-reports/api-report-core.md @@ -395,7 +395,7 @@ const enum CacheWriteBehavior { type CanReadFunction = (value: StoreValue) => boolean; // @public (undocumented) -export const checkFetcher: (fetcher: WindowOrWorkerGlobalScope["fetch"] | undefined) => void; +export const checkFetcher: (fetcher: typeof fetch | undefined) => void; // @public (undocumented) export type ClientParseError = InvariantError & { @@ -897,7 +897,7 @@ export class HttpLink extends ApolloLink { // @public (undocumented) export interface HttpOptions { credentials?: string; - fetch?: WindowOrWorkerGlobalScope["fetch"]; + fetch?: typeof fetch; fetchOptions?: any; headers?: Record; includeExtensions?: boolean; diff --git a/.api-reports/api-report-link_batch-http.md b/.api-reports/api-report-link_batch-http.md index 084012f6684..c7952979747 100644 --- a/.api-reports/api-report-link_batch-http.md +++ b/.api-reports/api-report-link_batch-http.md @@ -156,7 +156,7 @@ interface GraphQLRequest> { // @public (undocumented) interface HttpOptions { credentials?: string; - fetch?: WindowOrWorkerGlobalScope["fetch"]; + fetch?: typeof fetch; fetchOptions?: any; headers?: Record; includeExtensions?: boolean; diff --git a/.api-reports/api-report-link_http.md b/.api-reports/api-report-link_http.md index 2f059c22471..363dff4a60e 100644 --- a/.api-reports/api-report-link_http.md +++ b/.api-reports/api-report-link_http.md @@ -60,7 +60,7 @@ interface Body_2 { } // @public (undocumented) -export const checkFetcher: (fetcher: WindowOrWorkerGlobalScope["fetch"] | undefined) => void; +export const checkFetcher: (fetcher: typeof fetch | undefined) => void; // @public (undocumented) export type ClientParseError = InvariantError & { @@ -186,7 +186,7 @@ export class HttpLink extends ApolloLink { // @public (undocumented) export interface HttpOptions { credentials?: string; - fetch?: WindowOrWorkerGlobalScope["fetch"]; + fetch?: typeof fetch; fetchOptions?: any; headers?: Record; includeExtensions?: boolean; diff --git a/.api-reports/api-report.md b/.api-reports/api-report.md index 77f78c50806..d1024c01738 100644 --- a/.api-reports/api-report.md +++ b/.api-reports/api-report.md @@ -507,7 +507,7 @@ const enum CacheWriteBehavior { type CanReadFunction = (value: StoreValue) => boolean; // @public (undocumented) -export const checkFetcher: (fetcher: WindowOrWorkerGlobalScope["fetch"] | undefined) => void; +export const checkFetcher: (fetcher: typeof fetch | undefined) => void; // @public (undocumented) export type ClientParseError = InvariantError & { @@ -1075,7 +1075,7 @@ export class HttpLink extends ApolloLink { // @public (undocumented) export interface HttpOptions { credentials?: string; - fetch?: WindowOrWorkerGlobalScope["fetch"]; + fetch?: typeof fetch; fetchOptions?: any; headers?: Record; includeExtensions?: boolean; diff --git a/.changeset/many-bottles-count.md b/.changeset/many-bottles-count.md new file mode 100644 index 00000000000..2d1c5ef523f --- /dev/null +++ b/.changeset/many-bottles-count.md @@ -0,0 +1,5 @@ +--- +"@apollo/client": patch +--- + +Removes refences to the typescript "dom" lib. diff --git a/src/link/http/__tests__/HttpLink.ts b/src/link/http/__tests__/HttpLink.ts index b2ce5308cfd..6b29b63cfb2 100644 --- a/src/link/http/__tests__/HttpLink.ts +++ b/src/link/http/__tests__/HttpLink.ts @@ -887,10 +887,7 @@ describe("HttpLink", () => { itAsync("allows uri to be a function", (resolve, reject) => { const variables = { params: "stub" }; - const customFetch: WindowOrWorkerGlobalScope["fetch"] = ( - uri, - options - ) => { + const customFetch: typeof fetch = (uri, options) => { const { operationName } = convertBatchedBody(options!.body); try { expect(operationName).toBe("SampleQuery"); diff --git a/src/link/http/checkFetcher.ts b/src/link/http/checkFetcher.ts index 964bdd433d4..49a75586a70 100644 --- a/src/link/http/checkFetcher.ts +++ b/src/link/http/checkFetcher.ts @@ -1,8 +1,6 @@ import { newInvariantError } from "../../utilities/globals/index.js"; -export const checkFetcher = ( - fetcher: WindowOrWorkerGlobalScope["fetch"] | undefined -) => { +export const checkFetcher = (fetcher: typeof fetch | undefined) => { if (!fetcher && typeof fetch === "undefined") { throw newInvariantError(` "fetch" has not been found globally and no fetcher has been \ diff --git a/src/link/http/selectHttpOptionsAndBody.ts b/src/link/http/selectHttpOptionsAndBody.ts index 8789d16f302..33ec947cb37 100644 --- a/src/link/http/selectHttpOptionsAndBody.ts +++ b/src/link/http/selectHttpOptionsAndBody.ts @@ -36,7 +36,7 @@ export interface HttpOptions { /** * A `fetch`-compatible API to use when making requests. */ - fetch?: WindowOrWorkerGlobalScope["fetch"]; + fetch?: typeof fetch; /** * An object representing values to be sent as headers on the request. diff --git a/src/tsconfig.json b/src/tsconfig.json index 321f038a735..e5f75afe0f6 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -5,7 +5,7 @@ { "compilerOptions": { "noEmit": true, - "lib": ["es2015", "esnext.asynciterable", "dom"], + "lib": ["es2015", "esnext.asynciterable"], "types": ["jest", "node", "./testing/matchers/index.d.ts"] }, "extends": "../tsconfig.json", diff --git a/tsconfig.json b/tsconfig.json index 1285cfa64dd..cdb8b9cca26 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,7 @@ "esModuleInterop": true, "experimentalDecorators": true, "outDir": "./dist", - "lib": ["es2015", "esnext.asynciterable", "dom"], + "lib": ["es2015", "esnext.asynciterable"], "jsx": "react", "strict": true },