回顾一些TypeScript代码,我遇到了这个问题,我不确定这是什么意思
type data = {
serial_number: string;
hub_sn: string;
};
type rapid = data & {
type: "rapid";
ob: number[];
};
我看到一个听众快速引用了它:
listen.on("rapid", async (data: rapid) => {
const [ts, ob] = decodeRapid(data.ob);
const body = `rapid,station=${data.serial_number} ${
serialize(ob)
} ${ts}`;
const response = await writeToInfluxDB(body);
console.log(JSON.stringify({ response, body }));
});
我对如何将来自侦听器的数据馈送到对象中一无所知?