Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go to definition for class members hidden with Symbols takes to symbol itself #35406

Open
web-padawan opened this issue Nov 28, 2019 · 0 comments
Labels
Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript
Milestone

Comments

@web-padawan
Copy link

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.

Playground Link: https://www.typescriptlang.org/play/?ts=3.8.0-dev.20191126&ssl=1&ssc=1&pln=38&pc=2#code/MYewdgzgLgBAtgUygCxAExgXhgZQJ5wBGIANgBQDkiK6FAlANwBQTwJAhhBDAArsBOCMLADeTGBJgAHfiCgJg8jAG1qqNAF0ydGGMn6YgqAFd+YGBSkChUCs30BfJk9YcuMAMLIAliQwIAD3kwNG4+QWFdcUkZOQUlGFUkdS0dPQMJI1NzCGMpBH4kmk1tGABqCxhgHz87aIknJyA

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 #17744 (comment)

@RyanCavanaugh RyanCavanaugh added Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript labels Dec 5, 2019
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Dec 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Experience Enhancement Noncontroversial enhancements Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants