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.

Argument of type '{ apiKey: string; apiSecret: string; }' is not assignable to parameter of type 'AuthInterface'

See original GitHub issue

Migrating from v2, I can’t instantiate a Vonage object. From README.md :

const { Vonage } = require('@vonage/server-sdk');

const vonage = new Vonage({
    apiKey: API_KEY,
    apiSecret: API_SECRET,
    applicationId: APP_ID,
    privateKey: PRIVATE_KEY_PATH,
    signatureSecret: SIGNATURE_SECRET,
    signatureMethod: SIGNATURE_METHOD
  }, options);

To suit our coding guidelines, I use:

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

const vonage = new Vonage({
    apiKey: ##REDACTED##,
    apiSecret: ##REDACTED##,
}, { debug: false });

I can’t transpile with the following Typescript error:

error TS2345: Argument of type '{ apiKey: string; apiSecret: string; }' is not assignable to parameter of type 'AuthInterface'.
  Type '{ apiKey: string; apiSecret: string; }' is missing the following properties from type 'AuthInterface': getQueryParams, createSignatureHash, createBasicHeader, createBearerHeader

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

  • SDK Version: 3.0.6
  • Node Version: (e.g. Node 10.18): 14.20.1
  • Operating System and version: macOS 13.0.1
  • Typescript: 4.9.3

my tsconfig.json as follows:

{
  "compilerOptions": {
    "target": "es2019",
    "module": "commonjs",
    "sourceMap": true,
    "outDir": "../dist",
    "rootDir": ".",
    "removeComments": true,
    "strict": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "noEmitOnError": true,
    "skipLibCheck": true,
  },
  "references": [
    { "path": "../" }
  ]
}

Issue Analytics

  • State:open
  • Created 10 months ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
fmasclefcommented, Nov 23, 2022

Thanks @Kirween. This obviously works. Someone to fix the README.md?

1reaction
Kirweencommented, Nov 23, 2022

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##,
}));
Read more comments on GitHub >

github_iconTop Results From Across the Web

Argument of type '[string]' is not assignable to parameter of ...
My best answer is that U in memoized_async is not actually (string | number | boolean | undefined)[] . If I did this:...
Read more >
Typescript error "Type 'string' is not assignable to type ... - GitHub
Typescript doesn't want to compile this because the string value isn't considered the same type as the enum value, even though the strings...
Read more >
Angular | null' is not assignable to parameter of type 'string'
The TypeScript interface for the JSON.parse() function defines a string parameter as the first argument, whereas the interface for localStorage.
Read more >
Argument of type 'string' is not assignable to parameter of type
The React component works fine and displays the right icon based on the string it receives back from the API based on my...
Read more >
Argument type 'string or null' not assignable to parameter of ...
The error "Argument of type 'string | null' is not assignable to parameter of type string" occurs when a possibly `null` value is...
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