distubejs / ytdl-core

YouTube video downloader in javascript.
MIT License
213 stars 43 forks source link

TypeScript compilation fails #13

Closed dani-mp closed 1 year ago

dani-mp commented 1 year ago

Describe the bug

tsc --project . fails because of the types of a third party lib.

node_modules/@distube/ytdl-core/typings/index.d.ts:3:43 - error TS7016: Could not find a declaration file for module 'tough-cookie'. '<project-root>/node_modules/tough-cookie/lib/cookie.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/tough-cookie` if it exists or add a new declaration (.d.ts) file containing `declare module 'tough-cookie';`

3   import { Cookie as CK, CookieJar } from 'tough-cookie';

Environment

skick1234 commented 1 year ago

As the error said, you have to use npm i --save-dev @types/tough-cookie (or yarn add -D, ... depends on your package manager) to install its declaration files.

This is not a production dependency so it won't be installed by default.

dani-mp commented 1 year ago

@skick1234 right, but as I'm not using that library myself, it doesn't make sense to include it in my list of dependencies. The library could do it instead. If this is not possible, maybe adding a note about it in https://github.com/distubejs/ytdl-core#installation would be good enough. But I think it's the library that should add this dependency.

skick1234 commented 1 year ago

I get where you're coming from, but in the TypeScript world, it's kinda like a standard thing to have those type declarations for third-party stuff. It makes your codebase cleaner and helps TypeScript do its magic.

Still, I hear you! I'll think about making 'ytdl-core' handle this dependency or, at the very least, slap a note in the docs about it. Thanks for raising it, and if you've got more thoughts or run into any other quirks, just give me a shout. I'm here to make things easier for ya!