Hacker News new | ask | show | jobs
by raihansaputra 2226 days ago
On a tangent, but do you have any recommended readings specifically on writing .d.ts? I don't have a lot of experience on typed languages and I'm not too comfortable writing them, but I realize the value of having them on my project.
1 comments

I would suggest starting on the experience with typed languages in general first. Starting with the beginning of the Typescript handbook and trying working with things for instance directly in the Typescript Playground. You are going to want all of the basics when writing a .d.ts, and sometimes you aren't going to need much more than the basics.

The other thing I'd recommend is if your focus really is just specifically on writing .d.ts files, and you aren't expecting to use more Typescript directly yourself: get more familiar with and start regularly using JSDoc comments. Typescript in JS mode already understands and can do a lot with JSDoc comments. As I mentioned, it will sometimes give you a fully formed .d.ts if you ask and you have enough JSDoc comments, you'll even get the advantage of some of its type analysis in your project (not as much as if you were writing Typescript directly, but more than just a linter will do). If you use an editor such as VSCode where the JS experience is already backed by the Typescript language service you'd start to see some things almost Typescript-like light up in your development experience as you add more JSDoc comments (maybe even to help explain why you might want to use more Typescript directly).

https://en.wikipedia.org/wiki/JSDoc

My focus is not specifically on just writing .d.ts, but mostly being capable enough to adapt JS libraries and type them for my needs. Thanks for the recommendation, will muck around with TS for now.