tncrazvan / sveltekit-sse

Server Sent Events with SvelteKit
https://www.npmjs.com/package/sveltekit-sse
MIT License
204 stars 7 forks source link

chore(types): remove `timeout` from fetch options #37

Closed oscarhermoso closed 3 weeks ago

oscarhermoso commented 3 weeks ago

Small change to remove the "timeout" property fromOptions (derived from Pick<FetchEventSourceInit, ...>)

Browser fetch doesn't actually have this option, so it's type is "unknown", resulting in a TS error:

https://fetch.spec.whatwg.org/#requestinit

Resolves TS error:

Property 'timeout' is missing in type '{ fetch: { (input: RequestInfo | URL, init?: RequestInit | undefined): Promise; (input: string | Request | URL, init?: RequestInit | undefined): Promise; }; openWhenHidden: true; body: string; }' but required in type 'Pick<FetchEventSourceInit, "timeout" | "headers" | "body" | "cache" | "credentials" | "fetch" | "integrity" | "keepalive" | "method" | "mode" | "openWhenHidden" | "redirect" | "referrer" | "referrerPolicy" | "window">'.ts(2741)

tncrazvan commented 3 weeks ago

Hello @oscarhermoso , first of all thank you for the PR! I think this change makes sense.

I believe this issue comes from Bun, they used to declare their own global types and overwrite the node ones. https://github.com/oven-sh/bun/blob/1bf28e0d77a8b2261befbdb708cefd03e0126960/packages/bun-types/globals.d.ts#L1318

tncrazvan commented 3 weeks ago

Version 0.9.3 is out!