@type/mime has to be published for v3 otherwise types are wrong when you use express types... :(
Express is installing @type/mime for some reason. Then I cannot use this package because I use version 3 and types from version 1.
I cannot install the newest @type/mime because is version 2, so also incorrect types.
The reason this happens is because the @types/mime is hoisted to the root of the node_modules because my root project doesn't need any @type/mime.
=> Found "@types/[email protected]"
info Reasons this module exists
- "@types#express#@types#serve-static" depends on it
- Hoisted from "@types#express#@types#serve-static#@types#mime"
Only solution I can see is to publish a v3 so I can force v1 from express to not be in the root node_modules.
Or maybe publish mime-v3? Is a crazy problem...
For now I have to downgrade to v2 so I can force install types at v2. So they are in sync. Not great :(
Can you provide a recipe for reproducing this problem? Not really sure what issue you're referring to here.
I think @stevemarksd means using mime in typescript. The latest version of @types/mime is v2, but latest version of mime is v3, they don't match, so there will be many errors when developing typscript project.
'Sounds like this is an issue with the @types/mime module, then.
Cc: @sandersn @david-fong @peterblazejewicz (the last 3 people who touched @types/mime)
Can one of you comment on what the appropriate action is here?
Would it make sense to add one of you as a collaborator to this project so you could maintain a types definition file here rather than in the DefinitelyTyped project? I'm happy to do that, but I've been reluctant to "own" responsibility for maintaining the types file here until I have the time to do a full TS port (which is not high on my list of priorities).
Big picture: this is a types-only problem. @types/express depends on @types/serve-static which depends on @types/mime. There are no source packages involved. The required action is an update to @types/serve-static and @types/mime on Definitely Typed.
The immediate problem is that @types/mime is behind at 2.0, but mime is at 3. So @types/mime needs to update.
Except that the actual problem is that @types/serve-static is behind at 1.13, but serve-static is at 1.15. And [email protected] (indirectly) depends on [email protected], so both @types/serve-static and @types/mime are behind their source packages.
@stevemarksd if you want to have your types match your source packages -- and you should, because mime looks to have changed its API significantly between 1 and 3 -- you need to stay with [email protected]. If you want to use [email protected], you need to try to update DT's types for serve-static and mime.
@broofa I recommend keeping types on Definitely Typed unless your package is written in Typescript or strictly checked JSDoc. You can ship your own types separately, but it's much more error-prone, as well as harder to test.
Mime's source is small and already half-jsdocced, so I'd recommend // @ts-check instead of a full TS port anyway. Then you could generate the types from from the .js later if you wanted.
I was wrong, the types haven't changed significantly from mime 2 to 3. I opened https://github.com/DefinitelyTyped/DefinitelyTyped/pull/61509 to update the types.
Closing. mime@4 (published as mime@beta currently) has TS types built in.