SendBirdCall Typescript Init Error

I’ve tried integrating SendBirdCall with my Angular application. I’m importing SendBirdCall as mentioned in github readme page. Like this.

import SendBirdCall as “sendbird-calls”;

but that gives me no module named SendBirdCall and then I tried with below.

import * as SendBirdCall as “sendbird-calls”; and that leads to below error.

ERROR in node_modules/sendbird-calls/SendBirdCall.min.d.ts(29,44): error TS2304: Cannot find name 'int'.

Can you help me import SendBirdCall properly.

I too ran into a similar issue when attempting to utilize the sendbird-calls module with Typescript:

import SendBirdCall from 'sendbird-calls';

SendBirdCall.init();

and I was returned with

index.ts:1:8 - error TS1192: Module '"/Users/tylerhammer/Documents/Development/test/node_modules/sendbird-calls/SendBirdCall.min"' has no default export.

1 import SendBirdCall from 'sendbird-calls';

I also tried to compile this down with Babel and ES6, but I get a different error:

ReferenceError: self is not defined
    at /Users/tylerhammer/Documents/Development/test/node_modules/sendbird-calls/SendBirdCall.min.js:6:37339
    at /Users/tylerhammer/Documents/Development/test/node_modules/sendbird-calls/SendBirdCall.min.js:6:84
    at Object.<anonymous> (/Users/tylerhammer/Documents/Development/test/node_modules/sendbird-calls/SendBirdCall.min.js:6:165)
    at Module._compile (internal/modules/cjs/loader.js:1151:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1040:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/tylerhammer/Documents/Development/test/lib/index.js:3:45)

This may require a support ticket. Unfortunately I can’t look through the .min file.

1 Like

Hi rajasminonured and Tyler I’m Cobb from Sendbird. Thanks for your report!

The reported error is a known issue, and our declaration file type error causes it. We’ve already made a patch for it and preparing for release.

We’ll keep you updated when it’s release.

Thanks for your patience.

4 Likes

Hi Tyler, the above answer was for rajasmiounureed’s report, and the answer for your report is below.

As our JS SDK is intended to be used in browser environment, you cannot import it in nodejs environment.

Please refer to whatwg-fetch for more information.

Thanks

Thank makes total sense. I’ve used Node for so long and have only recently started playing with Frontend. Its tripped me up a couple of times. Appreciate the clarification.

@rajasimonureed @Tyler

Hello. I’m Junyoung from SendBird. Thanks for your precious report.

  • If you are using TypeScript, you have to set ‘–esModuleInterop’ setting to true for ‘default import’. README and documentation will be updated soon to prevent confusion.
  • There was a typo in the declaration file, which throw an error in TypeScript compilation. It is fixed in the latest release.
  • Importing sendbird-calls in Node environment threw an error. For the convenience of development, it is fixed in the latest release. Of course, the sendbird-calls is still supposed to be run on the browser.

Latest release is here. Thank you.

1 Like