Skip to content

Commit 0ce7935

Browse files
committed
chore: Add clarifying comments on castings
1 parent 56ad2dd commit 0ce7935

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/common/atlas/apiClient.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export class ApiClient {
3737
};
3838
};
3939

40+
// createFetch assumes that the first parameter of fetch is always a string
41+
// with the URL. However, fetch can also receive a Request object. While
42+
// the typechecking complains, createFetch does passthrough the parameters
43+
// so it works fine.
4044
private static customFetch: typeof fetch = createFetch({
4145
useEnvironmentVariableProxies: true,
4246
}) as unknown as typeof fetch;
@@ -104,6 +108,9 @@ export class ApiClient {
104108
Accept: `application/vnd.atlas.${ATLAS_API_VERSION}+json`,
105109
},
106110
fetch: ApiClient.customFetch,
111+
// NodeFetchRequest has more overloadings than the native Request
112+
// so it complains here. However, the interfaces are actually compatible
113+
// so it's not a real problem, just a type checking problem.
107114
Request: NodeFetchRequest as unknown as ClientOptions["Request"],
108115
});
109116

0 commit comments

Comments
 (0)