小编Uol*_*ary的帖子

如何绑定 socket.io 宽度来表达 TypeScript?

在服务器上,我尝试将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)

node.js socket.io

3
推荐指数
1
解决办法
9250
查看次数

标签 统计

node.js ×1

socket.io ×1