Vonage / vonage-node-sdk

Vonage API client for Node.js. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
Apache License 2.0
382 stars 181 forks source link

Property 'calls' does not exist on type 'Vonage' #613

Closed speak-jure closed 1 year ago

speak-jure commented 2 years ago

Issue

Vonage in relation to Typescript. After initializing a Vonage object, the calls property is not recognized as being part of the object, since it's not defined in d.ts.

Code

import Vonage from '@vonage/server-sdk';

const vonage = new Vonage({
    apiKey: process.env.VONAGE_API_KEY,
    apiSecret: process.env.VONAGE_API_SECRET,
    applicationId: process.env.VONAGE_APPLICATION_ID,
});

vonage.calls.create({...}, (error: any, response: any) => {...}).

Error

The calls in vonage.calls.create is underlined and specifies the following problem: Property 'calls' does not exist on type 'Vonage'.

Request

Is there any short-term plan on adding typing for this as well? Or is there a workaround that I am not aware of? Besides using // @ts-ignore.

kellyjandrews commented 2 years ago

The types for v2 have been mostly community supported. I'm working on v3 right now which will help with some of this, but haven't gotten to Voice quite yet. I should be in the next week or two. The only other way to work around it is set it to any, or extend it locally. I wish I had better news for you.

speak-jure commented 2 years ago

Hey Kelly!

Thank you for your reply. I assumed it's an upcoming improvement, but I'm glad to have gotten your confirmation. I have a workaround set up by using @ts-ignore, so I agree that my request is more of a nice to have than anything else.

Keep up the good work.

manchuck commented 1 year ago

@speak-jure Can you update V3 of the SDK and LMK if you still have an issue?

serfermorhc commented 1 year ago

Hello, i have the same issue this thread speaks about, those are my vonage object properties;

` Vonage {credentials: Auth, options: undefined, accounts: Accounts, applications: Applications, messages: Messages, …}

accounts: Accounts {auth: Auth, config: {…}, authType: 'query_key_secret'} applications: Applications {auth: Auth, config: {…}, authType: 'basic'} credentials: Auth {getQueryParams: ƒ, createBasicHeader: ƒ, createBearerHeader: ƒ, createSignatureHash: ƒ, apiKey: 'xxxxxx', …} messages: Messages {auth: Auth, config: {…}} numberInsights: NumberInsights {auth: Auth, config: {…}} numbers: Numbers {auth: Auth, config: {…}, authType: 'query_key_secret'} options: undefined pricing: Pricing {auth: Auth, config: {…}, authType: 'query_key_secret'} secrets: Secrets {auth: Auth, config: {…}, authType: 'basic'} sms: SMS {auth: Auth, config: {…}} verify: Verify {auth: Auth, config: {…}} voice: Voice {auth: Auth, config: {…}, authType: 'jwt'}

` There is a "voice" property, but any "calls".

I use the version 3.0.10; "dependencies": { "@vonage/server-sdk": "^3.0.10", }

manchuck commented 1 year ago

@serfermorhc and @speak-jure Apologies as we are behind on updating the code snippets and documentation. calls is no longer a property on numbers. We updated the function names to be more descriptive. Instead of calling vonage.numbers.calls.create, you can call vonage.numbers.createOutboundCall. I have added a migration guide that should explain all the changes.

Another point of note, we updated most of the functions to accept a parameters object instead of just passing in parameters. We are looking to build out technical documentation for all our functions. Once that is ready to go, you will be able to get a more detailed rundown of what needs to be passed into each call.

manchuck commented 1 year ago

This issue stems from improper documentation which has been addressed