Skip to content

Commit 9b1822e

Browse files
committed
types
1 parent 6121c36 commit 9b1822e

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

packages/cli-repl/src/update-notification-manager.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import semver from 'semver';
22
import { promises as fs } from 'fs';
33
import importNodeFetch from '@mongosh/import-node-fetch';
4+
import type {
5+
RequestInfo,
6+
RequestInit,
7+
Response,
8+
} from '@mongosh/import-node-fetch';
49

510
// 'http' is not supported in startup snapshots yet.
6-
const fetch = async (url: any, init?: any): Promise<any> =>
11+
const fetch = async (url: RequestInfo, init?: RequestInit): Promise<Response> =>
712
await (await importNodeFetch()).default(url, init);
813

914
interface MongoshUpdateLocalFileContents {

packages/import-node-fetch/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
22
export type TNodeFetch = typeof import('node-fetch');
3+
export type { Request, Response, RequestInfo, RequestInit } from 'node-fetch';
4+
35
export default async function importNodeFetch(): Promise<TNodeFetch> {
46
// Node-fetch is an ESM module from 3.x
57
// Importing ESM modules to CommonJS is possible with a dynamic import.

packages/snippet-manager/src/snippet-manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import zlib from 'zlib';
1818
import bson from 'bson';
1919
import joi from 'joi';
2020
import importNodeFetch from '@mongosh/import-node-fetch';
21-
import type { TNodeFetch } from '@mongosh/import-node-fetch';
21+
import type { Response } from '@mongosh/import-node-fetch';
2222
const pipeline = promisify(stream.pipeline);
2323
const brotliCompress = promisify(zlib.brotliCompress);
2424
const brotliDecompress = promisify(zlib.brotliDecompress);
@@ -193,7 +193,7 @@ export class SnippetManager implements ShellPlugin {
193193
return this._instanceState.messageBus;
194194
}
195195

196-
async fetch(url: string): Promise<InstanceType<TNodeFetch['Response']>> {
196+
async fetch(url: string): Promise<Response> {
197197
// 'http' is not supported in startup snapshots yet.
198198
const fetch = await importNodeFetch();
199199
return await fetch.default(url);

0 commit comments

Comments
 (0)