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 static method when using "import" in typescript #457

Closed ianzone closed 9 months ago

ianzone commented 1 year ago

Describe the bug Nylas.config() is undefined, when using import Nylas from 'nylas'

Nylas.config({ clientId: '', clientSecret: '' });
      ^
TypeError: Cannot read properties of undefined (reading 'config')
    at Object.<anonymous> (/home/ian/acte/roomzz-v1/api/booking/test.ts:3:7)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module.m._compile (/home/ian/.local/share/pnpm/global/5/.pnpm/ts-node@10.9.1_@types+node@18.15.11_typescript@5.0.4/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Object.require.extensions.<computed> [as .ts] (/home/ian/.local/share/pnpm/global/5/.pnpm/ts-node@10.9.1_@types+node@18.15.11_typescript@5.0.4/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Function.Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at phase4 (/home/ian/.local/share/pnpm/global/5/.pnpm/ts-node@10.9.1_@types+node@18.15.11_typescript@5.0.4/node_modules/ts-node/src/bin.ts:649:14)
    at bootstrap (/home/ian/.local/share/pnpm/global/5/.pnpm/ts-node@10.9.1_@types+node@18.15.11_typescript@5.0.4/node_modules/ts-node/src/bin.ts:95:10)

To Reproduce in test.ts

import Nylas from 'nylas';

Nylas.config({ clientId: '', clientSecret: '' });

then run ts-node test.ts

SDK Version: 6.10.0

relaxedtomato commented 1 year ago

Hi @ianzone, does the following syntax work?

const Nylas = require('nylas');

relaxedtomato commented 1 year ago

Just to clarify, we support CommonJS modules

ianzone commented 1 year ago

Hi @ianzone, does the following syntax work?

const Nylas = require('nylas');

It does, but ESM is pretty much the standard for js libraries nowadays.

ashryanbeats commented 1 year ago

Agreed @ianzone. Ram and I chatted with @mrashed-dev on our SDK team and he has share that ESM support is going into active development in a sprint soon. We'll keep you posted.

mrashed-dev commented 1 year ago

Thanks @ianzone for submitting this issue, the feature is complete and will be included in the next major release of the SDK. We will have the first beta coming out very soon!

mrashed-dev commented 9 months ago

Closing this issue as it's been included in the v7 beta releases.