diff options
author | 2023-03-22 15:01:01 -0700 | |
---|---|---|
committer | 2023-03-22 15:01:01 -0700 | |
commit | a5f92224b586289fc72f0abdb68b08eef9f017db (patch) | |
tree | 6092397858776820b431b0dffa635d8bc3b3185e /packages/bun-types/globals.d.ts | |
parent | 2bdaa81b1c2325687c5115b4e97627533cb3646b (diff) | |
download | bun-a5f92224b586289fc72f0abdb68b08eef9f017db.tar.gz bun-a5f92224b586289fc72f0abdb68b08eef9f017db.tar.zst bun-a5f92224b586289fc72f0abdb68b08eef9f017db.zip |
Fix types (#2453)
* WIP
* WIP
* WIP
* WIP
* Improve typechecking in type files
* Fix typechecking
* Update
* Update submodule
* CI for typechecking
* Add ci
* Update commands
* Format after build
* Dont use bunx
* Rename job
* Use nodemodules prettier
* Update workflow
* Use symlink
* Debug
* Debug
* Clean up and rename jobs
Diffstat (limited to 'packages/bun-types/globals.d.ts')
-rw-r--r-- | packages/bun-types/globals.d.ts | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/packages/bun-types/globals.d.ts b/packages/bun-types/globals.d.ts index 82f8cfb8b..6ff2e9970 100644 --- a/packages/bun-types/globals.d.ts +++ b/packages/bun-types/globals.d.ts @@ -417,7 +417,7 @@ interface BlobInterface { formData(): Promise<FormData>; } -type BlobPart = string | Blob | BufferSource | ArrayBuffer; +type BlobPart = string | Blob | BufferSource; interface BlobPropertyBag { /** Set a default "type" */ type?: string; @@ -639,7 +639,7 @@ declare class Blob implements BlobInterface { interface ResponseInit { headers?: HeadersInit; /** @default 200 */ - status?: number; + status?: number | bigint; /** @default "OK" */ statusText?: string; @@ -663,7 +663,13 @@ interface ResponseInit { */ declare class Response implements BlobInterface { constructor( - body?: ReadableStream | BlobPart | BlobPart[] | null | FormData, + body?: + | ReadableStream + | BlobPart + | BlobPart[] + | FormData + | URLSearchParams + | null, options?: ResponseInit, ); @@ -851,9 +857,9 @@ type ReferrerPolicy = | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url"; -type RequestInfo = Request | string | RequestInit; +// type RequestInfo = Request | string | RequestInit; -type BodyInit = ReadableStream | XMLHttpRequestBodyInit; +type BodyInit = ReadableStream | XMLHttpRequestBodyInit | URLSearchParams; type XMLHttpRequestBodyInit = Blob | BufferSource | string | FormData; type ReadableStreamController<T> = ReadableStreamDefaultController<T>; type ReadableStreamDefaultReadResult<T> = @@ -962,7 +968,10 @@ interface FetchRequestInit extends RequestInit { * ``` */ declare class Request implements BlobInterface { - constructor(requestInfo: RequestInfo, requestInit?: RequestInit); + // Request | string | RequestInit; + constructor(requestInfo: string, requestInit?: RequestInit); + constructor(requestInfo: RequestInit & { url: string }); + constructor(requestInfo: Request, requestInit?: RequestInit); /** * Read or write the HTTP headers for this request. @@ -1375,7 +1384,7 @@ declare function clearImmediate(id?: number | Timer): void; */ declare function fetch( - url: string | URL, + url: string | URL | Request, init?: FetchRequestInit, ): Promise<Response>; @@ -1584,7 +1593,7 @@ declare var EventTarget: { }; /** An event which takes place in the DOM. */ -interface Event { +interface Event<T extends EventTarget = EventTarget> { /** * Returns true or false depending on how event was initialized. True * if event goes through its target's ancestors in reverse tree order, @@ -1609,7 +1618,7 @@ interface Event { * Returns the object whose event listener's callback is currently * being invoked. */ - readonly currentTarget: EventTarget | null; + readonly currentTarget: T | null; /** * Returns true if preventDefault() was invoked successfully to * indicate cancelation, and false otherwise. @@ -1909,6 +1918,7 @@ interface URLSearchParams { ): void; /** Returns a string containing a query string suitable for use in a URL. Does not include the question mark. */ toString(): string; + [Symbol.iterator](): IterableIterator<[string, FormDataEntryValue]>; } declare var URLSearchParams: { @@ -1957,7 +1967,7 @@ interface EventMap { } interface AbortSignalEventMap { - abort: Event; + abort: Event<AbortSignal>; } interface AddEventListenerOptions extends EventListenerOptions { @@ -1972,10 +1982,12 @@ interface AbortSignal extends EventTarget { * Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. */ readonly aborted: boolean; + /** * The reason the signal aborted, or undefined if not aborted. */ readonly reason: any; + onabort: ((this: AbortSignal, ev: Event) => any) | null; addEventListener<K extends keyof AbortSignalEventMap>( type: K, @@ -2157,7 +2169,11 @@ interface ReadableStream<R = any> { declare var ReadableStream: { prototype: ReadableStream; new <R = any>( - underlyingSource?: DirectUnderlyingSource<R> | UnderlyingSource<R>, + underlyingSource?: UnderlyingSource<R>, + strategy?: QueuingStrategy<R>, + ): ReadableStream<R>; + new <R = any>( + underlyingSource?: DirectUnderlyingSource<R>, strategy?: QueuingStrategy<R>, ): ReadableStream<R>; }; |