0

Im new at socket io and im trying to use typescript on the project so i got the error of the image on start the socket server, i already tried to change the import to import * as socketIo from 'socket.io' but nothing changes, i dont know if is some version issue or im doing something wrong.

the error: The error

code:

code

1 Answer 1

1

Type declaration for socket.io does not contain default export. You can check it in its index.d.ts. It contains the following:

export { Socket, ServerOptions, Namespace };

That's why to init socket.io server object you need to use the following instruction:

const app = express();
const httpServer = new http.Server(app);
const io = new socketio.Server(httpServer);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.