例如,这是正确的:
const net = require('net');
const Socket = net.Socket;
/**@type {Socket} */
var s;
s.setTimeout(0);
但这些不正确:
const net = require('net');
/**@type {NodeJS.Socket} */
var s1; //the type is 'interface Socket' not 'class Socket'
/**@type {typeof net.Socket} */
var s2; //the type is 'interface Socket' not 'class Socket'
/**@type {net.Socket} */ //Can't find namespace "net"
var s3;
那么,如何在没有额外Socket
const Socket = net.Socket;