bun-types 1.2.6 → 1.2.8-canary.20250327T140605

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ name: Get the current Bun version
5
5
  Get the current version of Bun in a semver format.
6
6
 
7
7
  ```ts#index.ts
8
- Bun.version; // => "1.2.6"
8
+ Bun.version; // => "1.2.8-canary.20250327T140605"
9
9
  ```
10
10
 
11
11
  ---
@@ -14,7 +14,7 @@ Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1. Us
14
14
  ```bash#macOS/Linux_(curl)
15
15
  $ curl -fsSL https://bun.sh/install | bash # for macOS, Linux, and WSL
16
16
  # to install a specific version
17
- $ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.6"
17
+ $ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.8-canary.20250327T140605"
18
18
  ```
19
19
 
20
20
  ```bash#npm
@@ -189,10 +189,10 @@ Since Bun is a single binary, you can install older versions of Bun by re-runnin
189
189
 
190
190
  ### Installing a specific version of Bun on Linux/Mac
191
191
 
192
- To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.2.0` or `bun-v1.2.6`.
192
+ To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.2.0` or `bun-v1.2.8-canary.20250327T140605`.
193
193
 
194
194
  ```sh
195
- $ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.6"
195
+ $ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.8-canary.20250327T140605"
196
196
  ```
197
197
 
198
198
  ### Installing a specific version of Bun on Windows
@@ -201,7 +201,7 @@ On Windows, you can install a specific version of Bun by passing the version num
201
201
 
202
202
  ```sh
203
203
  # PowerShell:
204
- $ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.2.6"
204
+ $ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.2.8-canary.20250327T140605"
205
205
  ```
206
206
 
207
207
  ## Downloading Bun binaries directly
@@ -124,11 +124,11 @@ await fetch("https://example.com", {
124
124
  This prints the `fetch` request as a single-line `curl` command to let you copy-paste into your terminal to replicate the request.
125
125
 
126
126
  ```sh
