Almenon / Almenon/throttle

improve typing by making arguments generic

Open
#1 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Current type:

```typescript
Limit.throttledUpdate(fn: Function, wait: number): (...args: any[]) => void
```
The problem is that when you make a function with it, like so:
```typescript
let throttledFunc = new Limit().throttledUpdate((x:string,y:number)=>"foo", 50)
```

The throttledFunc has type (...args: any[]) => void
But it should have type (x:string, y:number) => void

Ideally I would want to do something like this:
```typescript
Limit.throttledUpdate(fn: ...T, wait: number): (...T) => void
```

Unfortunately, it looks like this capability is still in the proposal stages: https://github.com/Microsoft/TypeScript/issues/5453

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.