microsoft / microsoft/TypeScript
Go to definition for class members hidden with Symbols takes to symbol itself
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
As a developer working with Custom Elements classes that have their class members available in runtime, I would like to use Symbol to hide internal methods and properties from the public API.
The drawback of this approach is that "go to definition" currently does not recognise the case when Symbol is used for a method, and jumps to the place where the Symbol itself is defined.
I'm not sure whether this is a bug or feature.
TypeScript Version: 3.8.0-dev.20191126
Search Terms: Go to definition, ECMAScript Symbols, Symbol
Code
const method = Symbol('method');
class Parent {
protected [method]() {
return 'parent';
}
}
class Child extends Parent {
protected [method]() {
return super[method]() + ' child';
}
}
Expected behavior:
When clicking on super[method], it should be possible to go to the line 4.
Actual behavior:
When clicking on super[method], go to definition moves to the line 1.
Related Issues:
I didn't found any related issue but the approach with using ES2015 Symbols was suggested to be used as a workaround for protected methods in mixins at https://github.com/microsoft/TypeScript/issues/17744#issuecomment-431534647
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 playground TypeScript collegato e riproduci go-to-definition su super[method] nelle classi Parent e Child fornite. Traccia il punto di ingresso del language service per i membri di simbolo calcolati; il lavoro è completato quando la navigazione raggiunge il metodo Parent alla riga 4 invece della dichiarazione di Symbol alla riga 1.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 45/100