microsoft / microsoft/TypeScript

"Go To Type Definition" for type names should navigate to the type definition

オープン
#33,147 コメント 1 件 リアクション 2 件 担当者 0 名 GitHub で見る

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

Domain: LS: Symbol Navigation In Discussion Suggestion
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

"Go To Type Definition" doesn't doesn't work when the selection is itself a type. Instead, you get a "No type definition found" error. I can understand why it was implemented in this way ("types don't have a type!") but IMHO this behavior unnecessarily inconsistent and confusing for users. If I ask for the type definition of a type, then I should be taken to the... type definition! ;-)

I'm filing this at @weswigham's request to split it out of #6209. IMHO, if #6209 is implemented as I'm suggesting (where Go To Definition would navigate to the actual implementing source, not the DefinitelyTyped .d.ts) then fixing this issue would be helpful because it'd make both operations more consistent:

  • Go To Definition would always navigate to implementation code (not to type declarations), regardless of what symbol is selected.
  • Go to Type Definition would always navigate to type declarations, regardless of what symbol is selected

Search Terms

Go to Type Definition
No type definition found for
getTypeDefinitionsAtPosition - this is one possible method to change in a PR

Suggestion

Go to Type Definition should, when called for a type, return the location of the type definition.

Use Cases

Discussed above

Examples

type X = {a: number};
const a: X = {a: 1};

In VSCode, select and right-click on the second X and choose Go To Type Definition.

Expected: navigates to declaration
Actual: No type definition for 'X'

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

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

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

はじめの一歩

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

調査の方向性

Start with the getTypeDefinitionsAtPosition entry point named in the issue and reproduce the example by selecting the type name in the TypeScript language service. Done means Go To Type Definition returns the type declaration for a selected type instead of reporting that no type definition was found.

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

評価

技術スタック
typescript
領域
compilers, developer-experience
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
48/100

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

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