microsoft / microsoft/TypeScript
Unhelpful `--strictFunctionTypes` error when first method is `self(): this;`
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
TypeScript Version: 2.7.0-dev.20171214
Code
declare class C<T> {
self(): this;
covariant(): T;
contravariant: (t: T) => void;
m(other: C<{}>): void;
}
new C<number>().m(new C<number>());
Expected behavior:
Error that C<number> isn't C<{}> because C<{}>'s contravariant can accept (t: {}) but C<number> can only accept (t: number).
Actual behavior:
src/a.ts(8,19): error TS2345: Argument of type 'C<number>' is not assignable to parameter of type 'C<{}>'.
Types of property 'self' are incompatible.
Type '() => C<number>' is not assignable to type '() => C<{}>'.
Type 'C<number>' is not assignable to type 'C<{}>'.
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
Riprodurre il problema con lo snippet TypeScript nel report usando --strictFunctionTypes e confrontare la diagnostica con il comportamento previsto indicato. Tracciare il confronto dei tipi attivato dal primo metodo self(): this e considerare completato l’issue quando l’errore identifica invece l’incompatibilità della proprietà controvariante.
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
- Abbastanza chiara
- Idoneità per principianti
- 38/100