Skip to content

Commit

Permalink
Remove DOM type references.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcr-stripe committed Jan 11, 2022
1 parent 44d65a1 commit ed7e765
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
8 changes: 7 additions & 1 deletion types/crypto/crypto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ declare module 'stripe' {
* defaults to the `crypto.subtle` object in the global scope.
*/
export const createSubtleCryptoProvider: (
subtleCrypto?: WindowOrWorkerGlobalScope['crypto']['subtle']
/**
* The SubtleCrypto type cannot be specified without pulling in DOM types.
* This corresponds to WindowOrWorkerGlobalScope['crypto']['subtle'] for
* applications which pull in DOM types.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
subtleCrypto?: any
) => CryptoProvider;
}
}
20 changes: 16 additions & 4 deletions types/net/net.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="node" />
/// <reference lib="dom" />

import {IncomingMessage} from 'http';
declare module 'stripe' {
Expand Down Expand Up @@ -76,11 +75,24 @@ declare module 'stripe' {
* passed, will default to the default `fetch` function in the global scope.
*/
export const createFetchHttpClient: (
fetchFn?: WindowOrWorkerGlobalScope['fetch']
/** When specified, interface should match the Web Fetch API function. */
fetchFn?: Function
) => HttpClient<
HttpClientResponse<
ReturnType<WindowOrWorkerGlobalScope['fetch']>,
ReadableStream<Uint8Array>
/**
* The response type cannot be specified without pulling in DOM types.
* This corresponds to ReturnType<WindowOrWorkerGlobalScope['fetch']>
* for applications which pull in DOM types.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
any,
/**
* The stream type cannot be specified without pulling in DOM types.
* This corresponds to ReadableStream<Uint8Array> for applications which
* pull in DOM types.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
any
>
>;
}
Expand Down
4 changes: 2 additions & 2 deletions types/test/typescriptTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ async (): Promise<void> => {

// Test FetchHttpClient request processing.
async (): Promise<void> => {
const client = Stripe.createFetchHttpClient(window.fetch);
const client = Stripe.createFetchHttpClient();

const response = await client.makeRequest(
'api.stripe.com',
Expand All @@ -244,7 +244,7 @@ async (): Promise<void> => {
80000
);

const stream: ReadableStream = response.toStream(() => {
const stream = response.toStream(() => {
return;
});

Expand Down

0 comments on commit ed7e765

Please sign in to comment.