在服务器上,我尝试将express绑定到socket.io,但是,当连接socket.io时,我在IDE中收到以下错误:
TS2349: This expression is not callable.
Type 'typeof import("***/node_modules/socket.io/dist/index")' has no call signatures.
Run Code Online (Sandbox Code Playgroud)
server.ts 中的代码:
import * as express from 'express';
import * as http from 'http';
import * as socketIo from 'socket.io';
const app: express.Express = express();
const httpServer: http.Server = new http.Server(app);
const io: any = socketIo();
const port: string | number = process.env.PORT || 3000;
app.use(express.static('public'));
const server: any = httpServer.listen(port, (): void => {
console.log('listening on *:3000');
});
Run Code Online (Sandbox Code Playgroud)