feat(goja): implement fetch API and fix websocket concurrency

fix(goja): handle ignored error returns in fetch API

docs: add fetch API type definitions to global-types
This commit is contained in:
dragon
2026-01-29 14:01:16 +08:00
parent a60f123bee
commit c630b7e34f
5 changed files with 164 additions and 0 deletions

View File

@@ -161,6 +161,24 @@ declare global {
// @ts-ignore
const console: Console;
// Fetch API 相关类型
interface FetchResponse {
ok: boolean;
status: number;
statusText: string;
headers: Record<string, string>;
text(): Promise<string>;
json<T = any>(): Promise<T>;
}
interface FetchOptions {
method?: string;
headers?: Record<string, string>;
body?: string;
}
function fetch(url: string, options?: FetchOptions): Promise<FetchResponse>;
}
export {};