You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm expecting this to not be a bug but I can't seem to figure out what else it could be.
Basically I'm trying to create a (TLS)Socket instance using the core Node.js net or tls modules depending on a condition.
Instantiating them by directly referencing the module works fine but whenever I introduce a level of indirection by conditionally defining the TCP client module, compilation breaks.
This expression is not callable.
Each member of the union type
'{ (options: NetConnectOpts, connectionListener?: (() => void) | undefined): Socket;
(port: number, host?: string | undefined, connectionListener?: (() => void) | undefined): Socket;
(path: string, connectionListener?: (() => void) | undefined): Socket; } | { ...; }'
has signatures, but none of those signatures are compatible with each other.
12 const socketC = client.connect({ host: 'localhost', port: 443 });
~~~~~~~
This is essentially a duplicate of #7294 (this part of which has not been fixed by #29011). If you have a union of function types and more than one of the members of the union is overloaded or generic, the compiler won't let you call it. You need to help the compiler out by manually annotating the union as a single callable signature it can verify, e.g.,
I'm expecting this to not be a bug but I can't seem to figure out what else it could be.
Basically I'm trying to create a
(TLS)Socket
instance using the core Node.jsnet
ortls
modules depending on a condition.Instantiating them by directly referencing the module works fine but whenever I introduce a level of indirection by conditionally defining the TCP client module, compilation breaks.
Code
Expected behavior:
Successful compilation.
Actual behavior:
Playground Link:
Playground Link
Related Issues:
The text was updated successfully, but these errors were encountered: