intercom-node icon indicating copy to clipboard operation
intercom-node copied to clipboard

Not able to set intercom-version in headers for useRequestOpts

Open ThomasSchuller opened this issue 2 years ago • 6 comments

Version info

  • intercom-node version: 3.1.5
  • Node version: 14.18.2

Expected behavior

Setting the intercom-version with:

const client = new Client({ tokenAuth: { token: 'my_token' } });
client.useRequestOpts({
    headers: {
        'Intercom-Version': 2.4,
    },
});

Actual behavior

When using TS I get this error: Type '{ 'Intercom-Version': number; }' is not assignable to type 'HeadersDefaults'. Object literal may only specify known properties, and ''Intercom-Version'' does not exist in type 'HeadersDefaults'.ts(2322) index.d.ts(112, 3): The expected type comes from property 'headers' which is declared here on type 'Partial<AxiosDefaults<any>>'

Seems like it is linked to the sub dependency axios's type HeaderDefaults.

Steps to reproduce

  1. Setup a ts node project
  2. install intercom-client version 3.1.5
  3. Create main.ts file and add:
import { Client } from 'intercom-client';
const client = new Client({ tokenAuth: { token: 'my_token' } });
client.useRequestOpts({
    headers: {
        'Intercom-Version': 2.4,
    },
});

Logs

No logs, just a lint error.

ThomasSchuller avatar Jun 13 '22 10:06 ThomasSchuller

I'm also getting the same error: intercom client version 3.1.5 typescript version 4.2.2

aparkinson avatar Jul 11 '22 11:07 aparkinson

+1 client version 3.1.5, typescript version 4.2.2

isitgeorge avatar Jul 11 '22 11:07 isitgeorge

The typings for this library in general are embarrassingly bad :|

mullwaden avatar Nov 09 '22 12:11 mullwaden

@ mullwaden submit a feature request to intercom support for better typings in this lib. I submitted one a couple weeks back.

poppet-uk avatar Nov 14 '22 23:11 poppet-uk

How is this still open? I'm having same issue

colin-oos avatar Feb 06 '24 16:02 colin-oos

I believe for now you have to set it like this:

intercom.useRequestOpts({
      headers: {
        common: {
          'Intercom-Version': 2.6,
        },
        get: {},
        head: {},
        post: {},
        delete: {},
        put: {},
        patch: {},
      }
    })
  }

colin-oos avatar Feb 06 '24 16:02 colin-oos