Asana / node-asana

Official node.js and browser JS client for the Asana API v1
MIT License
264 stars 74 forks source link

Property 'ApiClient' does not exist on type 'typeof asana'. Did you mean 'Client'?ts(2551) #296

Open Strooss opened 4 months ago

Strooss commented 4 months ago

Types don't really match the code

jv-asana commented 4 months ago

Hi @Strooss which version of the node-asana are you using? In our v1.X.X (EX:v1.0.5) you would use asana.Client while in v3.X.X [EX: v3.0.6] it's Asana.ApiClient

node-asana v1.0.5:

const asana = require('asana');

const client = asana.Client.create().useAccessToken("<YOUR_ASANA_PERSONAL_ACCESS_TOKEN>");

client.users.getUser("me").then((result) => {
    console.log(result);
});
v1_sample_code

node-asana v3.0.6:

const Asana = require('asana');

let client = Asana.ApiClient.instance;
let token = client.authentications['token'];
token.accessToken = "<YOUR_ASANA_PERSONAL_ACCESS_TOKEN>";

let usersApiInstance = new Asana.UsersApi();
let user_gid = "me"; // String | A string identifying a user. This can either be the string \"me\", an email, or the gid of a user.
let opts = {};

usersApiInstance.getUser(user_gid, opts).then((result) => {
    console.log('API called successfully. Returned data: ' + JSON.stringify(result.data, null, 2));
}, (error) => {
    console.error(error.response.body);
});
v3_sample_code
oev-chrisbennett commented 3 months ago

@Strooss the @types/asana package matches the types in the previous version of asana.

npm remove @types/node
rm -rf node_modules
npm install

then restart your editor, and the type issues should disappear. Sadly you'll have no types 😞

Strooss commented 2 months ago

Yes im using the last version (node-dsk-v3). and yes the package don't have types right?

jv-asana commented 2 months ago

Hi @Strooss, @oev-chrisbennett is correct.

The @types/asana package only works with node-asana v1 client library version.

node-asana v3 client library version is not supported.

For context, we did not write or maintain the @types/asana package. It looks like an external dev worked on this and had to manually maintain it by updating it when our API changes.

Taking a look at the commit history for @types/asana it looks like the last major update to the types was 2 years ago.