diff options
Diffstat (limited to '')
-rw-r--r-- | docs/ecosystem/express.md | 6 | ||||
-rw-r--r-- | docs/ecosystem/react.md | 8 | ||||
-rw-r--r-- | docs/runtime/nodejs-apis.md (renamed from docs/ecosystem/nodejs.md) | 3 | ||||
-rw-r--r-- | docs/runtime/typescript.md (renamed from docs/ecosystem/typescript.md) | 23 |
4 files changed, 20 insertions, 20 deletions
diff --git a/docs/ecosystem/express.md b/docs/ecosystem/express.md index 856d2aafc..bbca048ab 100644 --- a/docs/ecosystem/express.md +++ b/docs/ecosystem/express.md @@ -1,7 +1,7 @@ -Projects that use Express and other major Node.js HTTP libraries should work out of the box. +Projects that use Express and other major Node.js HTTP libraries should work out of the box. {% callout %} -If you run into bugs, [please file an issue](https://bun.sh/issues) *in Bun's repo*, not the library. It is Bun's responsibility to address Node.js compatibility issues. +If you run into bugs, [please file an issue](https://bun.sh/issues) _in Bun's repo_, not the library. It is Bun's responsibility to address Node.js compatibility issues. {% /callout %} ```ts @@ -22,7 +22,7 @@ app.listen(port, () => { Bun implements the [`node:http`](https://nodejs.org/api/http.html) and [`node:https`](https://nodejs.org/api/https.html) modules that these libraries rely on. These modules can also be used directly, though [`Bun.serve`](/docs/api/http) is recommended for most use cases. {% callout %} -**Note** — Refer to the [Runtime > Node.js APIs](/docs/ecosystem/nodejs#node_http) page for more detailed compatibility information. +**Note** — Refer to the [Runtime > Node.js APIs](/docs/runtime/nodejs-apis#node_http) page for more detailed compatibility information. {% /callout %} ```ts diff --git a/docs/ecosystem/react.md b/docs/ecosystem/react.md index 197edb30f..84f1a4536 100644 --- a/docs/ecosystem/react.md +++ b/docs/ecosystem/react.md @@ -19,23 +19,23 @@ $ bun run react.tsx <Component message="Hello world!" /> ``` -### Prop punning +### Prop punning -The Bun runtime also supports "prop punning for JSX. This is a shorthand syntax useful for assigning a variable to a prop with the same name. +The Bun runtime also supports "prop punning" for JSX. This is a shorthand syntax useful for assigning a variable to a prop with the same name. ```tsx function Div(props: {className: string;}) { const {className} = props; - + // without punning return <div className={className} />; // with punning return <div {className} />; - } ``` ### Server-side rendering + To server-side render (SSR) React in an [HTTP server](/docs/api/http): ```tsx#ssr.tsx diff --git a/docs/ecosystem/nodejs.md b/docs/runtime/nodejs-apis.md index c821d3d9a..cbb264486 100644 --- a/docs/ecosystem/nodejs.md +++ b/docs/runtime/nodejs-apis.md @@ -183,6 +183,7 @@ This page is updated regularly to reflect compatibility status of the latest ver - {% anchor id="node_string_decoder" %} [`node:string_decoder`](https://nodejs.org/api/string_decoder.html) {% /anchor %} - 🟢 +- Fully implemented. --- @@ -230,7 +231,7 @@ This page is updated regularly to reflect compatibility status of the latest ver - {% anchor id="node_v8" %} [`node:v8`](https://nodejs.org/api/v8.html) {% /anchor %} - 🔴 -- Not implemented or planned. For profiling, use `bun:jsc` instead. +- Not implemented or planned. For profiling, use [`bun:jsc`](/docs/project/benchmarking#bunjsc) instead. --- diff --git a/docs/ecosystem/typescript.md b/docs/runtime/typescript.md index dfedfb850..6ac1d991a 100644 --- a/docs/ecosystem/typescript.md +++ b/docs/runtime/typescript.md @@ -1,12 +1,14 @@ -Bun can directly execute `.ts` and `.tsx` files just like vanilla JavaScript, with no extra configuration. If you import a `.ts` or `.tsx` file (or an `npm` module that exports these files), Bun internally transpiles it into JavaScript then executes the file. +Bun can directly execute `.ts` and `.tsx` files with no extra configuration. If you import a `.ts` or `.tsx` file, Bun internally transpiles it into JavaScript then executes the file. {% callout %} **Note** — Similar to other build tools, Bun does not typecheck the files. Use [`tsc --noEmit`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) (the official TypeScript CLI) if you're looking to catch static type errors. {% /callout %} -## Type definitions +## Configuring `tsconfig.json` -To install TypeScript definitions for Bun's built-in APIs, first install `bun-types`. +When using TypeScript and Bun together, it's important to properly configure your `tsconfig.json`. + +First, install the TypeScript definitions for Bun's built-in APIs: ```sh $ bun add -d bun-types # dev dependency @@ -22,13 +24,9 @@ Then include `"bun-types"` in the `compilerOptions.types` in your `tsconfig.json } ``` -## Compiler options - -Bun's runtime implements [modern ECMAScript features](https://github.com/sudheerj/ECMAScript-features), like bigint literals, nullish coalescing, dynamic imports, `import.meta`, `globalThis`, ES modules, top-level await, and more. To use these features without seeing TypeScript errors in your IDE, your `tsconfig.json` needs to be properly configured. +This is the most important step, as it allows you to use Bun's built in APIs without seeing TypeScript errors in your IDE. -These are the recommended `compilerOptions` for a Bun project. - -> The config below sets `moduleResolution` to `bundler` which requires TypeScript option is set to `"bundler"` to support [path mapping](#path-mapping). +Bun implements a range of [modern ECMAScript features](https://github.com/sudheerj/ECMAScript-features), like bigint literals, nullish coalescing, dynamic imports, `import.meta`, `globalThis`, ES modules, top-level await, and more. To use these features without seeing TypeScript errors in your IDE, set the following `compilerOptions`: ```jsonc { @@ -37,10 +35,11 @@ These are the recommended `compilerOptions` for a Bun project. "lib": ["esnext"], "module": "esnext", "target": "esnext", - - // requires typescript 5.x+ - // use "nodenext" for earlier versions + + // typescript 5.x+ "moduleResolution": "bundler", + // typescript 4.x or earlier + "moduleResolution": "nodenext", // support JSX, CommonJS "jsx": "react-jsx", // support JSX (value doesn't matter) |