microsoft / microsoft/TypeScript
Unexpected behavior when static methods are used in an array
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con il TypeScript Playground collegato e l’esempio ridotto che usa S.f, g e l’assegnazione dell’output. Confronta il controllo dei tipi con e senza l’alias G, quindi verifica la correzione assicurandoti che entrambe le versioni segnalino sistematicamente l’errore previsto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 38/100