Reputation: 1888
I'm transforming a small express api to use TypeScript, but some of the packages don't have a @types/
so when I import them I get a TS2307
error.
Is there something I can do to resolve the error? Or maybe type it myself, depending on the package complexity. One example is express-bearer-token
(found here)
Upvotes: 9
Views: 10062
Reputation: 3996
Create global.d.ts in the root directory
Add the below line
declare module "daisyui";
Note: Stop the server and re-start if you the server is running already.
Upvotes: 3
Reputation: 10659
The quick way is to create a globals.d.ts
file and add the line:
declare module "express-bearer-token";
This will treat express-bearer-token
as a JS module without typings. More information about that here.
From there, you can start adding more typings yourself if you wish. You can find some information about writing your own definitions here.
Upvotes: 23