Skip to content
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

Remove DOM type references. #1327

Merged
merged 1 commit into from
Jan 11, 2022
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
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