microsoft / microsoft/TypeScript

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

オープン
#35,406 コメント 0 件 リアクション 5 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Experience Enhancement Suggestion
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
1日 19時間
マージ済み PR(30日)
117

説明

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 https://github.com/microsoft/TypeScript/issues/17744#issuecomment-431534647

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンクされた TypeScript playground から始め、提供された Parent クラスと Child クラスで super[method] に対する go-to-definition を再現します。計算されたシンボルメンバーに対する language-service のエントリポイントを追跡します。完了条件は、ナビゲーションが 1 行目の Symbol 宣言ではなく、4 行目の Parent メソッドに到達することです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。