async-memoize-one icon indicating copy to clipboard operation
async-memoize-one copied to clipboard

Add type annotation

Open danielbom opened this issue 3 years ago • 2 comments

Can you add the type annotation to simplify the usage of this library in typescript?

declare module 'async-memoize-one' {
  import asyncMemoizeOne from "async-memoize-one";
  
  declare function asyncMemoizeOne<T>(callback: (...args: any[]) => Promise<T>): (...args: any[]) => Promise<T>;
  
  export default asyncMemoizeOne;
}

danielbom avatar Feb 18 '22 18:02 danielbom

Hey, I will be happy to accept a PR for this 🙂

Kikobeats avatar Feb 18 '22 19:02 Kikobeats

Just wanted to suggest a bit more strongly typed function definition:

declare module 'async-memoize-one' {
    declare function asyncMemoizeOne<TFn extends (...params: any[]) => Promise<any>>(
        callback: TFn,
    ): TFn;

    export default asyncMemoizeOne;
}

I might add a PR if I have some time

Obi-Dann avatar Nov 09 '22 23:11 Obi-Dann