microsoft / microsoft/TypeScript

Intellisense import suggestions - search index files only

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

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

Awaiting More Feedback Suggestion
主要言語
Go
スター
111k
フォーク
14.3k
平均マージ
2日 4時間
マージ済み PR(30日)
132

説明

Hi guys, in large codebases I often encounter following issue:

I work with React/TypeScript combo. If I export something from a file, it's visible to the entire project and Intellisense auto-import feature suggests me all functions/classes/... exported. It's overwhelming to list through all exports, especially in large projects, where different entities can have the same name. I would love to create some sort of hierarchy with use of index files. Auto-import would implicitly "see" only exports within the same folder or siblings of current folder (recursively) if they have exports declared in index file.

Example:

/src
   /module-alpha
      /components
         Alpha.tsx
         List.tsx
         Detail.tsx
         index.ts --> export {default} from './Alpha.tsx'
      /model
         utils.ts
         index.ts --> export * as Utils from './utils'
      ModuleAlpha.tsx
      index.ts --> export {default} from './ModuleAlpha.tsx'
   /module-beta
      /components
         Beta.tsx
         List.tsx
         Detail.tsx
         index.ts --> export {default} from './Beta.tsx'
      /model
         utils.ts
         index.ts --> export * as Utils from './utils'     
      ModuleBeta.tsx
      index.ts --> export {default} from './ModuleBeta.tsx'

If I am in file /src/module-alpha/components/Alpha.tsx and I type Detail, I want the auto-import to suggest me just Detail within the current folder. In this context I would be able to "see":

  • List and Detail from current folder
  • Utils from /model within this module
  • ModuleAlpha
  • ModuleBeta

In other words - folder will behave like a file. If you want the entity to be visible outside the folder, you would have to explicitly define the export in the index file (recursively). I hope that it's clear.

I don't want to change the ES6 module system, and we could still import the entity manually. I just want the intellisense to suggest me only relevant things.

Is this something that can be done?

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

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

はじめの一歩

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

調査の方向性

まず、既存のIntelliSenseの自動インポートの動作と、TypeScriptがindexファイルからのエクスポートをどのように解決するかを確認します。説明されているmodule-alphaとmodule-betaの構造について候補を比較します。indexファイルで再帰的に宣言されたエクスポートによって候補が制限され、手動インポートは引き続き利用できれば完了です。

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

評価

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

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

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