Socket.io: Missing type definitions in Socket.IO 3.x

Created on 10 Nov 2020  ·  4Comments  ·  Source: socketio/socket.io

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.

Most helpful comment

Hmm... according to this, it seems that the types must actually be included in the dependencies section, and not in the devDependencies. Let's do this!

All 4 comments

Hmm... according to this, it seems that the types must actually be included in the dependencies section, and not in the devDependencies. Let's do this!

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.

Was this page helpful?
0 / 5 - 0 ratings