typings index.d.ts failing transpilation, needs an ts-ignore bypass.
See original GitHub issueUsing @vonage/server-sdk with typescript doesn’t transpile without an unrecommended bypass, but then it doesn’t work at all.
Expected Behavior
The expected behavior is to use the package without ts notations
Current Behavior
The current behavior is the next.
import * as Vonage from '@vonage/server-sdk';
const nexmo = new Vonage({
apiKey: 'asdf',
apiSecret: 'asdf',
});
// throws:
// TS2351: This expression is not constructable.
// Type 'typeof import("@vonage/server-sdk")' has no construct signatures
import Vonage from '@vonage/server-sdk';
const nexmo = new Vonage({
apiKey: 'asdf',
apiSecret: 'asdf',
});
// ide don't complain, but when executing the bundle it throws a fatal error:
// TypeError: server_sdk_1.default is not a constructor
Context
Now it needs to be used with this ts notations:
import * as Vonage from '@vonage/server-sdk';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const nexmo = new Vonage({
apiKey: 'asdf',
apiSecret: 'asdf',
});
const from = 'Vonage APIs';
const to = '...';
const text = 'Hello from Vonage SMS API';
nexmo.message.sendSms(from, to, text, {}, (err, data) => {
console.log(err);
console.log(data);
});
// sms received
Your Environment
- SDK Version: “2.10.4”
- Node Version: v14.15.1
- TSC Version: 4.0.3
- Operating System and version: Ubuntu 20.04.1 LTS
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to force tsc to ignore node_modules folder?
To do so, the compiler needs the definition of a module, this could be a .ts file for your own code, or a...
Read more >TSConfig Reference - Docs on every TSConfig option
From allowJs to useDefineForClassFields the TSConfig reference includes information about all of the active compiler flags setting up a TypeScript project.
Read more >JSDoc typings: all the benefits of TypeScript, with none of the ...
How you can use JSDoc typings to get all the benefits of TypeScript, without any transpilation.
Read more >TypeScript - Cypress Documentation
Cypress ships with official type declarations for TypeScript. This allows you to write your tests in TypeScript. Install TypeScript To use TypeScript.
Read more >A Complete Guide to Using TypeScript in Node.js - Better Stack
TypeScript is a superset of JavaScript that brings static typing capabilities to the ... Learn more about when to use ts-ignore or ts-expect-error...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@visioncored - you may also need to add the following config:
I just about have things fixed up.
@kellyjandrews I also encountered this issue when I was trying out the SMS API in Firebase Cloud Functions. Here is the .tsconfig from my end.