question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not working in Typescript Build

See original GitHub issue

@vonage/server-sdk is not working in typescript build

Expected Behavior

import VonageLib from '@vonage/server-sdk'
const Vonage = new VonageLib({
    apiKey: process.env.VONAGE_API_KEY,
    apiSecret: process.env.VONAGE_API_SECRET
 })

Needs to work in typescript build too. Not just in TS environment.

Current Behavior

The code is fine in typescript, but when build is created it makes the following JS code:

const server_sdk_1 = require("@vonage/server-sdk");
const Vonage = new server_sdk_1.default({
    apiKey: process.env.VONAGE_API_KEY,
    apiSecret: process.env.VONAGE_API_SECRET
});

Then the build gives the following error in production(running js code):

Cloud Function TypeError: server_sdk_1.default is not a constructor

If I change the import to import * as VonageLib from '@vonage/server-sdk', typescript gives the error This expression is not constructable.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
shihabuddincommented, Sep 13, 2021

Thanks @kellyjandrews. Using esModuleInterop solved the problem for me.

1reaction
kellyjandrewscommented, Aug 24, 2021

@shihabuddin Thanks - I’ll take a look and see if I can figure it out. My typescript is still a bit shaky. PRs with solutions also welcome - sorry for the troubles 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

typescript compiler (tsc) command not working with tsconfig
this is the problem: C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\tsc.exe C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\tsc.js.
Read more >
Common TypeScript module problems and how to solve them
Introduction · Problem 1: Irregular location of dependencies · Solution 1: Locate the correct directory · Problem 2: Multiple fallback locations.
Read more >
TypeScript Compiling with Visual Studio Code
A problem matcher parses build output based on the specific build tool and provides integrated issue display and navigation. VS Code ships with...
Read more >
TS does not compile .ts files #32326 - microsoft/TypeScript
It looks like this is a question rather than a bug report. This issue tracker is for tracking bugs and active work on...
Read more >
TypeScript: JavaScript With Syntax For Types.
TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. Try TypeScript Now. Online or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found