microsoft / microsoft/TypeScript

From-first import statement completion

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

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

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

説明

Suggestion

import, completion, reverse, inverse, from-first

✅ Viability Checklist

This would be a completion feature for the language server, with no impact on the compiler or language syntax.

⭐ Suggestion

A smoother developer experience for completing imports when the symbol is unknown and the package is.

This is the opposite of the new symbol-first import completion feature proposed for TS 4.3.

📃 Motivating Example

The symbol-first import completion feature is interesting, but I think it somewhat misses a real-world context. Bottom line is that, as developers, we hardly ever actually spend time at the top of the file manually writing imports.

Whenever I know the symbol I want to import, I am usually writing it in-line in my code block, and TS Lang Server is able to complete the import based on its usage. This is 99% of the cases in which I am importing a symbol whose name I know. From this perspective, having completion for import { myFunc } is not so useful.

Given this, the only time I'm actually at the top of a file writing import statements is usually when I know the name of the package, but I don't know exactly what the symbol name is, or where to start. In this case I end up having to write import { } from 'myPackage'; and then going back to the { } and triggering completion.

It would be a small improvement, but being able to write from 'myPackage' and being presented with the list of symbols to select from would be much more relevant in my mind, because the only time we're up the top of the file writing imports is when we DON'T know what symbols we're looking for.

💻 Use Cases

I think the motivating example outlines this sufficiently.

The implementation seems simple. Simple enough at least that a snippet in VSCode or Webstorm ought to be able to match its behaviour.

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

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

はじめの一歩

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

調査の方向性

issue に記載されている TypeScript language server の既存のインポート補完の動作から始めます。from 'myPackage' と入力した後の補完を再現し、シンボルを先に使用するインポート補完と比較します。パッケージのシンボルが、空のインポート句を手動で挿入しなくても提示されれば完了です。

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

評価

技術スタック
typescript
領域
tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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