网页
综合
更新时间 2026-10-10 03:18:05
Bun v1.4.3 | Bun Blog
自动蜘蛛
bun.sh
正文约 4922 字
bun check is an incredibly fast TypeScript type checker that passes 100% of TypeScript 7.0.2's conformance test suite.
It's 3x to 6.4x faster than tsc 7.0.2, on a 16-core Apple silicon Mac:
And it uses 2.2x to 4.9x less memory:
It's a port of typescript-go. It reads your tsconfig.json, reports the same errors as tsc, and uses every CPU core. You don't need the typescript package installed.
It only type checks. It doesn't emit JavaScript or .d.ts files, and there's no language server, so your editor keeps using TypeScript.
Type check, then run. If there's a type error, your code doesn't run.
It also works with package.json scripts (bun run --check dev) and with --watch, which checks again before every restart.
Type check the test files and everything they import, then run the tests. If there's a type error, no tests run.
Type check, then bundle. A type error fails the build like any other build error, and nothing is written.
Bun.build takes check: true.
Every commit of Bun runs TypeScript 7.0.2's complete conformance test suite (and we will continue to keep it up-to-date as TypeScript itself updates).
For a project as complex as a TypeScript type checker, conformance tests aren't enough, so we deliberately misconfigured 72 popular open-source repositories and compared bun check's output with tsc's output.
Missing node_modules, mismatched TypeScript versions, no build step. Every error has to match: same file, line, column and error code.
The one mismatch is in vuejs/core. tsc only reports that error when global.ts comes before model.ts in files.
We ran 69 of them again under 11 other sets of compiler options:
Each fuzzer generates every combination of a set of language features, runs tsc and bun check on the result, and diffs the output.
Those run on every commit. These are larger runs we did offline:
162 of the 191 mismatches are in code that refers to itself while it's being declared, like class A { x = { a: null! as { p: A["x"] } } }.
For mutation testing, we broke Effect's source 913 times (swapped arguments, dropped type arguments, deleted overloads) and compared every error.
If there's a difference, that's a bug in Bun. Please open an issue.
Read the bun check docs.
Bun.FetchSession gives a group of requests their own TLS, proxy, and keep-alive settings and their own connection pool. Sessions never share connections with each other or with plain fetch().
NO_PROXY accepts wildcards, CIDR blocks, bare IPv6 addresses, and host:port.
ALL_PROXY is used when HTTP_PROXY / HTTPS_PROXY is unset. proxy: false ignores the proxy environment for one request.
When a proxy refuses CONNECT with a non-2xx status, fetch() rejects with ERR_PROXY_TUNNEL. The error carries the proxy's status and headers. Before, fetch() resolved with the proxy's reply as if it came from the origin.
Run many instances of one app in a single process. Each graph gets fresh module state, its own require.cache, and its own timers and I/O. Parsed code and bytecode are shared between graphs.
With Node's --disallow-code-generation-from-strings flag, eval() and new Function() throw. It covers the whole process, including every Worker. Bun used to accept the flag and ignore it.
=strict is Bun-only. It also blocks every other way a string becomes code: node:vm, import() of a data: URL, new Worker(code, { eval: true }), module._compile(), plugins that return source text, napi_run_script() and the inspector.
A flag embedded in a compiled executable always applies. BUN_OPTIONS can raise the level but not lower it.
A response over 16 KB now goes out in one write per tick instead of up to 16. It applies to node:http and Bun.serve, over HTTP and HTTPS.
Requests per second from a node:http server:
node:http was slower than Node in six of eight large-response benchmarks. Now it's faster in all eight. A Bun.serve direct stream writing 4 × 16 KB is 83% faster. Small responses are unchanged.
Bun's JavaScriptCore engine picks up upstream WebKit performance work and spec fixes.
The JSON.parse numbers are against Bun v1.4.2 on an Apple silicon Mac, with manifests from 331 KB to 8 MB. The for...of and destructuring change helps code that hasn't reached the top JIT tier yet.
Promise.allSettled over thousands of throwing async calls no longer stalls. Attaching handlers to many promises that reject in the same turn took quadratic time. It is linear now.
Attaching .catch() to 160,000 already-rejected promises went from 83 s to 24 ms.
Pass a level option to CompressionStream to trade ratio for speed. Brotli previously always ran at quality 11, which is very slow for large, dynamic responses.
Out-of-range values throw a RangeError. Omitting level keeps each format's current default.
Clients can safely resume a download from Bun.serve. A Range request with If-Range gets the range only if the file hasn't changed. Otherwise it gets the full body.
It works for Bun.file responses and { dir } routes.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。