microsoft / microsoft/TypeScript
Inconsistent error messages with circular base type argument
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
I noticed here that a type argument to a base class can reference property types in the same class, so I wondered what would happen if I tried to reference an inherited property type that itself depends on the type argument. To its credit, the compiler didn't crash, but the errors I got didn't make much sense.
TypeScript Version: master (e1a4c2779f93c8389d1589e543920a61771e97ec)
Search Terms: circular self referential base extends type argument property same class lookup type
Code
class Super<T> {
foo!: T;
}
class Sub extends Super<Sub["bar"]> {
bar!: Sub["foo"]; // Actual: Error: "Property 'foo' does not exist on type 'Sub'."
baz!: Sub["foo"]; // Actual: No error
}
Expected behavior: An error that indicates that circular type annotations are involved.
Actual behavior: As marked.
Playground Link: link
Related Issues: None found, but this is hard to search for.
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
Riproduci la discrepanza usando il Playground Link fornito con la revisione master di TypeScript mostrata nel report, quindi traccia il comportamento del compilatore per l'argomento di tipo base circolare. Il lavoro è completato quando i casi bar e baz ricevono una diagnostica coerente che indichi il coinvolgimento di annotazioni di tipo circolari, invece degli attuali risultati discordanti.
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
- 35/100