broofa / mime

Mime types for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong @types/mime package gets installed with latest version of 'mime' package

vijay-singh-16 opened this issue · comments

Hi! First of all thank you for this really nice package.
Just want put a small issue to your knowledge.

The default installation of this package puts old type definitions (version 1.3.2) in 'node_modules@types\mime' folder which makes typescript unhappy. Though this gets fixed by installation of latest version of '@types/mime' package.
But overall this is not a good experience. I don't think this is done knowingly but is left by mistake.

Please, if possible, correct the type package which gets installed when the latest version of this package is installed.

I don't maintain the @mime/types module. 'Not really sure what to do about this issue. Let me know if there's anything I can do to help. (I would be open to a PR that adds the appropriate *.d.ts file here, however, to help avoid the hassle of having to install @mime/types separately.)

I have found the reason for this problem.
I am using '@vue/cli-service' package which has the following dependency path up to '@types/mime':

@vue/cli-service >> @types/webpack-dev-server >> @types/serve-static >> @types/mime

In "@types/serve-static" package the dependencies are specified as follows:

"dependencies": {
"@types/mime": "^1",
"@types/node": "*"
}

So, if by any means your app has direct or indirect dependency on "@types/serve-static" package, the old version of '@types/mime', with version 1.3.2, will get installed.

Also note that the '@types/mime' package doesn't get installed by installing 'mime' package, which I thought was getting auto installed with 'mime' package, I am sorry for that.

So the problem occurs when the new 'mime' package gets installed and the types come from the old '@types/mime' package. But when new '@types/mime' package is installed it replaces the old '@types/mime' package and the problem gets resolved.

Hope this post will save some time for our busy devs facing this issue.

@broofa I don't know exactly how this can be fixed. May be the maintainers of '@types/serve-static' package can upgrade the dependency on '@types/mime' to fix this.