diff options
author | 2022-07-06 12:33:37 -0500 | |
---|---|---|
committer | 2022-07-06 19:22:53 -0700 | |
commit | c747a08649351bad4dccbfd388adda93ba529107 (patch) | |
tree | be79dee8f02c1921ea757ee7c7100a525d161271 | |
parent | ee5144924b68a14293b4628476e438ab6b7b84ed (diff) | |
download | bun-c747a08649351bad4dccbfd388adda93ba529107.tar.gz bun-c747a08649351bad4dccbfd388adda93ba529107.tar.zst bun-c747a08649351bad4dccbfd388adda93ba529107.zip |
docs: add callout for typedefs with TypeScript
-rw-r--r-- | README.md | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -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. |