Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript error for glob types in v4 #83

Closed
vladshcherbin opened this issue Apr 3, 2019 · 5 comments
Closed

Typescript error for glob types in v4 #83

vladshcherbin opened this issue Apr 3, 2019 · 5 comments

Comments

@vladshcherbin
Copy link
Contributor

Hey,

Since v4 has types file inside, there is no glob types which is used inside.

When using v4 typescript gives you an error about this missing types. v3 had external types which installed glob types automatically and didn't give you an error.

@sindresorhus
Copy link
Owner

Is this still a problem with v4.1.0? Ensure you use it like done here: https://github.com/sindresorhus/del/blob/master/index.test-d.ts

@vladshcherbin
Copy link
Contributor Author

vladshcherbin commented Apr 28, 2019

@sindresorhus yes, this also exists in 4.1.0

It happens because glob options are imported here, but glob itself doesn't have types inside, they have to be installed separately using @types/glob.

In v3, types were installed using @types/del which had a @types/glob dependency and installed types for you automatically.

So, I can think of 2 ways of solving this:

  1. add @types/glob to dependencies of this package. This will install needed types automatically, but will install unnecessary types for non-TS devs.
  2. move back to using @types/del. Using it will install glob types automatically and won't pollute non-TS devs dependencies.

I had same issue and conclusion after trying to add types to one of my packages. Chose 2-nd way since it doesn't add unnecessary type packages for non-TS devs. I guess, this is one of the reasons why @types repo is so popular and suggested in ts docs for non-ts package.

Hope this makes sense :)

@sindresorhus
Copy link
Owner

Thanks for elaborating :)

@BendingBender
Copy link
Contributor

Ups, my bad!

@sindresorhus
Copy link
Owner

@BendingBender No worries. I missed it too. tsd should have caught it though... tsdjs/tsd#24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants