New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: connector types #1362
fix: connector types #1362
Conversation
Co-authored-by: Khafra <42794878+KhafraDev@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We test our types! Can you add an assertion for this using tsd?
Also the build is failing |
Okay, so @KhafraDev the interface can't actually extend both of the types, it must be The type of export interface BuildOptions extends ConnectionOptions, TcpNetConnectOpts, IpcNetConnectOpts {
maxCachedSessions?: number | null;
socketPath?: string | null;
timeout?: number | null;
} But this gives a TS error that properties of Tcp and Ipc opts can't be both used due to conflicting types. Then we would get back to this: export type BuildOptions = (ConnectionOptions | NetConnectOpts) & {
maxCachedSessions?: number | null;
socketPath?: string | null;
timeout?: number | null;
} Which could also be: export type BuildOptions = (ConnectionOptions | TcpNetConnectOpts | IpcNetConnectOpts ) & {
maxCachedSessions?: number | null;
socketPath?: string | null;
timeout?: number | null;
} |
@mcollina what's your opinion on this? ^ |
I think the following look correct: export type BuildOptions = (ConnectionOptions | TcpNetConnectOpts | IpcNetConnectOpts ) & {
maxCachedSessions?: number | null;
socketPath?: string | null;
timeout?: number | null;
} however I'm not a big expert on TS, so I defer to whatever pleases the tests. |
Codecov Report
@@ Coverage Diff @@
## main #1362 +/- ##
==========================================
+ Coverage 94.24% 94.70% +0.45%
==========================================
Files 45 49 +4
Lines 4204 4246 +42
==========================================
+ Hits 3962 4021 +59
+ Misses 242 225 -17
Continue to review full report at Codecov.
|
Can you add a couple of assertions for this in the types tests? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@ronag Should this be merged already? |
@kibertoad is this ok? I'm waiting for somebody to better knowledge of TS than myself. |
@mcollina This is good to go! |
* fix: connector types * fix: add maxCachedSessions, socketPath and timeout back * Update types/connector.d.ts Co-authored-by: Khafra <42794878+KhafraDev@users.noreply.github.com> * fix: undo interface * Add tests * fix: tests & port should be optional Co-authored-by: Khafra <42794878+KhafraDev@users.noreply.github.com>
* fix: connector types * fix: add maxCachedSessions, socketPath and timeout back * Update types/connector.d.ts Co-authored-by: Khafra <42794878+KhafraDev@users.noreply.github.com> * fix: undo interface * Add tests * fix: tests & port should be optional Co-authored-by: Khafra <42794878+KhafraDev@users.noreply.github.com>
* fix: connector types * fix: add maxCachedSessions, socketPath and timeout back * Update types/connector.d.ts Co-authored-by: Khafra <42794878+KhafraDev@users.noreply.github.com> * fix: undo interface * Add tests * fix: tests & port should be optional Co-authored-by: Khafra <42794878+KhafraDev@users.noreply.github.com>
This PR fixes an issue with the type
buildConnector.BuildOptions
.The
buildConnector.BuildOptions
are used for 2 different methods,tls.connect(opts)
for https, andnet.connect(opt)
for all other protocols.TlsOptions
does not include all possible options that can be passed to those methods.tls.connect(opt)
accepts the typeConnectOptions
net.connect(opt)
accepts the typeNetConnectOpts