microsoft / microsoft/TypeScript
Go to definition for class members hidden with Symbols takes to symbol itself
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked TypeScript playground and reproduce go-to-definition on super[method] in the provided Parent and Child classes. Trace the language-service entry point for computed symbol members; done means navigation reaches the Parent method on line 4 instead of the Symbol declaration on line 1.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100