Closed Aderinom closed 1 year ago
Your approach worked great on my end, seems like it's the best way to go. Eventually I do plan on re-writing the library in TypeScript which should resolve any of these issues.
One thing I just remembered, with your clean JSDocs you can actually easily autogenerate the types.
See : https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html
I tried it on hyper-express and it seems to be working pretty flawlessly.
I see, yeah I ended up writing types manually for hyper-express and all of my other libraries since I learned TypeScript a bit later than when I initially wrote these packages. I'll be rewriting most of these in pure TypeScript soon with future plans for 100% Node.js / Express.js compatibility for hyper-express.
I had problems getting TS to properly import LiveDirectory.
After checking the types I saw that the ts exports were different to the actual js exports.
e.g.
I am not aware of any compiler flags which would fix this behaviour. However if there are any this is my tsconfig
Since I assume that this is a problem of the different export types used in .js and d.ts i changed them and made this pr.
Changes :
This allows the types to be imported and used as:
I'm not actually 100% sure if using the export = syntax is the right way to go, since I haven't written types for js modules before.
Furhtermore with export=x it's not possible to export other types, even if they were just declarations.