-
Notifications
You must be signed in to change notification settings - Fork 233
build: fix type errors with newer versions of typescript #323
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
base: main
Are you sure you want to change the base?
Changes from all commits
cdfaf4d
566250e
01cada3
dabdbbd
19fd833
5533dce
b59d00f
18568cd
1f23fa7
0018bdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,7 @@ export type SMTPSocketOptions = Omit< | |
>; | ||
|
||
export interface SMTPConnectionOptions { | ||
timeout: number | null; | ||
timeout: number | null | undefined; | ||
eleith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
user: string; | ||
password: string; | ||
domain: string; | ||
|
@@ -174,7 +174,7 @@ export class SMTPConnection extends EventEmitter { | |
this.port = port || (ssl ? SMTP_SSL_PORT : tls ? SMTP_TLS_PORT : SMTP_PORT); | ||
this.loggedin = user && password ? false : true; | ||
|
||
if (!user && (password?.length ?? 0) > 0) { | ||
if (user == null && password != null && password.length > 0) { | ||
throw new Error('`password` cannot be set without `user`'); | ||
} | ||
|
||
|
@@ -520,7 +520,8 @@ export class SMTPConnection extends EventEmitter { | |
// It's actually stricter, in that only spaces are allowed between | ||
// parameters, but were not going to check for that here. Note | ||
// that the space isn't present if there are no parameters. | ||
this.features[parse[1].toLowerCase()] = parse[2] || true; | ||
const [, one = '', two = true] = parse; | ||
this.features[one.toLowerCase()] = two; | ||
} | ||
}); | ||
} | ||
|
@@ -554,7 +555,7 @@ export class SMTPConnection extends EventEmitter { | |
* @returns {boolean} whether the extension exists | ||
*/ | ||
public has_extn(opt: string) { | ||
return (this.features ?? {})[opt.toLowerCase()] === undefined; | ||
return this.features != null && this.features[opt.toLowerCase()] != null; | ||
Comment on lines
-557
to
+558
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it took a bit of digging because this file has been renamed more than once. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the only change i did to that method in that commit was to add nullish coalescing. i'm referring specifically to the comparison to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agreed. it's wrong. i also can't find any use of this public method anywhere. |
||
} | ||
|
||
/** | ||
|
@@ -631,7 +632,11 @@ export class SMTPConnection extends EventEmitter { | |
*/ | ||
public message(data: string) { | ||
this.log(data); | ||
this.sock?.write(data) ?? this.log('no socket to write to'); | ||
if (this.sock != null) { | ||
this.sock.write(data); | ||
} else { | ||
this.log('no socket to write to'); | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -710,10 +715,10 @@ export class SMTPConnection extends EventEmitter { | |
const login = { | ||
user: user ? () => user : this.user, | ||
password: password ? () => password : this.password, | ||
method: options?.method?.toUpperCase() ?? '', | ||
method: options.method != null ? options.method.toUpperCase() : '', | ||
}; | ||
|
||
const domain = options?.domain || this.domain; | ||
const domain = options.domain || this.domain; | ||
|
||
const initiate = (err: Error | null | undefined, data: unknown) => { | ||
if (err) { | ||
|
@@ -755,16 +760,18 @@ export class SMTPConnection extends EventEmitter { | |
// List of authentication methods we support: from preferred to | ||
// less preferred methods. | ||
if (!method) { | ||
const preferred = this.authentication; | ||
let auth = ''; | ||
|
||
if (typeof this.features?.['auth'] === 'string') { | ||
if ( | ||
this.features != null && | ||
typeof this.features['auth'] === 'string' | ||
) { | ||
auth = this.features['auth']; | ||
} | ||
|
||
for (let i = 0; i < preferred.length; i++) { | ||
if (auth.includes(preferred[i])) { | ||
method = preferred[i]; | ||
for (const authMethod of this.authentication) { | ||
if (auth.includes(authMethod)) { | ||
method = authMethod; | ||
break; | ||
} | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.