bun-types 1.2.2 → 1.2.3-canary.20250205T140639

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.
package/docs/api/fetch.md CHANGED
@@ -337,7 +337,7 @@ This will print the request and response headers to your terminal:
337
337
  ```sh
338
338
  [fetch] > HTTP/1.1 GET http://example.com/
339
339
  [fetch] > Connection: keep-alive
340
- [fetch] > User-Agent: Bun/bun-v1.2.2
340
+ [fetch] > User-Agent: Bun/1.2.3-canary.20250205T140639
341
341
  [fetch] > Accept: */*
342
342
  [fetch] > Host: example.com
343
343
  [fetch] > Accept-Encoding: gzip, deflate, br
package/docs/api/spawn.md CHANGED
@@ -110,7 +110,7 @@ You can read results from the subprocess via the `stdout` and `stderr` propertie
110
110
  ```ts
111
111
  const proc = Bun.spawn(["bun", "--version"]);
112
112
  const text = await new Response(proc.stdout).text();
113
- console.log(text); // => "bun-v1.2.2"
113
+ console.log(text); // => "1.2.3-canary.20250205T140639"
114
114
  ```
115
115
 
116
116
  Configure the output stream by passing one of the following values to `stdout/stderr`:
@@ -1,6 +1,6 @@
1
- As of Bun v1.1.44, we've added initial support for bundling frontend apps directly in Bun's HTTP server: `Bun.serve()`. Run your frontend and backend in the same app with no extra steps.
1
+ Using `Bun.serve()`'s `static` option, you can run your frontend and backend in the same app with no extra steps.
2
2
 
3
- To get started, import your HTML files and pass them to the `static` option in `Bun.serve()`.
3
+ To get started, import HTML files and pass them to the `static` option in `Bun.serve()`.
4
4
 
5
5
  ```ts
6
6
  import dashboard from "./dashboard.html";
@@ -33,7 +33,7 @@ const server = Bun.serve({
33
33
  },
34
34
  });
35
35
 
36
- console.log(`Listening on ${server.url}`)
36
+ console.log(`Listening on ${server.url}`);
37
37
  ```
38
38
 
39
39
  ```bash
@@ -211,6 +211,7 @@ For example, enable TailwindCSS on your routes by installing and adding the `bun
211
211
  ```sh
212
212
  $ bun add bun-plugin-tailwind
213
213
  ```
214
+
214
215
  ```toml#bunfig.toml
215
216
  [serve.static]
216
217
  plugins = ["bun-plugin-tailwind"]
@@ -1,4 +1,4 @@
1
- As of Bun v1.1.43, Bun's bundler now has first-class support for HTML. Build static sites, landing pages, and web applications with zero configuration. Just point Bun at your HTML file and it handles everything else.
1
+ Bun's bundler has first-class support for HTML. Build static sites, landing pages, and web applications with zero configuration. Just point Bun at your HTML file and it handles everything else.
2
2
 
3
3
  ```html#index.html
4
4
  <!doctype html>
@@ -13,45 +13,228 @@ As of Bun v1.1.43, Bun's bundler now has first-class support for HTML. Build sta
13
13
  </html>
14
14
  ```
15
15
 
