Almenon / Almenon/throttle

improve typing by making arguments generic

Offen
#1 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
TypeScript
Sterne
0
Forks
0
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.