How to genereate type definitions with bun build bundle?

1k Views Asked by At

To create a bundle I run this command in CLI:

bun build ./index.ts --outdir ./build

The tsconfig.json contains this configuration:

{
  "compilerOptions": {
    "declaration": true,
  },
}

A single bundled file .build/index.js will be created. Which is good.

In addition I would like to have all type definitions that are used bundled in a single .d.ts file.

How do I get this file?

1

There are 1 best solutions below

0
Alexey Prokhorov On

Bun can't build type definitions.

So, the only alternative is to run tsc --emitDeclarationOnly for generating type definitions.