Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Strooss opened this issue Apr 23, 2024 · 5 comments

Comments

@Strooss
Copy link

Strooss commented Apr 23, 2024

Types don't really match the code

@jv-asana
Copy link
Contributor

jv-asana commented Apr 26, 2024

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
Copy link

oev-chrisbennett commented May 24, 2024

@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
Copy link
Author

Strooss commented Jun 26, 2024

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

@jv-asana
Copy link
Contributor

jv-asana commented Jun 26, 2024

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.

@Xanacas
Copy link

Xanacas commented Dec 6, 2024

I see, that you have a lot of jsdocs in the source, which should enable typescript to create types while using this lib.
However, it's not working for me. any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants