microsoft / microsoft/TypeScript
Unexpected behavior when static methods are used in an array
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
TypeScript Version: 4.2.0-dev.20201211 (also tested with 4.2.0)
Search Terms: static method(s)
Code
class S {
static f(a: number|string): void {}
}
function g(a: number): void {}
// Uncomment to see a different behavior of the `output` const type.
// type G = typeof g;
const y = [S.f, g];
const output: ((ctrl: number|string) => void)[] = y;
Expected behavior:
Consistent type checking result (an error) for the output const with and without type G = typeof g.
Actual behavior:
If the type G = typeof g is present, the error is thrown (as expected), otherwise there is no error thrown.
Playground Link:
Playground link to reproduce the error.
// cc @alxhub @rkirov
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 dem verlinkten TypeScript Playground und dem reduzierten Beispiel mit S.f, g und der Ausgabezuweisung. Vergleiche die Typprüfung mit und ohne den Alias G und überprüfe dann die Behebung, indem du sicherstellst, dass beide Versionen konsistent den erwarteten Fehler melden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 38/100