【发布时间】:2020-03-30 23:51:45
【问题描述】:
我正在尝试扩展以下 WebSocket https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ws/index.d.ts
无论我尝试什么,我似乎都无法向 WebSocket 添加新属性
// Messes with other typings in the WebSocket
declare module "ws" {
// Tried declare class MyWebSocket extends WebSocket too
interface WebSocket {
id: string;
}
}
wss.on("connection", socket => {
const id = uuidv4();
socket.id = id
socket.on("message", data => {
我在网上看到多人遇到这个问题,但我找不到详细的解决方案
【问题讨论】:
标签: typescript