127
- [fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/1.2.6" -H "Accept: */*" -H "Host: example.com" -H "Accept-Encoding: gzip, deflate, br" --compressed -H "Content-Length: 13" --data-raw "{\"foo\":\"bar\"}"
127
+ [fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/1.2.8-canary.20250327T140605" -H "Accept: */*" -H "Host: example.com" -H "Accept-Encoding: gzip, deflate, br" --compressed -H "Content-Length: 13" --data-raw "{\"foo\":\"bar\"}"
128
128
  [fetch] > HTTP/1.1 POST https://example.com/
129
129
  [fetch] > content-type: application/json
130
130
  [fetch] > Connection: keep-alive
131
- [fetch] > User-Agent: Bun/1.2.6
131
+ [fetch] > User-Agent: Bun/1.2.8-canary.20250327T140605
132
132
  [fetch] > Accept: */*
133
133
  [fetch] > Host: example.com
134
134
  [fetch] > Accept-Encoding: gzip, deflate, br
@@ -170,7 +170,7 @@ This prints the following to the console:
170
170
  [fetch] > HTTP/1.1 POST https://example.com/
171
171
  [fetch] > content-type: application/json
172
172
  [fetch] > Connection: keep-alive
173
- [fetch] > User-Agent: Bun/1.2.6
173
+ [fetch] > User-Agent: Bun/1.2.8-canary.20250327T140605
174
174
  [fetch] > Accept: */*
175
175
  [fetch] > Host: example.com
176
176
  [fetch] > Accept-Encoding: gzip, deflate, br
@@ -104,7 +104,7 @@ This page is updated regularly to reflect compatibility status of the latest ver
104
104
 
105
105
  ### [`node:crypto`](https://nodejs.org/api/crypto.html)
106
106
 
107
- 🟡 Missing `ECDH` `checkPrime` `checkPrimeSync` `generatePrime` `generatePrimeSync` `hkdf` `hkdfSync` `secureHeapUsed` `setEngine` `setFips`
107
+ 🟡 Missing `secureHeapUsed` `setEngine` `setFips`
108
108
 
109
109
  Some methods are not optimized yet.
110
110
 
package/docs/test/dom.md CHANGED
@@ -55,7 +55,7 @@ Let's run this test with `bun test`:
55
55
 
56
56
  ```bash
57
57
  $ bun test
58
- bun test v1.2.6
58
+ bun test v1.2.8-canary.20250327T140605
59
59
 
60
60
  dom.test.ts:
61
61
  ✓ dom test [0.82ms]
@@ -17,7 +17,7 @@ Bun supports things like top-level await, JSX, and extensioned `.ts` imports, wh
17
17
  ```jsonc
18
18
  {
19
19
  "compilerOptions": {
20
- // Enable latest features
20
+ // Environment setup & latest features
21
21
  "lib": ["ESNext"],
22
22
  "target": "ESNext",
23
23
  "module": "ESNext",
@@ -35,12 +35,13 @@ Bun supports things like top-level await, JSX, and extensioned `.ts` imports, wh
35
35
  "strict": true,
36
36
  "skipLibCheck": true,
37
37
  "noFallthroughCasesInSwitch": true,
38
+ "noUncheckedIndexedAccess": true,
38
39
 
39
- // Some stricter flags
40
- "noUnusedLocals": true,
41
- "noUnusedParameters": true,
42
- "noPropertyAccessFromIndexSignature": true
43
- }
40
+ // Some stricter flags (disabled by default)
41
+ "noUnusedLocals": false,
42
+ "noUnusedParameters": false,
43
+ "noPropertyAccessFromIndexSignature": false,
44
+ },
44
45
  }
45
46
  ```
46
47
 
@@ -0,0 +1,31 @@
1
+ declare module "*.txt" {
2
+ var text: string;
3
+ export = text;
4
+ }
5
+
6
+ declare module "*.toml" {
7
+ var contents: any;
8
+ export = contents;
9
+ }
10
+
11
+ declare module "*.jsonc" {
12
+ var contents: any;
13
+ export = contents;
14
+ }
15
+
16
+ declare module "*/bun.lock" {
17
+ var contents: import("bun").BunLockFile;
18
+ export = contents;
19
+ }
20
+
21
+ declare module "*.html" {
22
+ // In Bun v1.2, this might change to Bun.HTMLBundle
23
+ var contents: any;
24
+ export = contents;
25
+ }
26
+
27
+ declare module "*.svg" {
28
+ // Bun 1.2.3 added support for frontend dev server
29
+ var content: `${string}.svg`;
30
+ export = content;
31
+ }
package/fetch.d.ts CHANGED
@@ -1,169 +1,72 @@
1
- interface Headers {
2
- /**
3
- * Convert {@link Headers} to a plain JavaScript object.
4
- *
5
- * About 10x faster than `Object.fromEntries(headers.entries())`
6
- *
7
- * Called when you run `JSON.stringify(headers)`
8
- *
9
- * Does not preserve insertion order. Well-known header names are lowercased. Other header names are left as-is.
10
- */
11
- toJSON(): Record<string, string>;
12
- /**
13
- * Get the total number of headers
14
- */
15
- readonly count: number;
16
- /**
17
- * Get all headers matching the name
18
- *
19
- * Only supports `"Set-Cookie"`. All other headers are empty arrays.
20
- *
21
- * @param name - The header name to get
22
- *
23
- * @returns An array of header values
24
- *
25
- * @example
26
- * ```ts
27
- * const headers = new Headers();
28
- * headers.append("Set-Cookie", "foo=bar");
29
- * headers.append("Set-Cookie", "baz=qux");
30
- * headers.getAll("Set-Cookie"); // ["foo=bar", "baz=qux"]
31
- * ```
32
- */
33
- getAll(name: "set-cookie" | "Set-Cookie"): string[];
34
- }
35
-
36
- var Headers: {
37
- prototype: Headers;
38
- new (init?: Bun.HeadersInit): Headers;
39
- };
40
-
41
- interface Request {
42
- headers: Headers;
43
- }
44
-
45
- var Request: {
46
- prototype: Request;
47
- new (requestInfo: string, requestInit?: RequestInit): Request;
48
- new (requestInfo: RequestInit & { url: string }): Request;
49
- new (requestInfo: Request, requestInit?: RequestInit): Request;
50
- };
1
+ /*
51
2
 
52
- var Response: {
53
- new (
54
- body?: Bun.BodyInit | null | undefined,
55
- init?: Bun.ResponseInit | undefined,
56
- ): Response;
57
- /**
58
- * Create a new {@link Response} with a JSON body
59
- *
60
- * @param body - The body of the response
61
- * @param options - options to pass to the response
62
- *
63
- * @example
64
- *
65
- * ```ts
66
- * const response = Response.json({hi: "there"});
67
- * console.assert(
68
- * await response.text(),
69
- * `{"hi":"there"}`
70
- * );
71
- * ```
72
- * -------
73
- *
74
- * This is syntactic sugar for:
75
- * ```js
76
- * new Response(JSON.stringify(body), {headers: { "Content-Type": "application/json" }})
77
- * ```
78
- * @link https://github.com/whatwg/fetch/issues/1389
79
- */
80
- json(body?: any, options?: Bun.ResponseInit | number): Response;
3
+ This file does not declare any global types.
81
4
 
82
- /**
83
- * Create a new {@link Response} that redirects to url
84
- *
85
- * @param url - the URL to redirect to
86
- * @param status - the HTTP status code to use for the redirect
87
- */
88
- // tslint:disable-next-line:unified-signatures
89
- redirect(url: string, status?: number): Response;
5
+ That should only happen in [./globals.d.ts](./globals.d.ts)
6
+ so that our documentation generator can pick it up, as it
7
+ expects all globals to be declared in one file.
90
8
 
91
- /**
92
- * Create a new {@link Response} that redirects to url
93
- *
94
- * @param url - the URL to redirect to
95
- * @param options - options to pass to the response
96
- */
97
- // tslint:disable-next-line:unified-signatures
98
- redirect(url: string, options?: Bun.ResponseInit): Response;
9
+ */
99
10
 
100
- /**
101
- * Create a new {@link Response} that has a network error
102
- */
103
- error(): Response;
104
- };
11
+ declare module "bun" {
12
+ type HeadersInit = string[][] | Record<string, string | ReadonlyArray<string>> | Headers;
13
+ type BodyInit = ReadableStream | Bun.XMLHttpRequestBodyInit | URLSearchParams | AsyncGenerator<Uint8Array>;
105
14
 
106
- type _BunTLSOptions = import("bun").TLSOptions;
107
- interface BunFetchRequestInitTLS extends _BunTLSOptions {
108
- /**
109
- * Custom function to check the server identity
110
- * @param hostname - The hostname of the server
111
- * @param cert - The certificate of the server
112
- * @returns An error if the server is unauthorized, otherwise undefined
113
- */
114
- checkServerIdentity?: NonNullable<
115
- import("node:tls").ConnectionOptions["checkServerIdentity"]
116
- >;
117
- }
15
+ namespace __internal {
16
+ type LibOrFallbackHeaders = LibDomIsLoaded extends true ? {} : import("undici-types").Headers;
17
+ type LibOrFallbackRequest = LibDomIsLoaded extends true ? {} : import("undici-types").Request;
18
+ type LibOrFallbackResponse = LibDomIsLoaded extends true ? {} : import("undici-types").Response;
19
+ type LibOrFallbackResponseInit = LibDomIsLoaded extends true ? {} : import("undici-types").ResponseInit;
20
+ type LibOrFallbackRequestInit = LibDomIsLoaded extends true
21
+ ? {}
22
+ : Omit<import("undici-types").RequestInit, "body" | "headers"> & {
23
+ body?: Bun.BodyInit | null | undefined;
24
+ headers?: Bun.HeadersInit;
25
+ };
118
26
 
119
- /**
120
- * BunFetchRequestInit represents additional options that Bun supports in `fetch()` only.
121
- *
122
- * Bun extends the `fetch` API with some additional options, except
123
- * this interface is not quite a `RequestInit`, because they won't work
124
- * if passed to `new Request()`. This is why it's a separate type.
125
- */
126
- interface BunFetchRequestInit extends RequestInit {
127
- /**
128
- * Override the default TLS options
129
- */
130
- tls?: BunFetchRequestInitTLS;
131
- }
27
+ interface BunHeadersOverride extends LibOrFallbackHeaders {
28
+ /**
29
+ * Convert {@link Headers} to a plain JavaScript object.
30
+ *
31
+ * About 10x faster than `Object.fromEntries(headers.entries())`
32
+ *
33
+ * Called when you run `JSON.stringify(headers)`
34
+ *
35
+ * Does not preserve insertion order. Well-known header names are lowercased. Other header names are left as-is.
36
+ */
37
+ toJSON(): Record<string, string>;
132
38
 
133
- var fetch: {
134
- /**
135
- * Send a HTTP(s) request
136
- *
137
- * @param request Request object
138
- * @param init A structured value that contains settings for the fetch() request.
139
- *
140
- * @returns A promise that resolves to {@link Response} object.
141
- */
142
- (request: Request, init?: BunFetchRequestInit): Promise<Response>;
39
+ /**
40
+ * Get the total number of headers
41
+ */
42
+ readonly count: number;
143
43
 
144
- /**
145
- * Send a HTTP(s) request
146
- *
147
- * @param url URL string
148
- * @param init A structured value that contains settings for the fetch() request.
149
- *
150
- * @returns A promise that resolves to {@link Response} object.
151
- */
152
- (url: string | URL | Request, init?: BunFetchRequestInit): Promise<Response>;
44
+ /**
45
+ * Get all headers matching the name
46
+ *
47
+ * Only supports `"Set-Cookie"`. All other headers are empty arrays.
48
+ *
49
+ * @param name - The header name to get
50
+ *
51
+ * @returns An array of header values
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * const headers = new Headers();
56
+ * headers.append("Set-Cookie", "foo=bar");
57
+ * headers.append("Set-Cookie", "baz=qux");
58
+ * headers.getAll("Set-Cookie"); // ["foo=bar", "baz=qux"]
59
+ * ```
60
+ */
61
+ getAll(name: "set-cookie" | "Set-Cookie"): string[];
62
+ }
153
63
 
154
- (
155
- input: string | URL | globalThis.Request,
156
- init?: BunFetchRequestInit,
157
- ): Promise<Response>;
64
+ interface BunRequestOverride extends LibOrFallbackRequest {
65
+ headers: BunHeadersOverride;
66
+ }
158
67
 
159
- /**
160
- * Start the DNS resolution, TCP connection, and TLS handshake for a request
161
- * before the request is actually sent.
162
- *
163
- * This can reduce the latency of a request when you know there's some
164
- * long-running task that will delay the request starting.
165
- *
166
- * This is a bun-specific API and is not part of the Fetch API specification.
167
- */
168
- preconnect(url: string | URL): void;
169
- };
68
+ interface BunResponseOverride extends LibOrFallbackResponse {
69
+ headers: BunHeadersOverride;
70
+ }
71
+ }
72
+ }