0
const io = require('socket.io')(server, {
  cors: {
    origin: '*',
  }
});

How can I change the syntax to TS? (import {} from '';

1 Answer 1

1

You can't pass parameters to import in ES6 as you're doing with that require.

However, the documentation suggest something like this:

import { createServer } from "http";
import { Server, Socket } from "socket.io";

const httpServer = createServer();
const io = new 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.