Open penguoir opened 3 years ago
Let me know if this isn't the right repo to put this issue.
In the onAuth handler, I pass an object through the user parameter. It says in the documentation that this is fine.
onAuth
user
onAuth (auth, session, callback) { const account = getAccountFromSMTP(auth) // ... return callback(null, { user: account }) }
But then, when I use this account in the onRcptTo handler, Typescript tells me that user is a string!
onRcptTo
onRcptTo (address, session, callback) { const account = session.user account.doStuff() // ERROR: Property 'doStuff' does not exist on type 'string'. }
This makes sense, as that's what's written in the type definitions:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/a23f844346b0013a6bbc74ef0ddea16c127e815f/types/smtp-server/index.d.ts#L119
string
any
SMTPServerSession.user
Thanks!
A workaround:
(session.user as unknown as Account).doStuff()
Any next steps I could take?
Let me know if this isn't the right repo to put this issue.
In the
onAuth
handler, I pass an object through theuser
parameter. It says in the documentation that this is fine.But then, when I use this account in the
onRcptTo
handler, Typescript tells me thatuser
is a string!This makes sense, as that's what's written in the type definitions:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/a23f844346b0013a6bbc74ef0ddea16c127e815f/types/smtp-server/index.d.ts#L119
Possible solutions
string
toany
.SMTPServerSession.user
to be the same as whatever type was passed through inonAuth
.Thanks!