-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Missing type definitions in Socket.IO 3.x #3690
Comments
Hmm... according to this, it seems that the types must actually be included in the |
Those types are mandatory for TypeScript users. Related: - #3690 - microsoft/types-publisher#81 (comment)
This solves the issue for missing typings of cors and cookie, but not for component-emitter, used by package socket.io-parser where @types/component-emitter is included in the devDependencies section only. So, even with socket.io 3.0.3 I got a compiler error because of missing @types/component-emitter. I still have to add this to my own devDependencies section, although this is an implementation detail of socket.io that is nowhere documented. |
Fixed by 118cc68 and socketio/socket.io-parser@4efa005. Thanks! |
Just an FYI that including I just got here via a |
@namoscato It seems to be a recommandation from the TypeScript engineers. I'm open to suggestions on this though. |
In general, it can be somehow tricky to handle the problem that on one hand you need typings only during development for code completion in VSCode and for the transpilation step from typescript to javascript but on the other hand it could happen that you have to make typings available even on a production build of your package because otherwise a consumer of your package could run into the mentioned dependency issue above. For me, a clean solution would be to put typings only to devDependencies, always. This would have the side effect that Installation
To be honest, I've never seen packages which document the required typings details like that. Usually, the package developer puts the required typings to the dependencies section so that everything is silently resolved from the package consumer perspective. This way is easy and seems to be the best one but is maybe not the strictly correct one. |
Yeah, I don't really have any strong suggestions. @renkei summarizes the situation well. I could open an issue with Karma to see if they have any thoughts / preferences? This is only tangentially related to that project, but I could see this tripping up many users as part of their v6 upgrade. |
Those types are mandatory for TypeScript users. Related: - socketio#3690 - microsoft/types-publisher#81 (comment)
I've updated my TypeScript project from version 2.x to version 3.0.1 of socket.io. After that I cannot compile my project anymore because no type definitions of cors, cookie and component-emitter are known.
After adding them (@types/cors, @types/cookie, @types/component-emitter) to the devDependencies section of my project it works again, but this is neither documented in the migration guide nor feels it like a good solution to add a 3rdParty component and then to get compiler errors because of missing dependencies.
The text was updated successfully, but these errors were encountered: