aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar josefaidt <josef.aidt@gmail.com> 2022-07-06 12:33:37 -0500
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-07-06 19:22:53 -0700
commitc747a08649351bad4dccbfd388adda93ba529107 (patch)
treebe79dee8f02c1921ea757ee7c7100a525d161271
parentee5144924b68a14293b4628476e438ab6b7b84ed (diff)
downloadbun-c747a08649351bad4dccbfd388adda93ba529107.tar.gz
bun-c747a08649351bad4dccbfd388adda93ba529107.tar.zst
bun-c747a08649351bad4dccbfd388adda93ba529107.zip
docs: add callout for typedefs with TypeScript
-rw-r--r--README.md21
1 files changed, 20 insertions, 1 deletions
diff --git a/README.md b/README.md
index 648419e6f..fd9525021 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,7 @@ If using Linux, kernel version 5.6 or higher is strongly recommended, but the mi
- [Using bun with Create React App](#using-bun-with-create-react-app)
- [Using bun with TypeScript](#using-bun-with-typescript)
- [Transpiling TypeScript with Bun](#transpiling-typescript-with-bun)
+ - [Adding Type Definitions](#adding-type-definitions)
- [Not implemented yet](#not-implemented-yet)
- [Limitations & intended usage](#limitations--intended-usage)
- [Upcoming breaking changes](#upcoming-breaking-changes)
@@ -485,12 +486,30 @@ If no directory is specified and `./public/` doesn’t exist, bun will try `./st
## Using bun with TypeScript
-#### Transpiling TypeScript with Bun
+### Transpiling TypeScript with Bun
TypeScript just works. There’s nothing to configure and nothing extra to install. If you import a `.ts` or `.tsx` file, bun will transpile it into JavaScript. bun also transpiles `node_modules` containing `.ts` or `.tsx` files. This is powered by bun’s TypeScript transpiler, so it’s fast.
bun also reads `tsconfig.json`, including `baseUrl` and `paths`.
+### Adding Type Definitions
+
+To get TypeScript working with the global API, add `bun-types` to your project:
+
+```sh
+bun add -d bun-types
+```
+
+And to the `types` field in your `tsconfig.json`:
+
+```json
+{
+ "compilerOptions": {
+ "types": ["bun-types"]
+ }
+}
+```
+
## Not implemented yet
bun is a project with incredibly large scope, and it’s early days.