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

types #288

Open
goodwin64 opened this issue Jan 12, 2024 · 4 comments
Open

types #288

goodwin64 opened this issue Jan 12, 2024 · 4 comments

Comments

@goodwin64
Copy link

Heyyya! Thanks for creating this client. It works quickly and is easy to set up 🔥

One nuance I'd like to bring up is Typescript support. It's 2024 now and more and more code is written with types in mind. There's an open issue on this matter: #244

but it looks like:
a) there are no news or updates for ~1.5 years
b) PR with types mentioned there seems to be stuck outdated with WiP status (DefinitelyTyped/DefinitelyTyped#60589)

The actual types in the DefinitelyTyped project are relevant for the client v0.18, while the latest version of the client right now is v3.0.

In our project, not to play around with Java and openapi-generator-cli dependencies mentioned here, we decided to declare a mini .d.ts types file:

// file is /src/asana/asanaTypes.d.ts

declare module 'asana' {
  export class ApiClient {
    static instance: ApiClient;
    authentications: {
      token: {
        accessToken: string;
      };
    };
  }

  export class TasksApi {
    createTask(body: CreateTaskBody, opts?: any): Promise<CreateTaskResult>;
  }

  export type CreateTaskBody = {
    data: {
      name: string;
      notes: string;
      projects: string[];
    };
  };

  export type CreateTaskResult = {
    // Define the properties of the result as per Asana API's response
    id: string;
    name: string;
    notes: string;
  };
}

I wanted to clarify is there a plan in the roadmap to add a typescript support for v3.0 to either "definitely typed" or directly to this repo?

@tristan-nsg
Copy link

https://www.npmjs.com/package/@types/asana

@samholmes
Copy link

@tristan-nsg Did you even read the post before commenting?

I'm interested in using this library too, and type information is really expected for any serious project (especially one which a lot of API).

I wonder how far we can get with a PR to add the .d.ts file to this project (no DefinitelyTyped needed).

@unickq
Copy link

unickq commented Nov 4, 2024

November, 11 months passed, and no updates 🐳

@buildgreatthings
Copy link

Hi @jv-asana and Asana team,

Please prioritize adding official TypeScript types for the Asana API. If this is not immediately feasible, consider at least publishing a comprehensive declaration file (*.d.ts) as an interim step to improve developer confidence and usability. This is a major blocker for us right now to enhance our integration with Asana, which is our top requested features from multiple publicly-traded companies.

Asana’s API is widely used in JavaScript/TypeScript projects, and the lack of officially supported TypeScript types creates unnecessary friction for developers. While there are community-generated types, they are often incomplete or outdated, leading to inconsistent development experiences and potential errors.

Adding TypeScript types to your API SDK would:
1. Enhance Developer Experience: TypeScript types provide autocomplete, intelligent code suggestions, and error-checking, significantly improving development speed and accuracy.
2. Reduce Bugs: Types reduce the likelihood of runtime errors by catching mismatched data at compile time. This is critical for API integrations where unexpected issues can lead to production downtime.
3. Align with Industry Standards: TypeScript has become the de facto standard for modern JavaScript development, and many competing platforms (e.g., Slack, GitHub) already offer first-class TypeScript support.
4. Future-Proofing: Providing types now ensures smoother adoption as TypeScript continues to dominate in front-end and back-end JavaScript development.

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

5 participants