mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:49:35 +00:00
Tests: fix fetch mock typings for type-aware checks
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
export const withFetchPreconnect = <T extends (...args: unknown[]) => unknown>(
|
||||
type FetchWithPreconnect = {
|
||||
preconnect: (url: string, init?: { credentials?: RequestCredentials }) => void;
|
||||
};
|
||||
|
||||
export function withFetchPreconnect<T extends typeof fetch>(fn: T): T & FetchWithPreconnect;
|
||||
export function withFetchPreconnect<T extends object>(
|
||||
fn: T,
|
||||
): typeof fetch =>
|
||||
Object.assign(fn, {
|
||||
preconnect: () => {},
|
||||
}) as unknown as typeof fetch;
|
||||
): T & FetchWithPreconnect & typeof fetch;
|
||||
export function withFetchPreconnect(fn: object) {
|
||||
return Object.assign(fn, {
|
||||
preconnect: (_url: string, _init?: { credentials?: RequestCredentials }) => {},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user