Closed fmasclef closed 1 year ago
Based on the Typescript declaration, this should work
import { Vonage } from '@vonage/server-sdk';
import { Auth } from '@vonage/auth';
const vonage = new Vonage( new Auth({
apiKey: ##REDACTED##,
apiSecret: ##REDACTED##,
}));
Thanks @Kirween. This obviously works. Someone to fix the README.md?
Someone to fix the README.md?
It would be better to fix the type of the first parameter of the constructor
Should be
constructor(
credentials: AuthInterface | AuthOpts,
options?: {
...
The issue is not the constructor, but the differences between JS and TS enforcing code.
Our code snippets are for JavaScript, which lets us have users pass in a similar credentials structure from previous versions. We then convert that into an Auth
object internally. This is a convenience that JS affords us.
For TypeScript, we require you to pass in an Auth
object. At the moment while we have much better TS support than before, our published code snippets are taken from a JavaScript perspective.
@fmasclef Updating and Fixing the readmes is on my to-do for the week. I was at a conference the week after the V3 release and last week was short due to the holiday. Apologies for the issues with the readme
@fmasclef This is addressed in #801
You can now use the ConfigParams
, AuthInterface
or AuthParams
to overwrite the client constructor.
Migrating from v2, I can't instantiate a Vonage object. From README.md :
To suit our coding guidelines, I use:
I can't transpile with the following Typescript error:
Expected Behavior
By the doc, Typescript shouldn't complain and transpile.
Current Behavior
It's not working mate :(
Possible Solution
???
Steps to Reproduce (for bugs)
Copy paste code I provide, then
tsc -p .
Context
Your Environment
my tsconfig.json as follows: