1

Bun works fine with TypeScript libraries, but I can't get it working with packages that require @types, such as jsonwebtoken.

For example for the following code

import {sign} from "jsonwebtoken";

const token = sign({ name: "name" }, "secret");
console.log(token);

I get error

103 | 
104 |   if (!secretOrPrivateKey && options.algorithm !== 'none') {
105 |     return failure(new Error('secretOrPrivateKey must have a value'));
106 |   }
107 | 
108 |   if (secretOrPrivateKey != null && !(secretOrPrivateKey instanceof KeyObject)) {
                                         ^
TypeError: Right hand side of instanceof is not an object
      at /Users/huakun/Desktop/bunapp/node_modules/jsonwebtoken/sign.js:108:38
      at /Users/huakun/Desktop/bunapp/bunbun.ts:3:14
Huakun Shen
  • 312
  • 2
  • 9

0 Answers0