node-ytdl-core
node-ytdl-core copied to clipboard
[proposal] Migrate to TypeScript
Why?
I don't know how about other IDEs but it seems that VSCode would show JSDoc hints only if they are declared in TypeScript part (in .d.ts
). For example VSCode wouldn't show description for getVideoID
.
I don't think it's a big inconvenience for everyone but again we could provide a better developer experience with this change 🚀 .
AFAIK TypeScript doesn't have disadvantages and I think it would be much easier to keep everything in one place.
For instance
export const getVideoID = (str: string): string => {
// ...
@fent Do you have any thoughts on this? and do you mind if I show you how it could be done?
P.S. Sorry if I misspelled anything
yep, i was already planning this, but hadn't recorded it in an issue yet. just need to find the time to 😅
and do you mind if I show you how it could be done?
i've been slowly converting my other active projects into typescript, some examples are miniget and m3u8stream which ytdl uses. my process consists of the following changes
https://github.com/fent/node-miniget/commit/30e0b97ce4c2d5cee410ebe3b85fc48bceb5c03d
is my method similar to what you had in mind?
Yes, you're right. As I can see why section wasn't necessary here 😅 . If you want I could help you with that, because I've got a lot of free time :)
that would be great!
@fent can I know why do you export them here? https://github.com/fent/node-ytdl-core/blob/e14c9da91fbb383e8cc84fc6dab2febd13ee277d/lib/info.js#L478-L481
those are all exported by ytdl so that they can be used by users. they're also exported in index.js
, but i also want to support someone only importing info.js
Nah, index.js
exports them from url-libs.js
directly: https://github.com/fent/node-ytdl-core/blob/e14c9da91fbb383e8cc84fc6dab2febd13ee277d/lib/index.js#L30 why user can't import them from entry point directly? 0_o
Ah, just never mind, it doesn't really matter. I think i could remove this :)
why user can't import them from entry point directly? 0_o
i wanted to make both available. in another repo i've compiled ytdl-core from info.js
, without index.js
, and wanted the extra validation functions.