Can't import socket.io-client (v2.4.0) in my typescript project

1.4k Views Asked by At

It says here that I can import it like this: import io from 'socket.io-client';

But doing this I'm getting an error:

Could not find a declaration file for module 'socket.io-client'. '/.../project/node_modules/socket.io-client/lib/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/socket.io-client` if it exists or add a new declaration (.d.ts) file containing `declare module 'socket.io-client';`ts(7016)

I have tried installing @types/socket.io-client but the error doesn't go away.

1

There are 1 best solutions below

0
On

Nevermind, it worked importing this way:

const io = require("socket.io-client/dist/socket.io")