Closed tkrotoff closed 5 years ago
Hi,
I have never really used TS so far nor published any binding, PR welcome if you can help. I'll probably use TS soon so I will probably know better what to do
I started using ts recently, will try to work on this soon
Here is a draft:
// awesome-debounce-promise.d.ts
declare module 'awesome-debounce-promise' {
export interface Options {
/**
* One distinct debounced function is created per key and added to an internal cache
* By default, the key is null, which means that all the calls
* will share the same debounced function
*/
key?: (...args: any[]) => null|string
/**
* By default, a debounced function will only resolve
* the last promise it returned
* Former calls will stay unresolved, so that you don't have
* to handle concurrency issues in your code
* Setting this to false means all returned promises will resolve to the last result
*
* **Default**: `true`
*/
onlyResolvesLast?: boolean
}
export type PromiseProducer = (...args: any[]) => Promise<any>
export type AwesomeDebouncePromiseStatic = <P extends PromiseProducer>(fn: P, interval_ms: number, options?: Options) => P
const AwesomeDebouncePromiseStatic: AwesomeDebouncePromiseStatic
export default AwesomeDebouncePromiseStatic
}
thanks @jsamr
I really like TS and planning to rewrite all my libs in TS progressively
In the meantime your definition will probably be useful to others ;)
Hi,
I've totally migrated the project to TS so this should be fine now.
However if someone want to give some help, because internally I had to resort to some "as any" to make things compile... Not so easy to type async function wrappers
Would be nice to have a TypeScript type definition