nylas / nylas-nodejs

A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.
MIT License
169 stars 118 forks source link

Missing type definition #468

Closed ianzone closed 1 year ago

ianzone commented 1 year ago

image

mrashed-dev commented 1 year ago

Thanks for opening this issue @ianzone! This is unfortunately the result of a design decision and fixing this issue directly would cause a breaking change for everyone using the SDK. However, if you know you're anticipating a ManagementAccount type then you can modify line 6 to be:

const account: ManagementAccount = await Nylas.accounts.find(user.id);

That way, account.upgrade() will be known to your IDE. The issue is stemming from Nylas.accounts being a union of both ManagementAccount and Account, but upgrade only exists on the former. The upcoming SDK upgrade will be solely supporting API v3 but we've redesigned the SDK to be simpler and more explicit to avoid situations like this. Sorry for the poor experience here, but we thank you for opening this issue!