在ts项目中 Websocket 接口的类型声明和文档上的描述不符
tokisakiyuu opened this issue · 1 comments
tokisakiyuu commented
描述
在vscode中的截图如下:
当然,编译也是不过的:
> tsc
src/main.ts:13:4 - error TS2339: Property 'on' does not exist on type 'WebsocketClient'.
13 ws.on('READY', (wsdata: any) => {
~~
依赖
├── @types/node@18.13.0 -> ./node_modules/.pnpm/@types+node@18.13.0/node_modules/@types/node
├── axios@1.3.2 -> ./node_modules/.pnpm/axios@1.3.2/node_modules/axios
├── dotenv@16.0.3 -> ./node_modules/.pnpm/dotenv@16.0.3/node_modules/dotenv
├── qq-guild-bot@2.9.5 -> ./node_modules/.pnpm/qq-guild-bot@2.9.5/node_modules/qq-guild-bot
├── ts-node@10.9.1 -> ./node_modules/.pnpm/ts-node@10.9.1_4bewfcp2iebiwuold25d6rgcsy/node_modules/ts-node
└── typescript@4.9.5 -> ./node_modules/.pnpm/typescript@4.9.5/node_modules/typescript
环境
nodejs v16.14.0
pnpm 7.2.1
WitchElaina commented
添加这个依赖可以解决
"dependencies": {
"@types/ws": "^8.2.0",
}