16
- One command is all you need (won't be experimental after Bun v1.2):
16
+ To get started, pass HTML files to `bun`.
17
+
18
+ {% bunDevServerTerminal alt="bun ./index.html" path="./index.html" routes="" /%}
19
+
20
+ Bun's development server provides powerful features with zero configuration:
21
+
22
+ - **Automatic Bundling** - Bundles and serves your HTML, JavaScript, and CSS
23
+ - **Multi-Entry Support** - Handles multiple HTML entry points and glob entry points
24
+ - **Modern JavaScript** - TypeScript & JSX support out of the box
25
+ - **Smart Configuration** - Reads `tsconfig.json` for paths, JSX options, experimental decorators, and more
26
+ - **Plugins** - Plugins for TailwindCSS and more
27
+ - **ESM & CommonJS** - Use ESM and CommonJS in your JavaScript, TypeScript, and JSX files
28
+ - **CSS Bundling & Minification** - Bundles CSS from `<link>` tags and `@import` statements
29
+ - **Asset Management**
30
+ - Automatic copying & hashing of images and assets
31
+ - Rewrites asset paths in JavaScript, CSS, and HTML
32
+
33
+ ## Single Page Apps (SPA)
34
+
35
+ When you pass a single .html file to Bun, Bun will use it as a fallback route for all paths. This makes it perfect for single page apps that use client-side routing:
36
+
37
+ {% bunDevServerTerminal alt="bun index.html" path="index.html" routes="" /%}
38
+
39
+ Your React or other SPA will work out of the box — no configuration needed. All routes like `/about`, `/users/123`, etc. will serve the same HTML file, letting your client-side router handle the navigation.
40
+
41
+ ```html#index.html
42
+ <!doctype html>
43
+ <html>
44
+ <head>
45
+ <title>My SPA</title>
46
+ <script src="./app.tsx" type="module"></script>
47
+ </head>
48
+ <body>
49
+ <div id="root"></div>
50
+ </body>
51
+ </html>
52
+ ```
53
+
54
+ ## Multi-page apps (MPA)
55
+
56
+ Some projects have several separate routes or HTML files as entry points. To support multiple entry points, pass them all to `bun`
57
+
58
+ {% bunDevServerTerminal alt="bun ./index.html ./about.html" path="./index.html ./about.html" routes="[{\"path\": \"/\", \"file\": \"./index.html\"}, {\"path\": \"/about\", \"file\": \"./about.html\"}]" /%}
59
+
60
+ This will serve:
61
+
62
+ - `index.html` at `/`
63
+ - `about.html` at `/about`
64
+
65
+ ### Glob patterns
66
+
67
+ To specify multiple files, you can use glob patterns that end in `.html`:
68
+
69
+ {% bunDevServerTerminal alt="bun ./**/*.html" path="./**/*.html" routes="[{\"path\": \"/\", \"file\": \"./index.html\"}, {\"path\": \"/about\", \"file\": \"./about.html\"}]" /%}
70
+
71
+ ### Path normalization
72
+
73
+ The base path is chosen from the longest common prefix among all the files.
74
+
75
+ {% bunDevServerTerminal alt="bun ./index.html ./about/index.html ./about/foo/index.html" path="./index.html ./about/index.html ./about/foo/index.html" routes="[{\"path\": \"/\", \"file\": \"./index.html\"}, {\"path\": \"/about\", \"file\": \"./about/index.html\"}, {\"path\": \"/about/foo\", \"file\": \"./about/foo/index.html\"}]" /%}
76
+
77
+ ## JavaScript, TypeScript, and JSX
78
+
79
+ Bun's transpiler natively implements JavaScript, TypeScript, and JSX support. [Learn more about loaders in Bun](/docs/bundler/loaders).
80
+
81
+ Bun's transpiler is also used at runtime.
82
+
83
+ ### ES Modules & CommonJS
84
+
85
+ You can use ESM and CJS in your JavaScript, TypeScript, and JSX files. Bun will handle the transpilation and bundling automatically.
86
+
87
+ There is no pre-build or separate optimization step. It's all done at the same time.
88
+
89
+ Learn more about [module resolution in Bun](/docs/runtime/modules).
90
+
91
+ ## CSS
92
+
93
+ Bun's CSS parser is also natively implemented (clocking in around 58,000 lines of Zig).
94
+
95
+ It's also a CSS bundler. You can use `@import` in your CSS files to import other CSS files.
96
+
97
+ For example:
98
+
99
+ ```css#styles.css
100
+ @import "./abc.css";
101
+
102
+ .container {
103
+ background-color: blue;
104
+ }
105
+ ```
106
+
107
+ ```css#abc.css
108
+ body {
109
+ background-color: red;
110
+ }
111
+ ```
112
+
113
+ This outputs:
114
+
115
+ ```css#styles.css
116
+ body {
117
+ background-color: red;
118
+ }
119
+
120
+ .container {
121
+ background-color: blue;
122
+ }
123
+ ```
124
+
125
+ ### Referencing local assets in CSS
126
+
127
+ You can reference local assets in your CSS files.
128
+
129
+ ```css#styles.css
130
+ body {
131
+ background-image: url("./logo.png");
132
+ }
133
+ ```
134
+
135
+ This will copy `./logo.png` to the output directory and rewrite the path in the CSS file to include a content hash.
136
+
137
+ ```css#styles.css
138
+ body {
139
+ background-image: url("./logo-[ABC123].png");
140
+ }
141
+ ```
142
+
143
+ ### Importing CSS in JavaScript
144
+
145
+ To associate a CSS file with a JavaScript file, you can import it in your JavaScript file.
146
+
147
+ ```ts#app.ts
148
+ import "./styles.css";
149
+ import "./more-styles.css";
150
+ ```
151
+
152
+ This generates `./app.css` and `./app.js` in the output directory. All CSS files imported from JavaScript will be bundled into a single CSS file per entry point. If you import the same CSS file from multiple JavaScript files, it will only be included once in the output CSS file.
153
+
154
+ ## Plugins
155
+
156
+ The dev server supports plugins.
157
+
158
+ ### Tailwind CSS
159
+
160
+ To use TailwindCSS, install the `bun-plugin-tailwind` plugin:
161
+
162
+ ```bash
163
+ # Or any npm client
164
+ $ bun install --dev bun-plugin-tailwind
165
+ ```
166
+
167
+ Then, add the plugin to your `bunfig.toml`:
168
+
169
+ ```toml
170
+ [serve.static]
171
+ plugins = ["bun-plugin-tailwind"]
172
+ ```
173
+
174
+ Then, reference TailwindCSS in your HTML via `<link>` tag, `@import` in CSS, or `import` in JavaScript.
175
+
176
+ {% codetabs %}
177
+
178
+ ```html#index.html
179
+ <!-- Reference TailwindCSS in your HTML -->
180
+ <link rel="stylesheet" href="tailwindcss" />
181
+ ```
182
+
183
+ ```css#styles.css
184
+ /* Import TailwindCSS in your CSS */
185
+ @import "tailwindcss";
186
+ ```
187
+
188
+ ```ts#app.ts
189
+ /* Import TailwindCSS in your JavaScript */
190
+ import "tailwindcss";
191
+ ```
192
+
193
+ {% /codetabs %}
194
+
195
+ Only one of those are necessary, not all three.
196
+
197
+ ## Keyboard Shortcuts
198
+
199
+ While the server is running:
200
+
201
+ - `o + Enter` - Open in browser
202
+ - `c + Enter` - Clear console
203
+ - `q + Enter` (or Ctrl+C) - Quit server
204
+
205
+ ## Build for Production
206
+
207
+ When you're ready to deploy, use `bun build` to create optimized production bundles:
17
208
 
18
209
  {% codetabs %}
19
210
 
20
211
  ```bash#CLI
21
- $ bun build ./index.html --outdir=dist
212
+ $ bun build ./index.html --minify --outdir=dist
22
213
  ```
23
214
 
24
215
  ```ts#API
25
216
  Bun.build({
26
217
  entrypoints: ["./index.html"],
27
218
  outdir: "./dist",
219
+ minify: {
220
+ whitespace: true,
221
+ identifiers: true,
222
+ syntax: true,
223
+ }
28
224
  });
29
225
  ```
30
226
 
31
227
  {% /codetabs %}
32
228
 
33
- Bun automatically:
229
+ Currently, plugins are only supported through `Bun.build`'s API or through `bunfig.toml` with the frontend dev server - not yet supported in `bun build`'s CLI.
34
230
 
35
- - Bundles, tree-shakes, and optimizes your JavaScript, JSX and TypeScript
36
- - Bundles and optimizes your CSS
37
- - Copies & hashes images and other assets
38
- - Updates all references to local files or packages in your HTML
231
+ ### Watch Mode
39
232
 
40
- ## Zero Config, Maximum Performance
41
-
42
- The HTML bundler is enabled by default after Bun v1.2+. Drop in your existing HTML files and Bun will handle:
43
-
44
- - **TypeScript & JSX** - Write modern JavaScript for browsers without the setup
45
- - **CSS** - Bundle CSS stylesheets directly from `<link rel="stylesheet">` or `@import`
46
- - **Images & Assets** - Automatic copying & hashing & rewriting of assets in JavaScript, CSS, and HTML
47
-
48
- ## Watch mode
49
-
50
- You can run `bun build --watch` to watch for changes and rebuild automatically.
233
+ You can run `bun build --watch` to watch for changes and rebuild automatically. This works nicely for library development.
51
234
 
52
235
  You've never seen a watch mode this fast.
53
236
 
54
- ## Plugin API
237
+ ### Plugin API
55
238
 
56
239
  Need more control? Configure the bundler through the JavaScript API and use Bun's builtin `HTMLRewriter` to preprocess HTML.
57
240
 
@@ -102,3 +285,22 @@ Bun automatically handles all common web assets:
102
285
  - Any `<link>` tag with an `href` attribute pointing to a local file is rewritten to the new path, and hashed
103
286
 
104
287
  All paths are resolved relative to your HTML file, making it easy to organize your project however you want.
288
+
289
+ ## This is a work in progress
290
+
291
+ - No HMR support yet
292
+ - Need more plugins
293
+ - Need more configuration options for things like asset handling
294
+ - Need a way to configure CORS, headers, etc.
295
+
296
+ If you want to submit a PR, most of the [code is here](https://github.com/oven-sh/bun/blob/main/src/js/internal/html.ts). You could even copy paste that file into your project and use it as a starting point.
297
+
298
+ ## How this works
299
+
300
+ This is a small wrapper around Bun's support for HTML imports in JavaScript.
301
+
302
+ ### Adding a backend to your frontend
303
+
304
+ To add a backend to your frontend, you can use the `"static"` option in `Bun.serve`.
305
+
306
+ Learn more in [the full-stack docs](/docs/bundler/fullstack).
@@ -7,7 +7,7 @@ Use `bun publish` to publish a package to the npm registry.
7
7
  $ bun publish
8
8
 
9
9
  ## Output
10
- bun publish vbun-v1.2.2 (ca7428e9)
10
+ bun publish v1.2.3-canary.20250205T140639 (ca7428e9)
11
11
 
12
12
  packed 203B package.json
13
13
  packed 224B README.md
@@ -9,7 +9,7 @@ $ bunx nuxi init my-nuxt-app
9
9
  ✔ Which package manager would you like to use?
10
10
  bun
11
11
  ◐ Installing dependencies...
12
- bun install v$BUN_LATEST_VERSION (16b4bf34)
12
+ bun install v1.2.3-canary.20250205T140639 (16b4bf34)
13
13
  + @nuxt/devtools@0.8.2
14
14
  + nuxt@3.7.0
15
15
  785 packages installed [2.67s]
@@ -16,7 +16,7 @@ This will add the package to `peerDependencies` in `package.json`.
16
16
  ```json-diff
17
17
  {
18
18
  "peerDependencies": {
19
- + "@types/bun": "^$BUN_LATEST_VERSION"
19
+ + "@types/bun": "^1.2.3-canary.20250205T140639"
20
20
  }
21
21
  }
22
22
  ```
@@ -28,7 +28,7 @@ Running `bun install` will install peer dependencies by default, unless marked o
28
28
  ```json-diff
29
29
  {
30
30
  "peerDependencies": {
31
- "@types/bun": "^$BUN_LATEST_VERSION"
31
+ "@types/bun": "^1.2.3-canary.20250205T140639"
32
32
  },
33
33
  "peerDependenciesMeta": {
34
34
  + "@types/bun": {
@@ -97,7 +97,7 @@ $ bun update
97
97
  $ bun update @types/bun --latest
98
98
 
99
99
  # Update a dependency to a specific version
100
- $ bun update @types/bun@$BUN_LATEST_VERSION
100
+ $ bun update @types/bun@1.2.3-canary.20250205T140639
101
101
 
102
102
  # Update all dependencies to the latest versions
103
103
  $ bun update --latest
@@ -21,7 +21,7 @@ Here's what the output of a typical test run looks like. In this case, there are
21
21
 
22
22
  ```sh
23
23
  $ bun test
24
- bun test v$BUN_LATEST_VERSION (9c68abdb)
24
+ bun test v1.2.3-canary.20250205T140639 (9c68abdb)
25
25
 
26
26
  test.test.js:
27
27
  ✓ add [0.87ms]
@@ -47,7 +47,7 @@ To only run certain test files, pass a positional argument to `bun test`. The ru
47
47
 
48
48
  ```sh
49
49
  $ bun test test3
50
- bun test v$BUN_LATEST_VERSION (9c68abdb)
50
+ bun test v1.2.3-canary.20250205T140639 (9c68abdb)
51
51
 
52
52
  test3.test.js:
53
53
  ✓ add [1.40ms]
@@ -85,7 +85,7 @@ Adding `-t add` will only run tests with "add" in the name. This works with test
85
85
 
86
86
  ```sh
87
87
  $ bun test -t add
88
- bun test v$BUN_LATEST_VERSION (9c68abdb)
88
+ bun test v1.2.3-canary.20250205T140639 (9c68abdb)
89
89
 
90
90
  test.test.js:
91
91
  ✓ add [1.79ms]
@@ -18,7 +18,7 @@ The first time this test is executed, Bun will evaluate the value passed into `e
18
18
 
19
19
  ```sh
20
20
  $ bun test test/snap
21
- bun test v$BUN_LATEST_VERSION (9c68abdb)
21
+ bun test v1.2.3-canary.20250205T140639 (9c68abdb)
22
22
 
23
23
  test/snap.test.ts:
24
24
  ✓ snapshot [1.48ms]
@@ -61,7 +61,7 @@ Later, when this test file is executed again, Bun will read the snapshot file an
61
61
 
62
62
  ```sh
63
63
  $ bun test
64
- bun test v$BUN_LATEST_VERSION (9c68abdb)
64
+ bun test v1.2.3-canary.20250205T140639 (9c68abdb)
65
65
 
66
66
  test/snap.test.ts:
67
67
  ✓ snapshot [1.05ms]
@@ -78,7 +78,7 @@ To update snapshots, use the `--update-snapshots` flag.
78
78
 
79
79
  ```sh
80
80
  $ bun test --update-snapshots
81
- bun test v$BUN_LATEST_VERSION (9c68abdb)
81
+ bun test v1.2.3-canary.20250205T140639 (9c68abdb)
82
82
 
83
83
  test/snap.test.ts:
84
84
  ✓ snapshot [0.86ms]
@@ -29,7 +29,7 @@ To regenerate snapshots, use the `--update-snapshots` flag.
29
29
 
30
30
  ```sh
31
31
  $ bun test --update-snapshots
32
- bun test v$BUN_LATEST_VERSION (9c68abdb)
32
+ bun test v1.2.3-canary.20250205T140639 (9c68abdb)
33
33
 
34
34
  test/snap.test.ts:
35
35
  ✓ snapshot [0.86ms]
@@ -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; // => "$BUN_LATEST_VERSION"
8
+ Bun.version; // => "1.2.3-canary.20250205T140639"
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-v$BUN_LATEST_VERSION"
17
+ $ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.3-canary.20250205T140639"
18
18
  ```
19
19
 
20
20
  ```bash#npm
@@ -166,10 +166,10 @@ Since Bun is a single binary, you can install older versions of Bun by re-runnin
166
166
 
167
167
  ### Installing a specific version of Bun on Linux/Mac
168
168
 
169
- 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-v$BUN_LATEST_VERSION`.
169
+ 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.3-canary.20250205T140639`.
170
170
 
171
171
  ```sh
172
- $ curl -fsSL https://bun.sh/install | bash -s "bun-v$BUN_LATEST_VERSION"
172
+ $ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.3-canary.20250205T140639"
173
173
  ```
174
174
 
175
175
  ### Installing a specific version of Bun on Windows
@@ -178,7 +178,7 @@ On Windows, you can install a specific version of Bun by passing the version num
178
178
 
179
179
  ```sh
180
180
  # PowerShell:
181
- $ iex "& {$(irm https://bun.sh/install.ps1)} -Version $BUN_LATEST_VERSION"
181
+ $ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.2.3-canary.20250205T140639"
182
182
  ```
183
183
 
184
184
  ## Downloading Bun binaries directly
@@ -180,6 +180,25 @@ Whether to skip test files when computing coverage statistics. Default `false`.
180
180
  coverageSkipTestFiles = false
181
181
  ```
182
182
 
183
+ ### `test.coverageReporter`
184
+
185
+ By default, coverage reports will be printed to the console. For persistent code coverage reports in CI environments and for other tools use `lcov`.
186
+
187
+ ```toml
188
+ [test]
189
+ coverageReporter = ["text", "lcov"] # default ["text"]
190
+ ```
191
+
192
+ ### `test.coverageDir`
193
+
194
+ Set path where coverage reports will be saved. Please notice, that it works only for persistent `coverageReporter` like `lcov`.
195
+
196
+ ```toml
197
+ [test]
198
+ coverageDir = "path/to/somewhere" # default "coverage"
199
+ ```
200
+
201
+
183
202
  ## Package manager
184
203
 
185
204
  Package management is a complex issue; to support a range of use cases, the behavior of `bun install` can be configured under the `[install]` section.
@@ -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/bun-v1.2.2" -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.3-canary.20250205T140639" -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/bun-v1.2.2
131
+ [fetch] > User-Agent: Bun/1.2.3-canary.20250205T140639
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/bun-v1.2.2
173
+ [fetch] > User-Agent: Bun/1.2.3-canary.20250205T140639
174
174
  [fetch] > Accept: */*
175
175
  [fetch] > Host: example.com
176
176
  [fetch] > Accept-Encoding: gzip, deflate, br
@@ -58,3 +58,82 @@ export const foo = "Hello world!"
58
58
  ```
59
59
 
60
60
  {% /codetabs %}
61
+
62
+ ## Experimental Decorators
63
+
64
+ Bun supports the pre-TypeScript 5.0 experimental decorators syntax.
65
+
66
+ ```ts#hello.ts
67
+ // Simple logging decorator
68
+ function log(target: any, propertyKey: string, descriptor: PropertyDescriptor) {
69
+ const originalMethod = descriptor.value;
70
+
71
+ descriptor.value = function(...args: any[]) {
72
+ console.log(`Calling ${propertyKey} with:`, args);
73
+ return originalMethod.apply(this, args);
74
+ };
75
+ }
76
+
77
+ class Example {
78
+ @log
79
+ greet(name: string) {
80
+ return `Hello ${name}!`;
81
+ }
82
+ }
83
+
84
+ // Usage
85
+ const example = new Example();
86
+ example.greet("world"); // Logs: "Calling greet with: ['world']"
87
+ ```
88
+
89
+ To enable it, add `"experimentalDecorators": true` to your `tsconfig.json`:
90
+
91
+ ```jsonc#tsconfig.json
92
+ {
93
+ "compilerOptions": {
94
+ // ... rest of your config
95
+ "experimentalDecorators": true,
96
+ },
97
+ }
98
+ ```
99
+
100
+ We generally don't recommend using this in new codebases, but plenty of existing codebases have come to rely on it.
101
+
102
+ ### emitDecoratorMetadata
103
+
104
+ Bun supports `emitDecoratorMetadata` in your `tsconfig.json`. This enables emitting design-time type metadata for decorated declarations in source files.
105
+
106
+ ```ts#emit-decorator-metadata.ts
107
+ import "reflect-metadata";
108
+
109
+ class User {
110
+ id: number;
111
+ name: string;
112
+ }
113
+
114
+ function Injectable(target: Function) {
115
+ // Get metadata about constructor parameters
116
+ const params = Reflect.getMetadata("design:paramtypes", target);
117
+ console.log("Dependencies:", params); // [User]
118
+ }
119
+
120
+ @Injectable
121
+ class UserService {
122
+ constructor(private user: User) {}
123
+ }
124
+
125
+ // Creates new UserService instance with dependencies
126
+ const container = new UserService(new User());
127
+ ```
128
+
129
+ To enable it, add `"emitDecoratorMetadata": true` to your `tsconfig.json`:
130
+
131
+ ```jsonc#tsconfig.json
132
+ {
133
+ "compilerOptions": {
134
+ // ... rest of your config
135
+ "experimentalDecorators": true,
136
+ "emitDecoratorMetadata": true,
137
+ },
138
+ }
139
+ ```
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 vbun-v1.2.2
58
+ bun test v1.2.3-canary.20250205T140639
59
59
 
60
60
  dom.test.ts:
61
61
  ✓ dom test [0.82ms]
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.2",
2
+ "version": "1.2.3-canary.20250205T140639",
3
3
  "name": "bun-types",
4
4
  "license": "MIT",
5
5
  "main": "",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "scripts": {
26
26
  "prebuild": "echo $(pwd)",
27
- "copy-docs": "rm -rf docs && cp -rL ../../docs/ ./docs && sed -i 's/\\$BUN_LATEST_VERSION/'\"${BUN_VERSION:-1.0.0}\"'/g' ./docs/**/*.md",
27
+ "copy-docs": "rm -rf docs && cp -rL ../../docs/ ./docs && find ./docs -type f -name '*.md' -exec sed -i 's/\\$BUN_LATEST_VERSION/'\"${BUN_VERSION#bun-v:-1.0.0}\"'/g' {} +",
28
28
  "build": "bun run copy-docs && bun scripts/build.ts && bun run fmt",
29
29
  "test": "tsc",
30
30
  "fmt": "echo $(which biome) && biome format --write ."