3

Bun is currently working on my local machine, but I cannot get it to show all of the typings in my IDE. How do I set this up to work in VS Code and other editors?

sno2
  • 3,274
  • 11
  • 37
  • How is this different from any other thing missing types? – Kevin B Jul 07 '22 at 18:44
  • @KevinB We've answered this question 5+ times in the discord in the past 2 days despite it being in the README. Hopefully people will search here instead of someone needing to take the effort to answer again, – sno2 Jul 07 '22 at 18:52
  • Sound's like a better fit would be to have a FAQ in your discord for you to link people to. – Kevin B Jul 07 '22 at 18:58
  • @KevinB I will ask if we could do that. Although, I believe https://stackoverflow.com/a/71244561/10873797 would be sufficient precedent to keep this open? – sno2 Jul 07 '22 at 19:02
  • fwiw StackOverflow has a mechanism to make it as a "community" wiki. Just mark your answer as a "Community Wiki" one (a little checkbox at bottom left) – KarelG Jul 08 '22 at 13:13

1 Answers1

6

Install the bun-types NPM package:

bun add -D bun-types

Or

npm install -D bun-types

Then, create a tsconfig.json and include the package in your global types:

{
  "compilerOptions": {
    "types": ["bun-types"] // this is necessary
  }
}

You may need to reload your editor for these types to start showing.

From the documentation's TypeScript guide

sno2
  • 3,274
  • 11
  • 37
  • This can be done, but has absolutely no effect for me. Neither do I get hints in VS Code, nor does bun script.ts error if I make mistakes – NoBullsh1t Jul 13 '22 at 14:02
  • @NoBullsh1t Please try joining the Bun discord and hopefully we can better help you there. – sno2 Jul 13 '22 at 14:03
  • After spending hours trying to figure out how to add Bun types to WebStorm... "reload your editor" was what I was missing! – raphaelrk Nov 22 '22 at 19:17
  • I would have expected this to be in the installation or quickstart on https://bun.sh/docs – LiveSource Jul 07 '23 at 03:47
  • Thanks @LiveSource , it is actually on the installation guide and I have updated the information in this answer to follow it along with the link to the section. – sno2 Jul 10 '23 at 00:31