microsoft / microsoft/TypeScript

'super.prop' in static method should be allowed to access static properties of base class

Aperta
#42,215 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Bug Domain: classes
Lingua principale
Go
Stelle
111k
Fork
14.3k
Merge medio
2g 4h
PR unite (30g)
132

Descrizione

Bug Report

🔎 Search Terms

super property access static

🕗 Version & Regression Information
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about "super"
⏯ Playground Link

Playground link with relevant code

💻 Code
// @target: ES5
class Base {
    static method() {}
    static prop = 1;
    static get accessor() { return 1 }
}

class Derived extends Base {
    static fn() {
        super.method; // allowed, as expected
        super.accessor; // not allowed, not expected
        super.prop; // not allowed, not expected
    }
}
🙁 Actual behavior

super.accessor and super.prop are marked as error. That makes sense in instance methods, but not in static methods, because static properties are not on the prototype.

Related: #42214

🙂 Expected behavior

No error.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dal TypeScript Playground collegato e riproduci l’esempio di classe statica usando il target ES5. Segui il punto di ingresso del checker per l’accesso alle proprietà tramite super, quindi verifica che super.prop e super.accessor nel metodo statico non producano errori, mentre il caso esistente super.method rimanga valido.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
compilers
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.