Skip to content

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

@web-padawan

Description

@web-padawan

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions