microsoft / microsoft/TypeScript
Function should be assignable to (...args: any[]) => any
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
Obviously all functions have type Function. And likewise all functions can be given the type
type AnyFunc = (...args: any[]) => any;
AFAIK, there is nothing one can do with something of type Function that cannot be done with something of type AnyFunc and vice versa. However they are not equivalently assignable:
(f: AnyFunc): Function => f;
(f: Function): AnyFunc => f;
// ^
// Type 'Function' is not assignable to type 'AnyFunc'.
// Type 'Function' provides no match for the signature '(...args: any[]): any'.
If I edit lib.d.ts to add a callable signature to Function:
interface Function {
(...argArray: any[]): any;
//...
}
it seems to "fix" this issue; is there any reason not to make this change for real?
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der Überprüfung der Function-Deklaration in lib.d.ts und des im Issue gezeigten Zuweisbarkeitsverhaltens. Untersuche bestehende Tests für Function und aufrufbare Signaturen und bewerte anschließend, ob das Hinzufügen der Signatur das erwartete Verhalten des Typsystems beibehält. Als abgeschlossen gilt die Aufgabe, wenn die vorgeschlagene Zuweisbarkeit mit Abdeckung der gezeigten Fälle behandelt ist und alle Kompatibilitätsbedenken ausgeräumt sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100